Loading...
Searching...
No Matches
psa_crypto_cbor_encoder.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 HAW Hamburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
21#ifndef PSA_CRYPTO_CBOR_ENCODER_H
22#define PSA_CRYPTO_CBOR_ENCODER_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
29
34#define CBOR_BUF_SIZE_START ( 1 + /* Array encoding */ \
35 1 + /* Array encoding */ \
36 1 + sizeof(psa_key_id_t) + \
37 1 + sizeof(psa_key_type_t) + \
38 1 + sizeof(psa_key_bits_t) + \
39 1 + sizeof(psa_key_lifetime_t) + \
40 1 + /* Array encoding */ \
41 1 + sizeof(psa_key_usage_t) + \
42 1 + sizeof(psa_algorithm_t) \
43 )
44
45#if PSA_SINGLE_KEY_COUNT
50#define CBOR_BUF_SIZE_SINGLE_KEY ( CBOR_BUF_SIZE_START + \
51 3 + /* Bytestring encoding and size */ \
52 PSA_MAX_KEY_DATA_SIZE \
53 )
54#endif /* PSA_SINGLE_KEY_COUNT */
55
56#if PSA_ASYMMETRIC_KEYPAIR_COUNT
61#define CBOR_BUF_SIZE_KEY_PAIR ( CBOR_BUF_SIZE_START + \
62 1 + \
63 3 + PSA_BITS_TO_BYTES(PSA_MAX_PRIV_KEY_SIZE) + \
64 3 + PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
65 )
66#endif /* PSA_ASYMMETRIC_KEYPAIR_COUNT */
67
68#if PSA_PROTECTED_KEY_COUNT && IS_USED(MODULE_PSA_ASYMMETRIC)
73#define CBOR_BUF_SIZE_PROT_KEY ( CBOR_BUF_SIZE_START + \
74 1 + \
75 1 + sizeof(psa_key_slot_number_t) + \
76 3 + PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
77 )
78#elif PSA_PROTECTED_KEY_COUNT
83#define CBOR_BUF_SIZE_PROT_KEY ( CBOR_BUF_SIZE_START + \
84 1 + \
85 1 + sizeof(psa_key_slot_number_t) \
86 )
87#endif /* PSA_PROTECTED_KEY_COUNT */
88
118 size_t output_len, size_t *output_size);
119
130 size_t cbor_buf_size);
131
142 size_t cbor_buf_size);
143
144#ifdef __cplusplus
145}
146#endif
147
148#endif /* PSA_CRYPTO_CBOR_ENCODER_H */
int32_t psa_status_t
Function return status.
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.
PSA key slot management function declarations.
Structure storing key attributes.
Structure of a virtual key slot in local memory.