Loading...
Searching...
No Matches
Module for encoding PSA keys in CBOR

Detailed Description

Files

file  psa_crypto_cbor_encoder.h
 

Macros

#define CBOR_BUF_SIZE_START
 Required size of CBOR output buffer from start to end of attributes.
 

Functions

psa_status_t psa_encode_key_slot (psa_key_slot_t *slot, uint8_t *output, size_t output_len, size_t *output_size)
 Encodes a basic key slot in CBOR.
 
psa_status_t psa_decode_key_slot_data (psa_key_slot_t *slot, uint8_t *cbor_buf, size_t cbor_buf_size)
 Decode CBOR encoded key data and write to PSA key slot.
 
psa_status_t psa_decode_key_attributes (psa_key_attributes_t *attr, uint8_t *cbor_buf, size_t cbor_buf_size)
 Decode CBOR PSA key attributes.
 

Macro Definition Documentation

◆ CBOR_BUF_SIZE_START

#define CBOR_BUF_SIZE_START
Value:
( 1 + /* Array encoding */ \
1 + /* Array encoding */ \
1 + sizeof(psa_key_id_t) + \
1 + sizeof(psa_key_type_t) + \
1 + sizeof(psa_key_bits_t) + \
1 + sizeof(psa_key_lifetime_t) + \
1 + /* Array encoding */ \
1 + sizeof(psa_key_usage_t) + \
1 + sizeof(psa_algorithm_t) \
)
uint32_t psa_key_id_t
Key identifier.
uint16_t psa_key_bits_t
Public interfaces use size_t, but internally we use a smaller type.
uint16_t psa_key_type_t
Encoding of a key type.
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.

Required size of CBOR output buffer from start to end of attributes.

Adds attributes sizes to CBOR encodings for individual values.

Definition at line 34 of file psa_crypto_cbor_encoder.h.

Function Documentation

◆ psa_decode_key_attributes()

psa_status_t psa_decode_key_attributes ( psa_key_attributes_t attr,
uint8_t *  cbor_buf,
size_t  cbor_buf_size 
)

Decode CBOR PSA key attributes.

Only decodes key attributes and not the actual key. Key can be decoded with psa_decode_key_slot_data.

Parameters
attrKey attribute struct to store decoded attributes
cbor_bufBuffer containing CBOR encoded data
cbor_buf_sizeSize of cbor_buf
Returns
psa_status_t

◆ psa_decode_key_slot_data()

psa_status_t psa_decode_key_slot_data ( psa_key_slot_t slot,
uint8_t *  cbor_buf,
size_t  cbor_buf_size 
)

Decode CBOR encoded key data and write to PSA key slot.

Only decodes the key and should be called in combination with psa_decode_key_attributes.

Parameters
slotPointer to key slot to write decoded key to
cbor_bufBuffer containing CBOR encoded data
cbor_buf_sizeSize of cbor_buf
Returns
psa_status_t

◆ psa_encode_key_slot()

psa_status_t psa_encode_key_slot ( psa_key_slot_t slot,
uint8_t *  output,
size_t  output_len,
size_t *  output_size 
)

Encodes a basic key slot in CBOR.

     Single Key Format:
     -   [
             [ID, Type, Bits, Lifetime, [Usage, Algorithm]],
             h'key
         ]

     Asymmetric Key Pair Format:
     -   [
             [ID, Type, Bits, Lifetime, [Usage, Algorithm]],
             [h'private_key, h'public_key]
         ]

     Protected Key Format:
     -   [
             [ID, Type, Bits, Lifetime, [Usage, Algorithm]],
             [Slot No, *optional: h'public_key*]
         ]
Parameters
[in]slotPointer to slot containing the key to encode
[in]outputBuffer to write the encoded key to
[in]output_lenLength of output buffer
[out]output_sizePointer to write actual length of encoding
Returns
psa_status_t