Skip to content

Commit

Permalink
Realm provisioning fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed Apr 29, 2024
1 parent 92efbf3 commit 7b04d8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions comid/example_cca_realm_refval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func extractIntegrityRegisters(r *IntegrityRegisters) error {
}

for _, k := range keys {
d, ok := r.m[k]
d, ok := r.M[k]
if !ok {
return fmt.Errorf("unable to locate register index for: %s", k)
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func extractRealmDigests(digests Digests) error {

func extractRegisterIndexes(r *IntegrityRegisters) ([]string, error) {
var keys [5]string
for k := range r.m {
for k := range r.M {
switch t := k.(type) {
case string:
key := strings.ToLower(t)
Expand Down
18 changes: 9 additions & 9 deletions comid/integrityregisters.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type IRegisterIndex interface{}

// IntegrityRegisters holds the Integrity Registers
type IntegrityRegisters struct {
m map[IRegisterIndex]Digests
M map[IRegisterIndex]Digests
}

func NewIntegrityRegisters() *IntegrityRegisters {
return &IntegrityRegisters{m: make(map[IRegisterIndex]Digests)}
return &IntegrityRegisters{M: make(map[IRegisterIndex]Digests)}
}

// AddDigests allows inserting an array of digests at a specific index
Expand All @@ -42,24 +42,24 @@ func (i *IntegrityRegisters) AddDigests(index IRegisterIndex, digests Digests) e
// AddDigest allows inserting a digest at a specific index
// Supported index types are uint and text
func (i *IntegrityRegisters) AddDigest(index IRegisterIndex, digest swid.HashEntry) error {
if i.m == nil {
if i.M == nil {
return fmt.Errorf("no register to add digest")
}
switch t := index.(type) {
case string, uint, uint64:
i.m[t] = append(i.m[t], digest)
i.M[t] = append(i.M[t], digest)
default:
return fmt.Errorf("unexpected type for index: %T", t)
}
return nil
}

func (i IntegrityRegisters) MarshalCBOR() ([]byte, error) {
return em.Marshal(i.m)
return em.Marshal(i.M)
}

func (i *IntegrityRegisters) UnmarshalCBOR(data []byte) error {
return dm.Unmarshal(data, &i.m)
return dm.Unmarshal(data, &i.M)
}

type keyTypeandVal struct {
Expand All @@ -70,7 +70,7 @@ type keyTypeandVal struct {
func (i IntegrityRegisters) MarshalJSON() ([]byte, error) {
jmap := make(map[string]json.RawMessage)
var newkey string
for key, val := range i.m {
for key, val := range i.M {
var ktv keyTypeandVal
switch t := key.(type) {
case uint, uint64:
Expand Down Expand Up @@ -98,8 +98,8 @@ func (i IntegrityRegisters) MarshalJSON() ([]byte, error) {
}

func (i *IntegrityRegisters) UnmarshalJSON(data []byte) error {
if i.m == nil {
i.m = make(map[IRegisterIndex]Digests)
if i.M == nil {
i.M = make(map[IRegisterIndex]Digests)
}
jmap := make(map[string]json.RawMessage)
var index IRegisterIndex
Expand Down

0 comments on commit 7b04d8b

Please sign in to comment.