security.h File Reference

Security module header file.

More...

#include "mcl/mcl_common.h"
Include dependency graph for security.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void security_initialize (void)
 
E_MCL_ERROR_CODE security_hash_sha256 (const mcl_uint8_t *data, mcl_size_t data_size, mcl_uint8_t **hash, mcl_size_t *hash_size)
 
E_MCL_ERROR_CODE security_rsa_sign (char *rsa_key, char *data, mcl_size_t data_size, mcl_uint8_t **signature, mcl_size_t *signature_size)
 To be used to sign data with RSA key. More...
 
E_MCL_ERROR_CODE security_generate_rsa_key (char **public_key, char **private_key)
 To be used to generate the RSA public/private keys. More...
 
E_MCL_ERROR_CODE security_rsa_get_modulus_and_exponent (char *public_key, char **modulus, char **exponent)
 To be used to get the modulus (n) and public exponent (e) parameters of RSA key in Base64 format. More...
 
E_MCL_ERROR_CODE security_generate_random_bytes (unsigned char *buffer, mcl_size_t size)
 To be used to generate random bytes. More...
 

Detailed Description

Security module header file.

  • Inner security interface. Contains security related functions like hashing, public/private key generation. Implementation file might change depending on the platform and will be in security_XXX.c format.

Date
Jun 27, 2016

Definition in file security.h.

Function Documentation

E_MCL_ERROR_CODE security_generate_random_bytes ( unsigned char *  buffer,
mcl_size_t  size 
)

To be used to generate random bytes.

Parameters
[out]bufferBuffer which will be filled with random bytes.
[in]sizeSize of the buffer.
Returns
  • MCL_OK in case of success.
  • MCL_FAIL in case of an internal error in MCL.

Definition at line 214 of file security_libcrypto.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_FAIL, and MCL_OK.

Referenced by _generate_correlation_id_string(), random_generate_array(), random_generate_guid(), and random_generate_number().

Here is the caller graph for this function:

E_MCL_ERROR_CODE security_generate_rsa_key ( char **  public_key,
char **  private_key 
)

To be used to generate the RSA public/private keys.

Generated keys will be returned as out parameters.

Parameters
[out]public_keyGenerated public key. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space.
[out]private_keyGenerated private key. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space.
Returns

Definition at line 137 of file security_libcrypto.c.

References _get_rsa_private_key(), _get_rsa_public_key(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, KEY_LENGTH_BITS, MCL_FAIL, MCL_FREE, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.

Referenced by security_handler_generate_rsa_key().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE security_hash_sha256 ( const mcl_uint8_t data,
mcl_size_t  data_size,
mcl_uint8_t **  hash,
mcl_size_t hash_size 
)
See also
security_handler_hash_sha256

Definition at line 78 of file security_libcrypto.c.

References ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_CALLOC, MCL_DEBUG, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.

Referenced by hmac_sha256(), security_handler_hash_sha256(), and security_rsa_sign().

Here is the caller graph for this function:

void security_initialize ( void  )

Initializes security module. This function is used e.g. to set memory callback functions.

Definition at line 69 of file security_libcrypto.c.

References _libcrypto_free(), _libcrypto_malloc(), _libcrypto_realloc(), DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by http_processor_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE security_rsa_get_modulus_and_exponent ( char *  public_key,
char **  modulus,
char **  exponent 
)

To be used to get the modulus (n) and public exponent (e) parameters of RSA key in Base64 format.

Parameters
public_keyPublic key in PEM format.
modulusBase64 encoded modulus of RSA key.
exponentBase64 encoded public exponent of RSA key.
Returns

Definition at line 180 of file security_libcrypto.c.

References _base64_encode_big_number(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_FAIL, MCL_FREE, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, and string_util_strlen().

Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE security_rsa_sign ( char *  rsa_key,
char *  data,
mcl_size_t  data_size,
mcl_uint8_t **  signature,
mcl_size_t signature_size 
)

To be used to sign data with RSA key.

Received key will be used to sign.

Parameters
[in]rsa_keyPrivate key to be used in signing.
[in]dataThe data to be signed.
[in]data_sizeSize of the data.
[out]signatureGenerated signature.
[out]signature_sizeSize of signature.
Returns

Definition at line 99 of file security_libcrypto.c.

References ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_FAIL, MCL_FALSE, MCL_FREE, MCL_MALLOC, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, security_hash_sha256(), and string_util_strlen().

Referenced by security_handler_rsa_sign().

Here is the call graph for this function:

Here is the caller graph for this function: