Skip to content

Commit

Permalink
fix: Pass extended header list as unconstructed TLV
Browse files Browse the repository at this point in the history
Signed-off-by: Steffen Vogel <[email protected]>
  • Loading branch information
stv0g committed Dec 9, 2024
1 parent b5d5545 commit 313aad2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion key.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@ func (c *Card) ImportKey(key KeyRef, skImport crypto.PrivateKey) (crypto.Private
return nil, ErrUnsupportedKeyType
}

if err := c.putDataTLV(tlv.New(tagExtendedHeaderList, key.crt(), cpkt, cpk)); err != nil {
// We are encoding the extended header list as a byte sequence here
// as its tag (0x4d) is a non-constructed BER-TLV tag.
// Note: this may be a mistake in the specification.
hdrData, err := tlv.EncodeBER(
key.crt(), cpkt, cpk,
)
if err != nil {
return nil, err
}

if err := c.putDataTLV(tlv.New(tagExtendedHeaderList, hdrData)); err != nil {
return nil, fmt.Errorf("failed to import key: %w", err)
}

Expand Down

0 comments on commit 313aad2

Please sign in to comment.