Loading...
Searching...
No Matches
psa_crypto_cbor_encoder.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 HAW Hamburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
25
30#define CBOR_BUF_SIZE_START ( 1 + /* Array encoding */ \
31 1 + /* Array encoding */ \
32 1 + sizeof(psa_key_id_t) + \
33 1 + sizeof(psa_key_type_t) + \
34 1 + sizeof(psa_key_bits_t) + \
35 1 + sizeof(psa_key_lifetime_t) + \
36 1 + /* Array encoding */ \
37 1 + sizeof(psa_key_usage_t) + \
38 1 + sizeof(psa_algorithm_t) \
39 )
40
41#if PSA_SINGLE_KEY_COUNT
46#define CBOR_BUF_SIZE_SINGLE_KEY ( CBOR_BUF_SIZE_START + \
47 3 + /* Bytestring encoding and size */ \
48 PSA_MAX_KEY_DATA_SIZE \
49 )
50#endif /* PSA_SINGLE_KEY_COUNT */
51
52#if PSA_ASYMMETRIC_KEYPAIR_COUNT
57#define CBOR_BUF_SIZE_KEY_PAIR ( CBOR_BUF_SIZE_START + \
58 1 + \
59 3 + PSA_BITS_TO_BYTES(PSA_MAX_PRIV_KEY_SIZE) + \
60 3 + PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
61 )
62#endif /* PSA_ASYMMETRIC_KEYPAIR_COUNT */
63
64#if PSA_PROTECTED_KEY_COUNT && IS_USED(MODULE_PSA_ASYMMETRIC)
69#define CBOR_BUF_SIZE_PROT_KEY ( CBOR_BUF_SIZE_START + \
70 1 + \
71 1 + sizeof(psa_key_slot_number_t) + \
72 3 + PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
73 )
74#elif PSA_PROTECTED_KEY_COUNT
79#define CBOR_BUF_SIZE_PROT_KEY ( CBOR_BUF_SIZE_START + \
80 1 + \
81 1 + sizeof(psa_key_slot_number_t) \
82 )
83#endif /* PSA_PROTECTED_KEY_COUNT */
84
114 size_t output_len, size_t *output_size);
115
126 size_t cbor_buf_size);
127
138 size_t cbor_buf_size);
139
140#ifdef __cplusplus
141}
142#endif
143
struct psa_key_attributes_s psa_key_attributes_t
The type of an object containing key attributes.
Definition attributes.h:157
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.
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.
int32_t psa_status_t
Status code type used for all PSA Certified APIs.
Definition error.h:37
PSA key slot management function declarations.
Structure of a virtual key slot in local memory.