Skip to content

Commit

Permalink
coordinator: add report to mesh certificate
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Jan 9, 2024
1 parent 59b261e commit aa30949
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions coordinator/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/sha256"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/hex"
"fmt"
"log/slog"
Expand Down Expand Up @@ -76,7 +77,9 @@ func (m *meshAuthority) SNPValidateOpts(report *sevsnp.Report) (*validate.Option
}, nil
}

func (m *meshAuthority) ValidateCallback(_ context.Context, report *sevsnp.Report, _ []byte, peerPubKeyBytes []byte) error {
func (m *meshAuthority) ValidateCallback(_ context.Context, report *sevsnp.Report,
oid asn1.ObjectIdentifier, reportRaw, _, peerPubKeyBytes []byte,
) error {
mnfst, err := m.manifests.Latest()
if err != nil {
return fmt.Errorf("getting latest manifest: %w", err)
Expand All @@ -93,7 +96,7 @@ func (m *meshAuthority) ValidateCallback(_ context.Context, report *sevsnp.Repor
return fmt.Errorf("failed to parse peer public key: %w", err)
}

var extensions []pkix.Extension // TODO
extensions := []pkix.Extension{{Id: oid, Value: reportRaw}}
cert, err := m.ca.NewAttestedMeshCert(dnsNames, extensions, peerPubKey)
if err != nil {
return fmt.Errorf("failed to issue new attested mesh cert: %w", err)
Expand Down
7 changes: 5 additions & 2 deletions internal/attestation/snp/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type Validator struct {
}

type validateCallbacker interface {
ValidateCallback(ctx context.Context, report *sevsnp.Report, nonce []byte, peerPublicKey []byte) error
ValidateCallback(ctx context.Context, report *sevsnp.Report, validatorOID asn1.ObjectIdentifier,
reportRaw, nonce, peerPublicKey []byte) error
}

type validateOptsGenerator interface {
Expand Down Expand Up @@ -123,7 +124,9 @@ func (v *Validator) Validate(ctx context.Context, attDocRaw []byte, nonce []byte
// Run callbacks.

for _, callbacker := range v.callbackers {
if err := callbacker.ValidateCallback(ctx, report, nonce, peerPublicKey); err != nil {
if err := callbacker.ValidateCallback(
ctx, report, v.OID(), reportRaw, nonce, peerPublicKey,
); err != nil {
return fmt.Errorf("callback failed: %w", err)
}
}
Expand Down

0 comments on commit aa30949

Please sign in to comment.