mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-06-23 04:10:25 +00:00
This commit is contained in:
committed by
GitHub
parent
c9af8a166b
commit
bd59a4a617
@@ -308,7 +308,7 @@ func changeAttestationConfiguration(fileName, base64Data string, expectedLength
|
||||
return errAttestationPolicyField
|
||||
}
|
||||
|
||||
fileJson, err := json.MarshalIndent(&ac, "", " ")
|
||||
fileJson, err := attestation.ConvertAttestationPolicyToJSON(&ac)
|
||||
if err != nil {
|
||||
return errors.Wrap(errMarshalJSON, err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -120,7 +119,7 @@ func (ms *managerService) FetchAttestationPolicy(_ context.Context, computationI
|
||||
|
||||
attestationPolicy.Config.Policy.MinimumLaunchTcb = vmi.LaunchTCB
|
||||
|
||||
f, err := json.MarshalIndent(attestationPolicy, "", " ")
|
||||
f, err := attestation.ConvertAttestationPolicyToJSON(&attestationPolicy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ var (
|
||||
ErrAttestationPolicyDecode = errors.New("failed to decode Attestation Policy file")
|
||||
ErrAttestationPolicyMissing = errors.New("failed due to missing Attestation Policy file")
|
||||
ErrAttestationPolicyEncode = errors.New("failed to encode the Attestation Policy")
|
||||
ErrProtoMarshalFailed = errors.New("failed to marshal protojson")
|
||||
ErrJsonMarshalFailed = errors.New("failed to marshal json")
|
||||
ErrJsonUnarshalFailed = errors.New("failed to unmarshal json")
|
||||
)
|
||||
|
||||
type PcrValues struct {
|
||||
@@ -98,6 +101,34 @@ func ReadAttestationPolicyFromByte(policyData []byte, attestationConfiguration *
|
||||
return nil
|
||||
}
|
||||
|
||||
func ConvertAttestationPolicyToJSON(attestationConfiguration *Config) ([]byte, error) {
|
||||
pbJson, err := protojson.Marshal(attestationConfiguration.Config)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ErrProtoMarshalFailed, err)
|
||||
}
|
||||
|
||||
var pbMap map[string]interface{}
|
||||
if err := json.Unmarshal(pbJson, &pbMap); err != nil {
|
||||
return nil, errors.Wrap(ErrJsonUnarshalFailed, err)
|
||||
}
|
||||
|
||||
pcrJson, err := json.Marshal(attestationConfiguration.PcrConfig)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ErrJsonMarshalFailed, err)
|
||||
}
|
||||
|
||||
var pcrMap map[string]interface{}
|
||||
if err := json.Unmarshal(pcrJson, &pcrMap); err != nil {
|
||||
return nil, errors.Wrap(ErrJsonUnarshalFailed, err)
|
||||
}
|
||||
|
||||
for k, v := range pcrMap {
|
||||
pbMap[k] = v
|
||||
}
|
||||
|
||||
return json.MarshalIndent(pbMap, "", " ")
|
||||
}
|
||||
|
||||
// CCPlatform returns the type of the confidential computing platform.
|
||||
func CCPlatform() PlatformType {
|
||||
checks := []ccCheck{
|
||||
|
||||
Reference in New Issue
Block a user