Security module implementation file. More...
#include "mcl_core/mcl_assert.h"
#include "mcl_core/mcl_memory.h"
#include "mbedtls/sha256.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
Go to the source code of this file.
Macros | |
#define | SHA256_DIGEST_LENGTH 32 |
#define | KEY_LENGTH_BITS 3072 |
Functions | |
mcl_error_t | security_initialize (void) |
mcl_error_t | security_hash_sha256 (const mcl_uint8_t *data, mcl_size_t data_size, mcl_uint8_t **hash, mcl_size_t *hash_size) |
mcl_error_t | security_rsa_sign (char *rsa_key, char *data, mcl_size_t data_size, mcl_uint8_t **signature, mcl_size_t *signature_size) |
mcl_error_t | security_generate_rsa_key (char **public_key, char **private_key) |
mcl_error_t | security_rsa_get_modulus_and_exponent (char *public_key, char **modulus, char **exponent) |
mcl_error_t | security_generate_random_bytes (unsigned char *buffer, mcl_size_t size) |
Variables | |
static mbedtls_entropy_context | entropy |
static mbedtls_ctr_drbg_context | ctr_drbg |
static mcl_bool_t | is_initialized = MCL_FALSE |
Security module implementation file.
Definition in file security_mbedtls.c.
#define KEY_LENGTH_BITS 3072 |
Definition at line 17 of file security_mbedtls.c.
#define SHA256_DIGEST_LENGTH 32 |
Definition at line 15 of file security_mbedtls.c.
Referenced by security_hash_sha256().
mcl_error_t security_generate_random_bytes | ( | unsigned char * | buffer, |
mcl_size_t | size | ||
) |
This function is used to generate random bytes.
[out] | buffer | Buffer which will be filled with random bytes. |
[in] | size | Size of the buffer. |
Definition at line 88 of file security_mbedtls.c.
Referenced by _generate_correlation_id_string(), mcl_random_generate_bytes(), random_generate_guid(), and random_generate_number().
mcl_error_t security_generate_rsa_key | ( | char ** | public_key, |
char ** | private_key | ||
) |
This function is used to generate the RSA public/private keys.
Generated keys will be returned as out parameters.
[out] | public_key | Generated public key. New memory space will be allocated for this parameter. |
[out] | private_key | Generated private key. New memory space will be allocated for this parameter. |
Definition at line 78 of file security_mbedtls.c.
Referenced by security_handler_generate_rsa_key().
mcl_error_t security_hash_sha256 | ( | const mcl_uint8_t * | data, |
mcl_size_t | data_size, | ||
mcl_uint8_t ** | hash, | ||
mcl_size_t * | hash_size | ||
) |
This function is used to generate the sha256 hash of the given data.
Definition at line 45 of file security_mbedtls.c.
Referenced by hmac_sha256(), and security_handler_hash_sha256().
mcl_error_t security_initialize | ( | void | ) |
This function is used to initialize security implementation.
Definition at line 27 of file security_mbedtls.c.
Referenced by core_processor_initialize().
mcl_error_t security_rsa_get_modulus_and_exponent | ( | char * | public_key, |
char ** | modulus, | ||
char ** | exponent | ||
) |
This function is used to get the modulus (n) and public exponent (e) parameters of RSA key in base64 format.
public_key | Public key in PEM format. |
modulus | Base64 encoded modulus of RSA key. |
exponent | Base64 encoded public exponent of RSA key. |
Definition at line 83 of file security_mbedtls.c.
Referenced by _add_jwks().
mcl_error_t security_rsa_sign | ( | char * | rsa_key, |
char * | data, | ||
mcl_size_t | data_size, | ||
mcl_uint8_t ** | signature, | ||
mcl_size_t * | signature_size | ||
) |
This function is used to sign data with RSA key.
Received key will be used to sign.
[in] | rsa_key | Private key to be used in signing. |
[in] | data | The data to be signed. |
[in] | data_size | Size of the data. |
[out] | signature | Generated signature. |
[out] | signature_size | Size of signature. |
Definition at line 73 of file security_mbedtls.c.
Referenced by security_handler_rsa_sign().
|
static |
Definition at line 20 of file security_mbedtls.c.
Referenced by security_generate_random_bytes(), and security_initialize().
|
static |
Definition at line 19 of file security_mbedtls.c.
Referenced by security_initialize().
|
static |
Definition at line 21 of file security_mbedtls.c.
Referenced by security_generate_random_bytes(), and security_initialize().