24#ifndef PSA_CRYPTO_OPERATION_ENCODER_H
25#define PSA_CRYPTO_OPERATION_ENCODER_H
37#define PSA_INVALID_OPERATION (0xFF)
45 PSA_CBC_NO_PAD_AES_128,
46 PSA_CBC_NO_PAD_AES_192,
47 PSA_CBC_NO_PAD_AES_256,
48 PSA_CBC_PKCS7_AES_256,
49 PSA_STREAM_CIPHER_CHACHA20
81#define PSA_ENCODE_ECC_KEY_TYPE_SECPR1(bits) \
82 ((bits == 256) || (bits == 520) ? PSA_ECC_P256_R1 : \
83 (bits == 192) || (bits == 392) ? PSA_ECC_P192_R1 : \
84 PSA_INVALID_OPERATION)
94#define PSA_ENCODE_ECC_KEY_TYPE_EDWARDS(bits) \
95 ((bits == 255) || (bits == 256) ? PSA_ECC_ED25519 : \
96 PSA_INVALID_OPERATION)
107#define PSA_ENCODE_ECC_KEY_TYPE(bits, curve) \
108 ((curve == PSA_ECC_FAMILY_SECP_R1) ? PSA_ENCODE_ECC_KEY_TYPE_SECPR1(bits) : \
109 (curve == PSA_ECC_FAMILY_TWISTED_EDWARDS) ? PSA_ENCODE_ECC_KEY_TYPE_EDWARDS(bits) : \
110 PSA_INVALID_OPERATION)
121#define GET_CBC_NO_PADDING_OPERATION(type, bits) \
122 ((type == PSA_KEY_TYPE_AES) ? \
123 ((bits == 128) ? PSA_CBC_NO_PAD_AES_128 : \
124 (bits == 192) ? PSA_CBC_NO_PAD_AES_192 : \
125 (bits == 256) ? PSA_CBC_NO_PAD_AES_256 : \
126 PSA_INVALID_OPERATION) : \
127 PSA_INVALID_OPERATION)
138#define GET_CBC_PKCS7_OPERATION(type, bits) \
139 (((alg == PSA_ALG_CBC_PKCS7) && (type == PSA_KEY_TYPE_AES)) ? PSA_CBC_PKCS7_AES_256 : \
140 PSA_INVALID_OPERATION)
151#define GET_CFB_OPERATION(type, bits) \
152 (PSA_INVALID_OPERATION)
163#define GET_CTR_OPERATION(type, bits) \
164 (PSA_INVALID_OPERATION)
175#define GET_ECB_NO_PADDING_OPERATION(type, bits) \
176 (PSA_INVALID_OPERATION)
187#define GET_OFB_OPERATION(type, bits) \
188 (PSA_INVALID_OPERATION)
199#define GET_STREAM_CIPHER_OPERATION(type, bits) \
200 (((type == PSA_KEY_TYPE_CHACHA20) && (bits == 256)) ? PSA_STREAM_CIPHER_CHACHA20 : \
201 PSA_INVALID_OPERATION)
212#define GET_XTS_OPERATION(type, bits) \
213 (PSA_INVALID_OPERATION)
225#define PSA_ENCODE_CIPHER_OPERATION(alg, type, bits) \
226 ((alg == PSA_ALG_CBC_NO_PADDING) ? GET_CBC_NO_PADDING_OPERATION(type, bits) : \
227 (alg == PSA_ALG_CBC_PKCS7) ? GET_CBC_PKCS7_OPERATION(type, bits) : \
228 (alg == PSA_ALG_CFB) ? GET_CFB_OPERATION(type, bits) : \
229 (alg == PSA_ALG_CTR) ? GET_CTR_OPERATION(type, bits) : \
230 (alg == PSA_ALG_ECB_NO_PADDING) ? GET_ECB_NO_PADDING_OPERATION(type, bits) : \
231 (alg == PSA_ALG_OFB) ? GET_OFB_OPERATION(type, bits) : \
232 (alg == PSA_ALG_STREAM_CIPHER) ? GET_STREAM_CIPHER_OPERATION(type, bits) : \
233 (alg == PSA_ALG_XTS) ? GET_XTS_OPERATION(type, bits) : \
234 PSA_INVALID_OPERATION)
Function declarations for PSA Crypto.
psa_cipher_op_t
Enum encoding available cipher operations.
psa_asym_key_t
Enum encoding available asymmetric key types and sizes.
PSA key slot management function declarations.