Loading...
Searching...
No Matches
psa_crypto_operation_encoder.h File Reference

Macros used to map PSA algorithms, key types and key sizes to specific key types and operations to call the corresponding driver functions. More...

Detailed Description

Macros used to map PSA algorithms, key types and key sizes to specific key types and operations to call the corresponding driver functions.

Note
Currently this only supports a small number of operations. It should be expanded as needed as this implementation increases support for more operations.
Author
Lena Boeckmann lena..nosp@m.boec.nosp@m.kmann.nosp@m.@haw.nosp@m.-hamb.nosp@m.urg..nosp@m.de

Definition in file psa_crypto_operation_encoder.h.

+ Include dependency graph for psa_crypto_operation_encoder.h:

Go to the source code of this file.

#define PSA_INVALID_OPERATION   (0xFF)
 Unknown or invalid operation.
 
#define PSA_ENCODE_ECC_KEY_TYPE_SECPR1(bits)
 Combine a SECP_R1 key type with a given key size (private or public key).
 
#define PSA_ENCODE_ECC_KEY_TYPE_EDWARDS(bits)
 Combine a Twisted Edwards key type with a given key size (private or public key).
 
#define PSA_ENCODE_ECC_KEY_TYPE(bits, curve)
 Map an ECC key to a given curve according to its type and size.
 
#define GET_CBC_NO_PADDING_OPERATION(type, bits)
 Combine key type and size with a PSA_ALG_CBC_NO_PADDING algorithm.
 
#define GET_CBC_PKCS7_OPERATION(type, bits)
 Combine key type and size with a PSA_ALG_CBC_PKCS7 algorithm.
 
#define GET_CFB_OPERATION(type, bits)    (PSA_INVALID_OPERATION)
 Combine key type and size with a PSA_ALG_CFB algorithm.
 
#define GET_CTR_OPERATION(type, bits)    (PSA_INVALID_OPERATION)
 Combine key type and size with a PSA_ALG_CTR algorithm.
 
#define GET_ECB_NO_PADDING_OPERATION(type, bits)    (PSA_INVALID_OPERATION)
 Combine key type and size with a PSA_ALG_ECB_NO_PADDING algorithm.
 
#define GET_OFB_OPERATION(type, bits)    (PSA_INVALID_OPERATION)
 Combine key type and size with a PSA_ALG_OFB algorithm.
 
#define GET_STREAM_CIPHER_OPERATION(type, bits)
 Combine key type and size with a PSA_ALG_STREAM_CIPHER algorithm.
 
#define GET_XTS_OPERATION(type, bits)    (PSA_INVALID_OPERATION)
 Combine key type and size with a PSA_ALG_XTS algorithm.
 
#define PSA_ENCODE_CIPHER_OPERATION(alg, type, bits)
 Map algorithm, key size and type to a specific operation.
 
enum  psa_cipher_op_t {
  PSA_CBC_NO_PAD_AES_128 , PSA_CBC_NO_PAD_AES_192 , PSA_CBC_NO_PAD_AES_256 , PSA_CBC_PKCS7_AES_256 ,
  PSA_STREAM_CIPHER_CHACHA20
}
 Enum encoding available cipher operations. More...
 
enum  psa_asym_key_t {
  PSA_ECC_P160_K1 , PSA_ECC_P160_R1 , PSA_ECC_P160_R2 , PSA_ECC_P192_K1 ,
  PSA_ECC_P192_R1 , PSA_ECC_P224_K1 , PSA_ECC_P224_R1 , PSA_ECC_P256_K1 ,
  PSA_ECC_P256_R1 , PSA_ECC_P384_R1 , PSA_ECC_P521_R1 , PSA_ECC_FRP ,
  PSA_ECC_ED25519
}
 Enum encoding available asymmetric key types and sizes. More...
 

Macro Definition Documentation

◆ GET_CBC_NO_PADDING_OPERATION

#define GET_CBC_NO_PADDING_OPERATION (   type,
  bits 
)
Value:
((type == PSA_KEY_TYPE_AES) ? \
((bits == 128) ? PSA_CBC_NO_PAD_AES_128 : \
(bits == 192) ? PSA_CBC_NO_PAD_AES_192 : \
(bits == 256) ? PSA_CBC_NO_PAD_AES_256 : \
#define PSA_KEY_TYPE_AES
Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.
#define PSA_INVALID_OPERATION
Unknown or invalid operation.

Combine key type and size with a PSA_ALG_CBC_NO_PADDING algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 121 of file psa_crypto_operation_encoder.h.

◆ GET_CBC_PKCS7_OPERATION

#define GET_CBC_PKCS7_OPERATION (   type,
  bits 
)
Value:
(((alg == PSA_ALG_CBC_PKCS7) && (type == PSA_KEY_TYPE_AES)) ? PSA_CBC_PKCS7_AES_256 : \
#define PSA_ALG_CBC_PKCS7
The Cipher Block Chaining (CBC) mode of a block cipher, with PKCS#7 padding.

Combine key type and size with a PSA_ALG_CBC_PKCS7 algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 138 of file psa_crypto_operation_encoder.h.

◆ GET_CFB_OPERATION

#define GET_CFB_OPERATION (   type,
  bits 
)     (PSA_INVALID_OPERATION)

Combine key type and size with a PSA_ALG_CFB algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 151 of file psa_crypto_operation_encoder.h.

◆ GET_CTR_OPERATION

#define GET_CTR_OPERATION (   type,
  bits 
)     (PSA_INVALID_OPERATION)

Combine key type and size with a PSA_ALG_CTR algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 163 of file psa_crypto_operation_encoder.h.

◆ GET_ECB_NO_PADDING_OPERATION

#define GET_ECB_NO_PADDING_OPERATION (   type,
  bits 
)     (PSA_INVALID_OPERATION)

Combine key type and size with a PSA_ALG_ECB_NO_PADDING algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 175 of file psa_crypto_operation_encoder.h.

◆ GET_OFB_OPERATION

#define GET_OFB_OPERATION (   type,
  bits 
)     (PSA_INVALID_OPERATION)

Combine key type and size with a PSA_ALG_OFB algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 187 of file psa_crypto_operation_encoder.h.

◆ GET_STREAM_CIPHER_OPERATION

#define GET_STREAM_CIPHER_OPERATION (   type,
  bits 
)
Value:
(((type == PSA_KEY_TYPE_CHACHA20) && (bits == 256)) ? PSA_STREAM_CIPHER_CHACHA20 : \
#define PSA_KEY_TYPE_CHACHA20
Key for the ChaCha20 stream cipher or the ChaCha20-Poly1305 AEAD algorithm.

Combine key type and size with a PSA_ALG_STREAM_CIPHER algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 199 of file psa_crypto_operation_encoder.h.

◆ GET_XTS_OPERATION

#define GET_XTS_OPERATION (   type,
  bits 
)     (PSA_INVALID_OPERATION)

Combine key type and size with a PSA_ALG_XTS algorithm.

Parameters
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 212 of file psa_crypto_operation_encoder.h.

◆ PSA_ENCODE_CIPHER_OPERATION

#define PSA_ENCODE_CIPHER_OPERATION (   alg,
  type,
  bits 
)
Value:
(alg == PSA_ALG_CBC_PKCS7) ? GET_CBC_PKCS7_OPERATION(type, bits) : \
(alg == PSA_ALG_CFB) ? GET_CFB_OPERATION(type, bits) : \
(alg == PSA_ALG_CTR) ? GET_CTR_OPERATION(type, bits) : \
(alg == PSA_ALG_OFB) ? GET_OFB_OPERATION(type, bits) : \
(alg == PSA_ALG_XTS) ? GET_XTS_OPERATION(type, bits) : \
#define PSA_ALG_CFB
A stream cipher built using the Cipher Feedback (CFB) mode of a block cipher.
#define PSA_ALG_XTS
The XEX with Ciphertext Stealing (XTS) cipher mode of a block cipher.
#define PSA_ALG_ECB_NO_PADDING
The Electronic Codebook (ECB) mode of a block cipher, with no padding.
#define PSA_ALG_CBC_NO_PADDING
The Cipher Block Chaining (CBC) mode of a block cipher, with no padding.
#define PSA_ALG_CTR
A stream cipher built using the Counter (CTR) mode of a block cipher.
#define PSA_ALG_STREAM_CIPHER
The stream cipher mode of a stream cipher algorithm.
#define PSA_ALG_OFB
A stream cipher built using the Output Feedback (OFB) mode of a block cipher.
#define GET_STREAM_CIPHER_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_STREAM_CIPHER algorithm.
#define GET_XTS_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_XTS algorithm.
#define GET_ECB_NO_PADDING_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_ECB_NO_PADDING algorithm.
#define GET_CFB_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_CFB algorithm.
#define GET_OFB_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_OFB algorithm.
#define GET_CTR_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_CTR algorithm.
#define GET_CBC_PKCS7_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_CBC_PKCS7 algorithm.
#define GET_CBC_NO_PADDING_OPERATION(type, bits)
Combine key type and size with a PSA_ALG_CBC_NO_PADDING algorithm.

