Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
setrofim committed Sep 1, 2023
1 parent 3563b51 commit 3799dbe
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
9 changes: 9 additions & 0 deletions comid/cbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ func comidTags() cbor.TagSet {
//551: To Do see: https://github.com/veraison/corim/issues/32
552: TaggedSVN(0),
553: TaggedMinSVN(0),
554: TaggedPKIXBase64Key(""),
555: TaggedPKIXBase64Cert(""),
556: TaggedPKIXBase64CertPath(""),
557: TaggedThumbprint(""),
558: TaggedCOSEKey(""),
559: TaggedCertThumbprint(""),
// TODO(setrofim): there is currently a collision for tag 560 in the CORIM spec.
// see: https://github.com/ietf-rats-wg/draft-ietf-rats-corim/issues/132
//560: TaggedCertPathThumbprint(""),
560: TaggedRawValueBytes{},
// PSA profile tags
600: TaggedImplID{},
Expand Down
45 changes: 44 additions & 1 deletion comid/verifkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,50 @@

package comid

import "fmt"
import (
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
)

// ICryptoKey is the interface implemented by variants of CoRIM
// crypto-key-type-choice. See
// https://www.ietf.org/archive/id/draft-ietf-rats-corim-02.html#name-crypto-keys
type ICryptoKey interface {
Valid() error
}

type TaggedPKIXBase64Key string

func (o TaggedPKIXBase64Key) Valid() error {
block, rest := pem.Decode([]byte(o))
if block == nil {
return errors.New("could not extract PKIX PEM block")
}

if len(rest) != 0 {
return errors.New("trailing data found after PEM block")
}

if block.Type != "PUBLIC KEY" {
return fmt.Errorf("unsupported PEM block type: %q", block.Type)
}

_, err := x509.ParsePKIXPublicKey(block.Bytes)
if err != nil {
return fmt.Errorf("unable to parse public key: %w", err)
}

return nil
}

type TaggedPKIXBase64Cert string
type TaggedPKIXBase64CertPath string
type TaggedThumbprint string
type TaggedCOSEKey string
type TaggedCertThumbprint string
type TaggedCertPathThumbprint string

// VerifKey stores the verification key material associated to a signing key.
// Key is - typically, but not necessarily - a public key. Chain is an optional
Expand Down

0 comments on commit 3799dbe

Please sign in to comment.