Skip to content

Commit

Permalink
Add Realm Personalization Value as RawValue to Realm Reference Values
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed May 13, 2024
1 parent 89d797b commit a0e8f54
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions comid/example_cca_realm_refval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func Example_cca_realm_refval() {
// Vendor: Workload Client Ltd
// ClassID: cd1f0e5526f9460db9d8f7fde171787c
// InstanceID: 4284b5694ca6c0d2cf4789a0b95ac8025c818de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f5
// RawValue: e45b72f5c0c0b572db4d8d3ab7e97f368ff74e62347a824decb67a84e5224d75e45b72f5c0c0b572db4d8d3ab7e97f368ff74e62347a824decb67a84e5224d75
// Index: rim
// Alg: sha-384
// Digest: 4284b5694ca6c0d2cf4789a0b95ac8025c818de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f5
Expand Down Expand Up @@ -94,6 +95,9 @@ func extractMeasurements(m Measurements) error {
}

func extractMeasurement(m Measurement) error {

Check failure on line 97 in comid/example_cca_realm_refval_test.go

View workflow job for this annotation

GitHub Actions / Lint

hugeParam: m is heavy (128 bytes); consider passing it by pointer (gocritic)

Check failure on line 97 in comid/example_cca_realm_refval_test.go

View workflow job for this annotation

GitHub Actions / Lint

hugeParam: m is heavy (128 bytes); consider passing it by pointer (gocritic)
if err := extractRealmPersonalizationValue(m.Val.RawValue); err != nil {
return fmt.Errorf("extracting realm personalization value: %w", err)
}
if err := extractIntegrityRegisters(m.Val.IntegrityRegisters); err != nil {
return fmt.Errorf("extracting digest: %w", err)
}
Expand Down Expand Up @@ -142,6 +146,22 @@ func extractRealmInstanceID(i *Instance) error {
return nil
}

func extractRealmPersonalizationValue(r *RawValue) error {
if r == nil {
fmt.Println("realm persoanlization value not present")
return nil
}
b, err := r.GetBytes()
if err != nil {
return err
}
if len(b) != 64 {
return fmt.Errorf("invalid length %d, for realm personalization value", len(b))
}
fmt.Printf("RawValue: %x\n", b)
return nil
}

func extractIntegrityRegisters(r *IntegrityRegisters) error {
if r == nil {
return fmt.Errorf("no integrity registers")
Expand Down
4 changes: 4 additions & 0 deletions comid/test_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ var (
"measurements": [
{
"value": {
"raw-value": {
"type": "bytes",
"value": "5Fty9cDAtXLbTY06t+l/No/3TmI0eoJN7LZ6hOUiTXXkW3L1wMC1cttNjTq36X82j/dOYjR6gk3stnqE5SJNdQ=="
},
"integrity-registers": {
"rim": {
"key-type": "text",
Expand Down

0 comments on commit a0e8f54

Please sign in to comment.