*
* @remarks The @a ctx should be released using yaca_context_destroy()
*
+ * @remarks The @a pub_key must be #YACA_KEY_TYPE_RSA_PUB
+ *
* @remarks The @a sym_key should be released using yaca_key_destroy()
*
* @remarks The @a iv should be released using yaca_key_destroy()
*
* @remarks The @a ctx should be released using yaca_context_destroy()
*
+ * @remarks The @a prv_key must be #YACA_KEY_TYPE_RSA_PRIV
+ *
* @param[out] ctx Newly created context
* @param[in] prv_key Private key, part of the pair that was used for the encryption
* @param[in] algo Symmetric algorithm that was used for the encryption
const yaca_key_h pub_key,
yaca_encrypt_algorithm_e algo,
yaca_block_cipher_mode_e bcm,
- size_t bit_len,
- yaca_key_h *enc_sym_key,
+ size_t sym_key_bit_len,
+ yaca_key_h *sym_key,
yaca_key_h *iv)
{
int ret;
yaca_key_h lenc_sym_key = YACA_KEY_NULL;
if (pub_key == YACA_KEY_NULL || pub_key->type != YACA_KEY_TYPE_RSA_PUB ||
- enc_sym_key == NULL || bcm == YACA_BCM_WRAP)
+ sym_key == NULL || bcm == YACA_BCM_WRAP || sym_key_bit_len % 8 != 0)
return YACA_ERROR_INVALID_PARAMETER;
- ret = encrypt_get_algorithm(algo, bcm, bit_len, &cipher);
+ ret = encrypt_get_algorithm(algo, bcm, sym_key_bit_len, &cipher);
if (ret != YACA_ERROR_NONE)
goto exit;
if (ret != YACA_ERROR_NONE)
goto exit;
- *enc_sym_key = lenc_sym_key;
+ *sym_key = lenc_sym_key;
lenc_sym_key = YACA_KEY_NULL;
*iv = liv;
liv = YACA_KEY_NULL;
const yaca_key_h prv_key,
yaca_encrypt_algorithm_e algo,
yaca_block_cipher_mode_e bcm,
- size_t bit_len,
- const yaca_key_h enc_sym_key,
+ size_t sym_key_bit_len,
+ const yaca_key_h sym_key,
const yaca_key_h iv)
{
int ret;
yaca_key_h lsym_key = YACA_KEY_NULL;
if (prv_key == YACA_KEY_NULL || prv_key->type != YACA_KEY_TYPE_RSA_PRIV ||
- enc_sym_key == YACA_KEY_NULL || bcm == YACA_BCM_WRAP)
+ sym_key == YACA_KEY_NULL || bcm == YACA_BCM_WRAP || sym_key_bit_len % 8 != 0)
return YACA_ERROR_INVALID_PARAMETER;
- ret = encrypt_get_algorithm(algo, bcm, bit_len, &cipher);
+ ret = encrypt_get_algorithm(algo, bcm, sym_key_bit_len, &cipher);
if (ret != YACA_ERROR_NONE)
goto exit;
/* using private key will make it decrypt the symmetric key */
- ret = seal_encrypt_decrypt_key(prv_key, enc_sym_key, &lsym_key);
+ ret = seal_encrypt_decrypt_key(prv_key, sym_key, &lsym_key);
if (ret != YACA_ERROR_NONE)
goto exit;