Move code to encrypt* as it's encryption related.
Change-Id: Id9b5072e3fb220aaffcc0f1aad5f2b0893fa06ed
Signed-off-by: Mateusz Kulikowski <m.kulikowski@samsung.com>
*/
#define yaca_get_block_length(ctxa) yaca_get_output_length((ctxa), 0)
-/**
- * @brief yaca_get_iv_bits Returns the recomended/default length of the IV for a given encryption configuration.
- *
- * @param[in] algo Encryption algorithm.
- * @param[in] bcm Chain mode.
- * @param[in] key_bits Key length in bits (@see crypto_key_len_e).
- *
- * @return negative on error (@see error.h) or the IV length in bits.
- */
-int yaca_get_iv_bits(yaca_enc_algo_e algo,
- yaca_block_cipher_mode_e bcm,
- size_t key_bits);
-
/**@}*/
#ifdef __cplusplus
char *plain,
size_t *plain_len);
+/**
+ * @brief yaca_get_iv_bits Returns the recomended/default length of the IV for a given encryption configuration.
+ *
+ * @param[in] algo Encryption algorithm.
+ * @param[in] bcm Chain mode.
+ * @param[in] key_bits Key length in bits (@see crypto_key_len_e).
+ *
+ * @return negative on error (@see error.h) or the IV length in bits.
+ */
+int yaca_get_iv_bits(yaca_enc_algo_e algo,
+ yaca_block_cipher_mode_e bcm,
+ size_t key_bits);
+
/**@}*/
#ifdef __cplusplus
return ctx->get_output_length(ctx, input_len);
}
-
-API int yaca_get_iv_bits(yaca_enc_algo_e algo,
- yaca_block_cipher_mode_e bcm,
- size_t key_bits)
-{
- return YACA_ERROR_NOT_IMPLEMENTED;
-}
return 0;
}
+API int yaca_get_iv_bits(yaca_enc_algo_e algo,
+ yaca_block_cipher_mode_e bcm,
+ size_t key_bits)
+{
+ const EVP_CIPHER *cipher;
+ int ret;
+
+ ret = get_symmetric_algorithm(algo, bcm, key_bits, &cipher);
+ if (ret < 0)
+ return ret;
+
+ return EVP_CIPHER_iv_length(cipher) * 8;
+}
+
API int yaca_encrypt_init(yaca_ctx_h *ctx,
yaca_enc_algo_e algo,
yaca_block_cipher_mode_e bcm,