|
BSL v1.1.1 - 50.g42e5d9b
AMMOS Bundle Protocol Security Library (BSL)
|
Backend cryptography implementation. More...
#include "CryptoInterface.h"#include "bsl/BPSecLib_Private.h"#include "bsl/front/TextUtil.h"#include "bsl/dynamic/Variant.h"#include <openssl/core_names.h>#include <openssl/err.h>#include <openssl/evp.h>#include <openssl/kdf.h>#include <openssl/rand.h>
Include dependency graph for CryptoInterface.c:Macros | |
| #define | BSL_Crypto_PtrOrZero(ptr) (ptr) ? (ptr) : (void *)&BSL_Crypto_zero |
Functions | |
| void | BSL_Crypto_SetRngGenerator (BSL_Crypto_RandBytesFn rand_gen_fn) |
| Set RNG generator to be used by crypto library. | |
| int | BSL_Crypto_UnwrapKey (BSL_Crypto_KeyHandle_t kek_handle, const BSL_Data_t *wrapped_key, BSL_Crypto_KeyHandle_t *cek_handle) |
| Perform key unwrap. | |
| int | BSL_Crypto_WrapKey (BSL_Crypto_KeyHandle_t kek_handle, BSL_Crypto_KeyHandle_t cek_handle, BSL_Data_t *wrapped_key) |
| Perform key wrap. | |
| int | BSL_Crypto_KDF (BSL_Crypto_KeyHandle_t kdk_handle, BSL_Crypto_KDFVariant_t func, const BSL_Data_t *salt, const BSL_Data_t *info, size_t keylen, BSL_Crypto_KeyHandle_t *cek_handle) |
| Perform key derivation. | |
| int | BSL_AuthCtx_Init (BSL_AuthCtx_t *hmac_ctx, BSL_Crypto_KeyHandle_t keyhandle, BSL_Crypto_SHAVariant_e sha_var) |
| Initialize HMAC context resources and set private key and SHA variant. | |
| int | BSL_AuthCtx_DigestBuffer (BSL_AuthCtx_t *hmac_ctx, const void *data, size_t data_len) |
| Input data to HMAC sign to context. | |
| int | BSL_AuthCtx_DigestSeq (BSL_AuthCtx_t *hmac_ctx, BSL_SeqReader_t *reader) |
| Input data to HMAC sign to context. | |
| int | BSL_AuthCtx_Finalize (BSL_AuthCtx_t *hmac_ctx, BSL_Data_t *tag) |
| Finalize HMAC tag. | |
| void | BSL_AuthCtx_Deinit (BSL_AuthCtx_t *hmac_ctx) |
| Deinitialize HMAC context resources. | |
| bool | BSL_Crypto_Compare (const void *data1, size_t size1, const void *data2, size_t size2) |
| Compare two blocks of data in a time-invariant way. | |
| int | BSL_Cipher_Init (BSL_Cipher_t *cipher_ctx, BSL_CipherMode_e enc, BSL_Crypto_AESVariant_e aes_var, const BSL_Data_t *iv_val, BSL_Crypto_KeyHandle_t keyhandle) |
| Initialize crypto context resources and set as encoding or decoding. | |
| int | BSL_Cipher_AddAadBuffer (BSL_Cipher_t *cipher_ctx, const void *aad, size_t aad_len) |
| Add additional authenticated data (AAD) to cipher context. | |
| int | BSL_Cipher_AddAadSeq (BSL_Cipher_t *cipher_ctx, BSL_SeqReader_t *reader) |
| Add AAD from sequential reader. | |
| int | BSL_Cipher_AddSeq (BSL_Cipher_t *cipher_ctx, BSL_SeqReader_t *reader, BSL_SeqWriter_t *writer, size_t limit) |
| Add data to encrypt or decrypt to the context sequentially. | |
| size_t | BSL_Cipher_TagLen (const BSL_Cipher_t *cipher_ctx) |
| Determine the size of the authentication tag. | |
| int | BSL_Cipher_GetTag (BSL_Cipher_t *cipher_ctx, BSL_Data_t *tag) |
| Get the tag of the crypto operation. | |
| int | BSL_Cipher_SetTag (BSL_Cipher_t *cipher_ctx, const BSL_Data_t *tag) |
| Set the tag of the crypto operation. | |
| int | BSL_Cipher_FinalizeSeq (BSL_Cipher_t *cipher_ctx, BSL_SeqWriter_t *writer) |
| Finalize crypto operation. | |
| void | BSL_Cipher_Deinit (BSL_Cipher_t *cipher_ctx) |
| De-initialize crypto context resources. | |
| int | BSL_Crypto_GenIV (BSL_Data_t *buf) |
| Generate random bytes. | |
Variables | |
| BSL_KeyStore_Descriptors_t | BSL_KeyStore_State |
| Initialized to library default. | |
| static BSL_Crypto_RandBytesFn | rand_bytes_generator = RAND_bytes |
| Random bytes generator. | |
| static const uint8_t | BSL_Crypto_zero = 0 |
Backend cryptography implementation.
| #define BSL_Crypto_PtrOrZero | ( | ptr | ) | (ptr) ? (ptr) : (void *)&BSL_Crypto_zero |
| void BSL_AuthCtx_Deinit | ( | BSL_AuthCtx_t * | hmac_ctx | ) |
Deinitialize HMAC context resources.
| [in,out] | hmac_ctx | pointer to hmac context struct to add data to |
References ASSERT_ARG_NONNULL, BSL_Data_Deinit(), BSL_KeyStore_State, BSL_AuthCtx_t::in_buf, BSL_AuthCtx_t::keyhandle, BSL_AuthCtx_t::libhandle, and BSL_KeyStore_Descriptors_t::release_key.
Referenced by BSLX_BIB_GenHMAC(), and BSLX_CoseSc_Deinit().
| int BSL_AuthCtx_DigestBuffer | ( | BSL_AuthCtx_t * | hmac_ctx, |
| const void * | data, | ||
| size_t | data_len | ||
| ) |
Input data to HMAC sign to context.
| [in,out] | hmac_ctx | pointer to hmac context struct to add data to |
| [in] | data | buffer containing data to sign |
| data_len | length of incoming data buffer, which is internally limited to INT_MAX |
References ASSERT_ARG_NONNULL, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, CHK_PRECONDITION, CHK_PROPERTY, BSL_AuthCtx_t::keyhandle, BSL_AuthCtx_t::libhandle, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BIB_GenHMAC(), BSLX_CoseSc_Mac_Compute(), and switch().
| int BSL_AuthCtx_DigestSeq | ( | BSL_AuthCtx_t * | hmac_ctx, |
| BSL_SeqReader_t * | reader | ||
| ) |
Input data to HMAC sign to context.
| [in,out] | hmac_ctx | pointer to hmac context struct to add data to |
| [in] | reader | sequential reader over data to sign |
References ASSERT_ARG_NONNULL, BSL_AuthCtx_t::block_size, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, BSL_SeqReader_Get(), CHK_PROPERTY, BSL_AuthCtx_t::in_buf, BSL_AuthCtx_t::keyhandle, BSL_AuthCtx_t::libhandle, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_CoseSc_Mac_Compute(), and switch().
| int BSL_AuthCtx_Finalize | ( | BSL_AuthCtx_t * | hmac_ctx, |
| BSL_Data_t * | tag | ||
| ) |
Finalize HMAC tag.
| [in,out] | hmac_ctx | pointer to hmac context struct to add data to |
| [out] | tag | The HMAC output buffer to resize and populate. |
References ASSERT_ARG_NONNULL, BSL_Data_Resize(), BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, CHK_PROPERTY, BSL_Data_t::len, BSL_AuthCtx_t::libhandle, BSL_Data_t::ptr, and tag.
Referenced by BSLX_BIB_GenHMAC(), and BSLX_CoseSc_Mac_Compute().
| int BSL_AuthCtx_Init | ( | BSL_AuthCtx_t * | hmac_ctx, |
| BSL_Crypto_KeyHandle_t | keyhandle, | ||
| BSL_Crypto_SHAVariant_e | sha_var | ||
| ) |
Initialize HMAC context resources and set private key and SHA variant.
| [in,out] | hmac_ctx | pointer to hmac context struct to init and set |
| [in] | keyhandle | handle for key to use. The HMAC context keeps its own reference to this handle. |
| [in] | sha_var | SHA variant, see RFC9173 [2] |
References BSL_KeyStore_Descriptors_t::acquire_key, BSL_AuthCtx_t::block_size, BSL_CRYPTO_SHA_256, BSL_CRYPTO_SHA_384, BSL_CRYPTO_SHA_512, BSL_Data_InitBuffer(), BSL_ERR_SECURITY_CONTEXT_CRYPTO_FAILED, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, CHK_ARG_NONNULL, CHK_PRECONDITION, CHK_PROPERTY, BSL_KeyStore_Descriptors_t::get_keymat, BSL_AuthCtx_t::in_buf, BSL_AuthCtx_t::keyhandle, keyhandle, BSL_Data_t::len, BSL_AuthCtx_t::libhandle, BSL_Data_t::ptr, sha_var, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BIB_GenHMAC(), and BSLX_CoseSc_Mac_Compute().
| int BSL_Cipher_AddAadBuffer | ( | BSL_Cipher_t * | cipher_ctx, |
| const void * | aad, | ||
| size_t | aad_len | ||
| ) |
Add additional authenticated data (AAD) to cipher context.
| cipher_ctx | pointer to context to add AAD to |
| aad | pointer to AAD |
| aad_len | length of AAD, which is internally limited to INT_MAX. |
References ASSERT_ARG_NONNULL, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, CHK_PRECONDITION, CHK_PROPERTY, BSL_Cipher_t::keyhandle, BSL_Cipher_t::libhandle, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BCB_Decrypt(), BSLX_BCB_Encrypt(), BSLX_CoseSc_Encrypt_Compute(), test_decrypt(), and test_encrypt().
| int BSL_Cipher_AddAadSeq | ( | BSL_Cipher_t * | cipher_ctx, |
| BSL_SeqReader_t * | reader | ||
| ) |
Add AAD from sequential reader.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References ASSERT_ARG_NONNULL, BSL_Cipher_t::block_size, BSL_KeyStore_State, BSL_LOG_PLAINTEXT_PTR, BSL_SeqReader_Get(), CHK_PROPERTY, BSL_Cipher_t::in_buf, BSL_Cipher_t::keyhandle, BSL_Cipher_t::libhandle, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_CoseSc_Encrypt_Compute().
| int BSL_Cipher_AddSeq | ( | BSL_Cipher_t * | cipher_ctx, |
| BSL_SeqReader_t * | reader, | ||
| BSL_SeqWriter_t * | writer, | ||
| size_t | limit | ||
| ) |
Add data to encrypt or decrypt to the context sequentially.
| cipher_ctx | pointer to context to add data to | |
| [in] | reader | pointer to sequential reader - input to crypto operation |
| [in] | writer | pointer to sequential writer (output of crypto operation), or NULL (crypto output will not be written) |
| limit | The number of bytes of the reader to read and process. This can be shorter than the full length if the ciphertext contains an authentication tag. |
References ASSERT_ARG_NONNULL, BSL_Cipher_t::block_size, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, BSL_SeqReader_Get(), BSL_SeqWriter_Put(), BSL_SUCCESS, CHK_PROPERTY, BSL_Cipher_t::in_buf, BSL_Cipher_t::keyhandle, BSL_Cipher_t::libhandle, BSL_Cipher_t::out_buf, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BCB_Decrypt(), BSLX_BCB_Encrypt(), BSLX_CoseSc_Encrypt_Compute(), test_decrypt(), and test_encrypt().
| void BSL_Cipher_Deinit | ( | BSL_Cipher_t * | cipher_ctx | ) |
De-initialize crypto context resources.
| cipher_ctx | pointer to context to deinitialize |
References ASSERT_ARG_NONNULL, BSL_Data_Deinit(), BSL_KeyStore_State, BSL_Cipher_t::in_buf, BSL_Cipher_t::keyhandle, BSL_Cipher_t::libhandle, BSL_Cipher_t::out_buf, and BSL_KeyStore_Descriptors_t::release_key.
Referenced by BSLX_BCB_Decrypt(), BSLX_BCB_Encrypt(), BSLX_CoseSc_Deinit(), test_decrypt(), and test_encrypt().
| int BSL_Cipher_FinalizeSeq | ( | BSL_Cipher_t * | cipher_ctx, |
| BSL_SeqWriter_t * | writer | ||
| ) |
Finalize crypto operation.
Finalize may or may not add data to writer depending on implementation.
| cipher_ctx | pointer to context to finalize | |
| [out] | writer | additional written data |
References BSL_Cipher_t::block_size, BSL_ERR_FAILURE, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_SeqWriter_Put(), BSL_SUCCESS, CHK_ARG_NONNULL, BSL_Cipher_t::libhandle, BSL_Cipher_t::out_buf, and BSL_Data_t::ptr.
Referenced by BSLX_BCB_Decrypt(), BSLX_BCB_Encrypt(), BSLX_CoseSc_Encrypt_Compute(), test_decrypt(), and test_encrypt().
| int BSL_Cipher_GetTag | ( | BSL_Cipher_t * | cipher_ctx, |
| BSL_Data_t * | tag | ||
| ) |
Get the tag of the crypto operation.
| cipher_ctx | pointer to context to get tag from | |
| [out] | tag | will be resized and contain data upon successful function completion |
References ASSERT_ARG_NONNULL, BSL_Data_Resize(), BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, CHK_PROPERTY, BSL_Data_t::len, BSL_Cipher_t::libhandle, BSL_Data_t::ptr, and tag.
Referenced by BSLX_BCB_Encrypt(), BSLX_CoseSc_Encrypt_Compute(), and test_encrypt().
| int BSL_Cipher_Init | ( | BSL_Cipher_t * | cipher_ctx, |
| BSL_CipherMode_e | enc, | ||
| BSL_Crypto_AESVariant_e | aes_var, | ||
| const BSL_Data_t * | iv_val, | ||
| BSL_Crypto_KeyHandle_t | key_handle | ||
| ) |
Initialize crypto context resources and set as encoding or decoding.
| [out] | cipher_ctx | pointer to context to initialize |
| aes_var | AES GCM variant to use | |
| enc | enum for BSL_CRYPTO_ENCRYPT or BSL_CRYPTO_DECRYPT | |
| [in] | iv_val | The initialization vector (IV) data, which must be non-empty. The length is internally limited to INT_MAX |
| [in] | key_handle | key handle to use. The cipher context keeps its own reference to this handle. |
References BSL_KeyStore_Descriptors_t::acquire_key, BSL_Cipher_t::AES_variant, ASSERT_ARG_NONNULL, BSL_Cipher_t::block_size, BSL_CRYPTO_AES_128, BSL_CRYPTO_AES_192, BSL_CRYPTO_AES_256, BSL_CRYPTO_ENCRYPT, BSL_Data_InitBuffer(), BSL_ERR_FAILURE, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, CHK_PRECONDITION, CHK_PROPERTY, BSL_Cipher_t::enc, BSL_KeyStore_Descriptors_t::get_keymat, BSL_Cipher_t::in_buf, BSL_Cipher_t::keyhandle, keyhandle, BSL_Data_t::len, BSL_Cipher_t::libhandle, BSL_Cipher_t::out_buf, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BCB_Decrypt(), BSLX_BCB_Encrypt(), BSLX_CoseSc_Encrypt_Compute(), test_decrypt(), and test_encrypt().
| int BSL_Cipher_SetTag | ( | BSL_Cipher_t * | cipher_ctx, |
| const BSL_Data_t * | tag | ||
| ) |
Set the tag of the crypto operation.
| cipher_ctx | pointer to context to set tag of | |
| [in] | tag | pointer to tag to read from. |
References ASSERT_ARG_NONNULL, BSL_LOG_DEBUG, BSL_LOG_PLAINTEXT_PTR, CHK_PROPERTY, BSL_Data_t::len, BSL_Cipher_t::libhandle, BSL_Data_t::ptr, and tag.
Referenced by BSLX_BCB_Decrypt(), BSLX_CoseSc_Encrypt_Compute(), and test_decrypt().
| size_t BSL_Cipher_TagLen | ( | const BSL_Cipher_t * | cipher_ctx | ) |
Determine the size of the authentication tag.
This will be the output of BSL_Cipher_GetTag() and the input of BSL_Cipher_SetTag().
References ASSERT_ARG_NONNULL, and BSL_Cipher_t::libhandle.
Referenced by BSLX_CoseSc_Encrypt_Compute().
| bool BSL_Crypto_Compare | ( | const void * | data1, |
| size_t | size1, | ||
| const void * | data2, | ||
| size_t | size2 | ||
| ) |
Compare two blocks of data in a time-invariant way.
This avoids side channel attacks which depend on comparison time.
| [in] | data1 | The first pointer. |
| size1 | The size of data1 block. | |
| [in] | data2 | The second pointer. |
| size2 | The size of data2 block. |
Referenced by BSL_Crypto_CompareKeys(), BSLX_BIB_Execute(), BSLX_CoseSc_Mac0_VerifyAccept(), and BSLX_CoseSc_Mac_VerifyAccept().
| int BSL_Crypto_GenIV | ( | BSL_Data_t * | buf | ) |
Generate random bytes.
This can be used for cipher initialization vector (IV) or KDF salt.
| [in,out] | buf | to write data into without changing its size. The size in bytes needed is determined by the calling context. |
References ASSERT_PRECONDITION, BSL_SUCCESS, CHK_ARG_NONNULL, CHK_PROPERTY, BSL_Data_t::len, BSL_Data_t::ptr, and rand_bytes_generator.
Referenced by BSL_Crypto_GenKey(), BSLX_BCB_Encrypt(), BSLX_CoseSc_GenerateNonce(), test_crypto_generate_iv(), test_decrypt(), and test_encrypt().
| int BSL_Crypto_KDF | ( | BSL_Crypto_KeyHandle_t | kdk_handle, |
| BSL_Crypto_KDFVariant_t | func, | ||
| const BSL_Data_t * | salt, | ||
| const BSL_Data_t * | info, | ||
| size_t | keylen, | ||
| BSL_Crypto_KeyHandle_t * | cek_handle | ||
| ) |
Perform key derivation.
| [in] | kdk_handle | The derivation key handle. |
| func | The derivation function variation. | |
| [in] | salt | The extract step salt. |
| [in] | info | The expand step context data. |
| keylen | The expand step length. | |
| [in,out] | cek_handle | output content encryption key handle. |
References BSL_CRYPTO_KDF_HKDF_SHA_256, BSL_CRYPTO_KDF_HKDF_SHA_512, BSL_Crypto_LoadKey(), BSL_Crypto_PtrOrZero, BSL_Data_Deinit(), BSL_Data_InitBuffer(), BSL_ERR_SECURITY_CONTEXT_CRYPTO_FAILED, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, CHK_ARG_NONNULL, CHK_PRECONDITION, BSL_KeyStore_Descriptors_t::get_keymat, BSL_Data_t::len, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_CoseSc_HkdfContentKey(), and TEST_CASE().
| void BSL_Crypto_SetRngGenerator | ( | BSL_Crypto_RandBytesFn | rand_gen_fn | ) |
Set RNG generator to be used by crypto library.
| [in] | rand_gen_fn | random bytes generation function. |
References rand_bytes_generator.
Referenced by main(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), test_RFC9173_AppendixA_Example1_BIB_Source(), test_RFC9173_AppendixA_Example2_BCB_Source(), test_RFC9173_AppendixA_Example3_Acceptor(), test_RFC9173_AppendixA_Example4_Acceptor(), test_RFC9173_AppendixA_Example4_Source(), test_sec_accept_keyunwrap(), and test_sec_source_keywrap().
| int BSL_Crypto_UnwrapKey | ( | BSL_Crypto_KeyHandle_t | kek_handle, |
| const BSL_Data_t * | wrapped_key, | ||
| BSL_Crypto_KeyHandle_t * | cek_handle | ||
| ) |
Perform key unwrap.
CEK size expected to match size of KEK.
| [in] | kek_handle | key encryption key handle (decryption key) |
| [in] | wrapped_key | input wrapped key (ciphertext) bytes |
| [in,out] | cek_handle | output content encryption key (plaintext) handle. |
References ASSERT_ARG_NONNULL, BSL_Crypto_LoadKey(), BSL_Data_Deinit(), BSL_Data_InitBuffer(), BSL_ERR_SECURITY_CONTEXT_CRYPTO_FAILED, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, CHK_PRECONDITION, BSL_KeyStore_Descriptors_t::get_keymat, BSL_Data_t::len, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BCB_Decrypt(), BSLX_BIB_GenHMAC(), and BSLX_CoseSc_ExtractContentKey().
| int BSL_Crypto_WrapKey | ( | BSL_Crypto_KeyHandle_t | kek_handle, |
| BSL_Crypto_KeyHandle_t | cek_handle, | ||
| BSL_Data_t * | wrapped_key | ||
| ) |
Perform key wrap.
KEK and CEK sizes must match.
| [in] | kek_handle | key encryption key handle (encryption key) |
| [in] | cek_handle | content encryption key handle (encryption data) |
| [in,out] | wrapped_key | output wrapped key (ciphertext) bytes |
References BSL_Data_Resize(), BSL_ERR_SECURITY_CONTEXT_CRYPTO_FAILED, BSL_KeyStore_State, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, CHK_ARG_NONNULL, CHK_PRECONDITION, BSL_KeyStore_Descriptors_t::get_keymat, BSL_Data_t::len, BSL_Data_t::ptr, and BSL_KeyStore_Descriptors_t::update_stats.
Referenced by BSLX_BCB_Encrypt(), BSLX_BIB_GenHMAC(), BSLX_CoseSc_GenerateContentKey(), and TEST_CASE().
|
static |
|
extern |
Initialized to library default.
Referenced by BSL_AuthCtx_Deinit(), BSL_AuthCtx_DigestBuffer(), BSL_AuthCtx_DigestSeq(), BSL_AuthCtx_Init(), BSL_Cipher_AddAadBuffer(), BSL_Cipher_AddAadSeq(), BSL_Cipher_AddSeq(), BSL_Cipher_Deinit(), BSL_Cipher_Init(), BSL_Crypto_KDF(), BSL_Crypto_UnwrapKey(), and BSL_Crypto_WrapKey().
|
static |
Random bytes generator.
Referenced by BSL_Crypto_GenIV(), and BSL_Crypto_SetRngGenerator().