Map algorithm, key size and type to a specific operation.

Parameters
algAlgorithm of type psa_algorithm_t.
typeKey type of type psa_key_type_t
bitsSize of the used key of type psa_key_bits_t
Returns
psa_cipher_op_t
PSA_INVALID_OPERATION alg, bits and type are not compatible

Definition at line 225 of file psa_crypto_operation_encoder.h.

◆ PSA_ENCODE_ECC_KEY_TYPE

#define PSA_ENCODE_ECC_KEY_TYPE (   bits,
  curve 
)
Value:
#define PSA_ECC_FAMILY_SECP_R1
SEC random curves over prime fields.
#define PSA_ECC_FAMILY_TWISTED_EDWARDS
Twisted Edwards curves.
#define PSA_ENCODE_ECC_KEY_TYPE_SECPR1(bits)
Combine a SECP_R1 key type with a given key size (private or public key).
#define PSA_ENCODE_ECC_KEY_TYPE_EDWARDS(bits)
Combine a Twisted Edwards key type with a given key size (private or public key).

Map an ECC key to a given curve according to its type and size.

Parameters
bitsKey size of type psa_key_bits_t
curveMust be a curve of type psa_ecc_family_t
Returns
psa_asym_key_t
PSA_INVALID_OPERATION curve and bits are incompatible

Definition at line 107 of file psa_crypto_operation_encoder.h.

◆ PSA_ENCODE_ECC_KEY_TYPE_EDWARDS

#define PSA_ENCODE_ECC_KEY_TYPE_EDWARDS (   bits)
Value:
((bits == 255) || (bits == 256) ? PSA_ECC_ED25519 : \

Combine a Twisted Edwards key type with a given key size (private or public key).

Parameters
bitsKey size of type psa_key_bits_t
Returns
psa_asym_key_t
PSA_INVALID_OPERATION bits is not compatible with Twisted Edwards curves

Definition at line 94 of file psa_crypto_operation_encoder.h.

◆ PSA_ENCODE_ECC_KEY_TYPE_SECPR1

#define PSA_ENCODE_ECC_KEY_TYPE_SECPR1 (   bits)
Value:
((bits == 256) || (bits == 520) ? PSA_ECC_P256_R1 : \
(bits == 192) || (bits == 392) ? PSA_ECC_P192_R1 : \

Combine a SECP_R1 key type with a given key size (private or public key).

Parameters
bitsKey size of type psa_key_bits_t
Returns
psa_asym_key_t
PSA_INVALID_OPERATION bits is not compatible with SECP_R1 curves

Definition at line 81 of file psa_crypto_operation_encoder.h.

◆ PSA_INVALID_OPERATION

#define PSA_INVALID_OPERATION   (0xFF)

Unknown or invalid operation.

Definition at line 37 of file psa_crypto_operation_encoder.h.

Enumeration Type Documentation

◆ psa_asym_key_t

Enum encoding available asymmetric key types and sizes.

To be expanded with the development of this implementation.

Definition at line 57 of file psa_crypto_operation_encoder.h.

◆ psa_cipher_op_t

Enum encoding available cipher operations.

To be expanded with the development of this implementation.

Definition at line 44 of file psa_crypto_operation_encoder.h.