Mbed OS Reference
|
PSA cryptography module: Mbed TLS buffer size macros. More...
#include "mbedtls/config.h"
Go to the source code of this file.
Macros | |
#define | PSA_HASH_SIZE(alg) |
The size of the output of psa_hash_finish(), in bytes. More... | |
#define | PSA_HASH_MAX_SIZE 32 |
Maximum size of a hash. More... | |
#define | PSA_MAC_MAX_SIZE PSA_HASH_MAX_SIZE |
Maximum size of a MAC. More... | |
#define | PSA_AEAD_TAG_LENGTH(alg) |
The tag size for an AEAD algorithm, in bytes. More... | |
#define | PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN 128 |
This macro returns the maximum length of the PSK supported by the TLS-1.2 PSK-to-MS key derivation. More... | |
#define | PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE 16 |
The maximum size of a block cipher supported by the implementation. More... | |
#define | PSA_MAC_FINAL_SIZE(key_type, key_bits, alg) |
The size of the output of psa_mac_sign_finish(), in bytes. More... | |
#define | PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) |
The maximum size of the output of psa_aead_encrypt(), in bytes. More... | |
#define | PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) |
The maximum size of the output of psa_aead_decrypt(), in bytes. More... | |
#define | PSA_AEAD_UPDATE_OUTPUT_SIZE(alg, input_length) |
A sufficient output buffer size for psa_aead_update(). More... | |
#define | PSA_AEAD_FINISH_OUTPUT_SIZE(alg) |
A sufficient ciphertext buffer size for psa_aead_finish(). More... | |
#define | PSA_AEAD_VERIFY_OUTPUT_SIZE(alg) |
A sufficient plaintext buffer size for psa_aead_verify(). More... | |
#define | PSA_ECDSA_SIGNATURE_SIZE(curve_bits) (PSA_BITS_TO_BYTES(curve_bits) * 2) |
ECDSA signature size for a given curve bit size. More... | |
#define | PSA_SIGN_OUTPUT_SIZE(key_type, key_bits, alg) |
Sufficient signature buffer size for psa_sign_hash(). More... | |
#define | PSA_SIGNATURE_MAX_SIZE |
Maximum size of an asymmetric signature. More... | |
#define | PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(key_type, key_bits, alg) |
Sufficient output buffer size for psa_asymmetric_encrypt(). More... | |
#define | PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(key_type, key_bits, alg) |
Sufficient output buffer size for psa_asymmetric_decrypt(). More... | |
#define | PSA_KEY_EXPORT_MAX_SIZE(key_type, key_bits) |
Sufficient output buffer size for psa_export_key() or psa_export_public_key(). More... | |
#define | PSA_AEAD_NONCE_LENGTH(key_type, alg) |
The default nonce size for an AEAD algorithm, in bytes. More... | |
#define | PSA_AEAD_NONCE_MAX_SIZE 12 |
The maximum default nonce size among all supported pairs of key types and AEAD algorithms, in bytes. More... | |
#define | PSA_CIPHER_IV_LENGTH(key_type, alg) |
The default IV size for a cipher algorithm, in bytes. More... | |
#define | PSA_CIPHER_IV_MAX_SIZE 16 |
The maximum IV size for all supported cipher algorithms, in bytes. More... | |
PSA cryptography module: Mbed TLS buffer size macros.
This file contains the definitions of macros that are useful to compute buffer sizes. The signatures and semantics of these macros are standardized, but the definitions are not, because they depend on the available algorithms and, in some cases, on permitted tolerances on buffer sizes.
In implementations with isolation between the application and the cryptography module, implementers should take care to ensure that the definitions that are exposed to applications match what the module implements.
Macros that compute sizes whose values do not depend on the implementation are in crypto.h.
Definition in file crypto_sizes.h.
#define PSA_HASH_SIZE | ( | alg | ) |
The size of the output of psa_hash_finish(), in bytes.
This is also the hash size that psa_hash_verify() expects.
alg | A hash algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_HASH(alg ) is true), or an HMAC algorithm (PSA_ALG_HMAC(hash_alg ) where hash_alg is a hash algorithm). |
Definition at line 71 of file crypto_sizes.h.
#define PSA_HASH_MAX_SIZE 32 |
Maximum size of a hash.
This macro must expand to a compile-time constant integer. This value should be the maximum size of a hash supported by the implementation, in bytes, and must be no smaller than this maximum.
Definition at line 105 of file crypto_sizes.h.
#define PSA_MAC_MAX_SIZE PSA_HASH_MAX_SIZE |
Maximum size of a MAC.
This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum.
Definition at line 122 of file crypto_sizes.h.
#define PSA_AEAD_TAG_LENGTH | ( | alg | ) |
The tag size for an AEAD algorithm, in bytes.
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
Definition at line 139 of file crypto_sizes.h.
#define PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN 128 |
This macro returns the maximum length of the PSK supported by the TLS-1.2 PSK-to-MS key derivation.
Quoting RFC 4279, Sect 5.3: TLS implementations supporting these ciphersuites MUST support arbitrary PSK identities up to 128 octets in length, and arbitrary PSKs up to 64 octets in length. Supporting longer identities and keys is RECOMMENDED.
Therefore, no implementation should define a value smaller than 64 for PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN.
Definition at line 205 of file crypto_sizes.h.
#define PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE 16 |
The maximum size of a block cipher supported by the implementation.
Definition at line 208 of file crypto_sizes.h.
#define PSA_MAC_FINAL_SIZE | ( | key_type, | |
key_bits, | |||
alg | |||
) |
The size of the output of psa_mac_sign_finish(), in bytes.
This is also the MAC size that psa_mac_verify_finish() expects.
key_type | The type of the MAC key. |
key_bits | The size of the MAC key in bits. |
alg | A MAC algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_MAC(alg ) is true). |
Definition at line 227 of file crypto_sizes.h.
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE | ( | alg, | |
plaintext_length | |||
) |
The maximum size of the output of psa_aead_encrypt(), in bytes.
If the size of the ciphertext buffer is at least this large, it is guaranteed that psa_aead_encrypt() will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the ciphertext may be smaller.
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
plaintext_length | Size of the plaintext in bytes. |
Definition at line 252 of file crypto_sizes.h.
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE | ( | alg, | |
ciphertext_length | |||
) |
The maximum size of the output of psa_aead_decrypt(), in bytes.
If the size of the plaintext buffer is at least this large, it is guaranteed that psa_aead_decrypt() will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the plaintext may be smaller.
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
ciphertext_length | Size of the plaintext in bytes. |
Definition at line 276 of file crypto_sizes.h.
#define PSA_AEAD_UPDATE_OUTPUT_SIZE | ( | alg, | |
input_length | |||
) |
A sufficient output buffer size for psa_aead_update().
If the size of the output buffer is at least this large, it is guaranteed that psa_aead_update() will not fail due to an insufficient buffer size. The actual size of the output may be smaller in any given call.
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
input_length | Size of the input in bytes. |
Definition at line 304 of file crypto_sizes.h.
#define PSA_AEAD_FINISH_OUTPUT_SIZE | ( | alg | ) |
A sufficient ciphertext buffer size for psa_aead_finish().
If the size of the ciphertext buffer is at least this large, it is guaranteed that psa_aead_finish() will not fail due to an insufficient ciphertext buffer size. The actual size of the output may be smaller in any given call.
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
Definition at line 327 of file crypto_sizes.h.
#define PSA_AEAD_VERIFY_OUTPUT_SIZE | ( | alg | ) |
A sufficient plaintext buffer size for psa_aead_verify().
If the size of the plaintext buffer is at least this large, it is guaranteed that psa_aead_verify() will not fail due to an insufficient plaintext buffer size. The actual size of the output may be smaller in any given call.
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
Definition at line 350 of file crypto_sizes.h.
#define PSA_ECDSA_SIGNATURE_SIZE | ( | curve_bits | ) | (PSA_BITS_TO_BYTES(curve_bits) * 2) |
ECDSA signature size for a given curve bit size.
curve_bits | Curve size in bits. |
Definition at line 368 of file crypto_sizes.h.
#define PSA_SIGN_OUTPUT_SIZE | ( | key_type, | |
key_bits, | |||
alg | |||
) |
Sufficient signature buffer size for psa_sign_hash().
This macro returns a sufficient buffer size for a signature using a key of the specified type and size, with the specified algorithm. Note that the actual size of the signature may be smaller (some algorithms produce a variable-size signature).
key_type | An asymmetric key type (this may indifferently be a key pair type or a public key type). |
key_bits | The size of the key in bits. |
alg | The signature algorithm. |
Definition at line 397 of file crypto_sizes.h.
#define PSA_SIGNATURE_MAX_SIZE |
Maximum size of an asymmetric signature.
This macro must expand to a compile-time constant integer. This value should be the maximum size of a signature supported by the implementation, in bytes, and must be no smaller than this maximum.
Definition at line 413 of file crypto_sizes.h.
#define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE | ( | key_type, | |
key_bits, | |||
alg | |||
) |
Sufficient output buffer size for psa_asymmetric_encrypt().
This macro returns a sufficient buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.
key_type | An asymmetric key type (this may indifferently be a key pair type or a public key type). |
key_bits | The size of the key in bits. |
alg | The asymmetric encryption algorithm. |
Definition at line 444 of file crypto_sizes.h.
#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE | ( | key_type, | |
key_bits, | |||
alg | |||
) |
Sufficient output buffer size for psa_asymmetric_decrypt().
This macro returns a sufficient buffer size for a plaintext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the plaintext may be smaller, depending on the algorithm.
key_type | An asymmetric key type (this may indifferently be a key pair type or a public key type). |
key_bits | The size of the key in bits. |
alg | The asymmetric encryption algorithm. |
Definition at line 475 of file crypto_sizes.h.
#define PSA_KEY_EXPORT_MAX_SIZE | ( | key_type, | |
key_bits | |||
) |
Sufficient output buffer size for psa_export_key() or psa_export_public_key().
This macro returns a compile-time constant if its arguments are compile-time constants.
The following code illustrates how to allocate enough memory to export a key by querying the key type and size at runtime.
For psa_export_public_key(), calculate the buffer size from the public key type. You can use the macro PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR to convert a key pair type to the corresponding public key type.
key_type | A supported key type. |
key_bits | The size of the key in bits. |
Definition at line 650 of file crypto_sizes.h.
#define PSA_AEAD_NONCE_LENGTH | ( | key_type, | |
alg | |||
) |
The default nonce size for an AEAD algorithm, in bytes.
This macro can be used to allocate a buffer of sufficient size to store the nonce output from psa_aead_generate_nonce().
See also PSA_AEAD_NONCE_MAX_SIZE.
key_type | A symmetric key type that is compatible with algorithm alg . |
alg | An AEAD algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_AEAD(alg ) is true). |
Definition at line 685 of file crypto_sizes.h.
#define PSA_AEAD_NONCE_MAX_SIZE 12 |
The maximum default nonce size among all supported pairs of key types and AEAD algorithms, in bytes.
This is equal to or greater than any value that PSA_AEAD_NONCE_LENGTH() may return.
Definition at line 701 of file crypto_sizes.h.
#define PSA_CIPHER_IV_LENGTH | ( | key_type, | |
alg | |||
) |
The default IV size for a cipher algorithm, in bytes.
The IV that is generated as part of a call to psa_cipher_encrypt() is always the default IV length for the algorithm.
This macro can be used to allocate a buffer of sufficient size to store the IV output from psa_cipher_generate_iv() when using a multi-part cipher operation.
See also PSA_CIPHER_IV_MAX_SIZE.
key_type | A symmetric key type that is compatible with algorithm alg . |
alg | A cipher algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_CIPHER(alg ) is true). |
Definition at line 729 of file crypto_sizes.h.
#define PSA_CIPHER_IV_MAX_SIZE 16 |
The maximum IV size for all supported cipher algorithms, in bytes.
See also PSA_CIPHER_IV_LENGTH().
Definition at line 745 of file crypto_sizes.h.