NCBI C++ ToolKit
Functions
psa_crypto_rsa.h File Reference
#include <psa/crypto.h>
#include <mbedtls/rsa.h>
+ Include dependency graph for psa_crypto_rsa.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Functions

psa_status_t mbedtls_psa_rsa_load_representation (psa_key_type_t type, const uint8_t *data, size_t data_length, mbedtls_rsa_context **p_rsa)
 Load the contents of a key buffer into an internal RSA representation. More...
 
psa_status_t mbedtls_psa_rsa_import_key (const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length, size_t *bits)
 Import an RSA key in binary format. More...
 
psa_status_t mbedtls_psa_rsa_export_key (psa_key_type_t type, mbedtls_rsa_context *rsa, uint8_t *data, size_t data_size, size_t *data_length)
 Export an RSA key to export representation. More...
 
psa_status_t mbedtls_psa_rsa_export_public_key (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, uint8_t *data, size_t data_size, size_t *data_length)
 Export a public RSA key or the public part of an RSA key pair in binary format. More...
 
psa_status_t mbedtls_psa_rsa_generate_key (const psa_key_attributes_t *attributes, const psa_key_production_parameters_t *params, size_t params_data_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length)
 Generate an RSA key. More...
 
psa_status_t mbedtls_psa_rsa_sign_hash (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
 Sign an already-calculated hash with an RSA private key. More...
 
psa_status_t mbedtls_psa_rsa_verify_hash (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)
 Verify the signature a hash or short message using a public RSA key. More...
 
psa_status_t mbedtls_psa_asymmetric_encrypt (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
 Encrypt a short message with a public key. More...
 
psa_status_t mbedtls_psa_asymmetric_decrypt (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
 Decrypt a short message with a private key. More...
 

Function Documentation

◆ mbedtls_psa_asymmetric_decrypt()

psa_status_t mbedtls_psa_asymmetric_decrypt ( const psa_key_attributes_t attributes,
const uint8_t key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg,
const uint8_t input,
size_t  input_length,
const uint8_t salt,
size_t  salt_length,
uint8_t output,
size_t  output_size,
size_t *  output_length 
)

Decrypt a short message with a private key.

Parameters
attributesThe attributes for the key to import.
key_bufferBuffer where the key data is to be written.
key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]inputThe message to decrypt.
input_lengthSize of the input buffer in bytes.
[in]saltA salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass NULL. If the algorithm supports an optional salt and you do not want to pass a salt, pass NULL.

◆ mbedtls_psa_asymmetric_encrypt()

psa_status_t mbedtls_psa_asymmetric_encrypt ( const psa_key_attributes_t attributes,
const uint8_t key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg,
const uint8_t input,
size_t  input_length,
const uint8_t salt,
size_t  salt_length,
uint8_t output,
size_t  output_size,
size_t *  output_length 
)

Encrypt a short message with a public key.

Parameters
attributesThe attributes for the key to import.
key_bufferBuffer where the key data is to be written.
key_buffer_sizeSize of the key_buffer buffer in bytes.
input_lengthSize of the input buffer in bytes.
[in]saltA salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass NULL. If the algorithm supports an optional salt and you do not want to pass a salt, pass NULL.

◆ mbedtls_psa_rsa_export_key()

psa_status_t mbedtls_psa_rsa_export_key ( psa_key_type_t  type,
mbedtls_rsa_context rsa,
uint8_t data,
size_t  data_size,
size_t *  data_length 
)

Export an RSA key to export representation.

Parameters
[in]typeThe type of key (public/private) to export
[in]rsaThe internal RSA representation from which to export
[out]dataThe buffer to export to
[in]data_sizeThe length of the buffer to export to
[out]data_lengthThe amount of bytes written to data

◆ mbedtls_psa_rsa_export_public_key()

psa_status_t mbedtls_psa_rsa_export_public_key ( const psa_key_attributes_t attributes,
const uint8_t key_buffer,
size_t  key_buffer_size,
uint8_t data,
size_t  data_size,
size_t *  data_length 
)

Export a public RSA key or the public part of an RSA key pair in binary format.

Note
The signature of this function is that of a PSA driver export_public_key entry point. This function behaves as an export_public_key entry point as defined in the PSA driver interface specification.
Parameters
[in]attributesThe attributes for the key to export.
[in]key_bufferMaterial or context of the key to export.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[out]dataBuffer where the key data is to be written.
[in]data_sizeSize of the data buffer in bytes.
[out]data_lengthOn success, the number of bytes written in data.
Return values
PSA_SUCCESSThe RSA public key was exported successfully.
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_COMMUNICATION_FAILURE\emptydescription
PSA_ERROR_HARDWARE_FAILURE\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription
PSA_ERROR_STORAGE_FAILURE\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription

◆ mbedtls_psa_rsa_generate_key()

psa_status_t mbedtls_psa_rsa_generate_key ( const psa_key_attributes_t attributes,
const psa_key_production_parameters_t params,
size_t  params_data_length,
uint8_t key_buffer,
size_t  key_buffer_size,
size_t *  key_buffer_length 
)

Generate an RSA key.

Note
The signature of the function is that of a PSA driver generate_key entry point.
Parameters
[in]attributesThe attributes for the RSA key to generate.
[in]paramsProduction parameters for the key generation. This function only uses `params->data`, which contains the public exponent. This can be a null pointer if params_data_length is 0.
params_data_lengthLength of `params->data` in bytes. This can be 0, in which case the public exponent will be 65537.
[out]key_bufferBuffer where the key data is to be written.
[in]key_buffer_sizeSize of key_buffer in bytes.
[out]key_buffer_lengthOn success, the number of bytes written in key_buffer.
Return values
PSA_SUCCESSThe key was successfully generated.
PSA_ERROR_NOT_SUPPORTEDKey length or type not supported.
PSA_ERROR_BUFFER_TOO_SMALLThe size of key_buffer is too small.

◆ mbedtls_psa_rsa_import_key()

psa_status_t mbedtls_psa_rsa_import_key ( const psa_key_attributes_t attributes,
const uint8_t data,
size_t  data_length,
uint8_t key_buffer,
size_t  key_buffer_size,
size_t *  key_buffer_length,
size_t *  bits 
)

Import an RSA key in binary format.

Note
The signature of this function is that of a PSA driver import_key entry point. This function behaves as an import_key entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in]attributesThe attributes for the key to import.
[in]dataThe buffer containing the key data in import format.
[in]data_lengthSize of the data buffer in bytes.
[out]key_bufferThe buffer containing the key data in output format.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes. This size is greater or equal to data_length.
[out]key_buffer_lengthThe length of the data written in key_buffer in bytes.
[out]bitsThe key size in number of bits.
Return values
PSA_SUCCESSThe RSA key was imported successfully.
PSA_ERROR_INVALID_ARGUMENTThe key data is not correctly formatted.
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_rsa_load_representation()

psa_status_t mbedtls_psa_rsa_load_representation ( psa_key_type_t  type,
const uint8_t data,
size_t  data_length,
mbedtls_rsa_context **  p_rsa 
)

Load the contents of a key buffer into an internal RSA representation.

Parameters
[in]typeThe type of key contained in data.
[in]dataThe buffer from which to load the representation.
[in]data_lengthThe size in bytes of data.
[out]p_rsaReturns a pointer to an RSA context on success. The caller is responsible for freeing both the contents of the context and the context itself when done.

◆ mbedtls_psa_rsa_sign_hash()

psa_status_t mbedtls_psa_rsa_sign_hash ( const psa_key_attributes_t attributes,
const uint8_t key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg,
const uint8_t hash,
size_t  hash_length,
uint8_t signature,
size_t  signature_size,
size_t *  signature_length 
)

Sign an already-calculated hash with an RSA private key.

Note
The signature of this function is that of a PSA driver sign_hash entry point. This function behaves as a sign_hash entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in]attributesThe attributes of the RSA key to use for the operation.
[in]key_bufferThe buffer containing the RSA key context. format.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]algA signature algorithm that is compatible with an RSA key.
[in]hashThe hash or message to sign.
[in]hash_lengthSize of the hash buffer in bytes.
[out]signatureBuffer where the signature is to be written.
[in]signature_sizeSize of the signature buffer in bytes.
[out]signature_lengthOn success, the number of bytes that make up the returned signature value.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_BUFFER_TOO_SMALLThe size of the signature buffer is too small. You can determine a sufficient buffer size by calling PSA_SIGN_OUTPUT_SIZE(PSA_KEY_TYPE_RSA_KEY_PAIR, key_bits, alg) where key_bits is the bit-size of the RSA key.
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INVALID_ARGUMENT\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription
PSA_ERROR_INSUFFICIENT_ENTROPY\emptydescription

◆ mbedtls_psa_rsa_verify_hash()

psa_status_t mbedtls_psa_rsa_verify_hash ( const psa_key_attributes_t attributes,
const uint8_t key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg,
const uint8_t hash,
size_t  hash_length,
const uint8_t signature,
size_t  signature_length 
)

Verify the signature a hash or short message using a public RSA key.

Note
The signature of this function is that of a PSA driver verify_hash entry point. This function behaves as a verify_hash entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in]attributesThe attributes of the RSA key to use for the operation.
[in]key_bufferThe buffer containing the RSA key context. format.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]algA signature algorithm that is compatible with an RSA key.
[in]hashThe hash or message whose signature is to be verified.
[in]hash_lengthSize of the hash buffer in bytes.
[in]signatureBuffer containing the signature to verify.
[in]signature_lengthSize of the signature buffer in bytes.
Return values
PSA_SUCCESSThe signature is valid.
PSA_ERROR_INVALID_SIGNATUREThe calculation was performed successfully, but the passed signature is not a valid signature.
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INVALID_ARGUMENT\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
Modified on Tue Jul 23 17:47:45 2024 by modify_doxy.py rev. 669887