From dd2bf9eb95f875f0ad6a15aecb48cfc8b739fcbc Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 23 Oct 2015 16:13:50 +0100 Subject: crypto: add additional query accessors for cipher instances Adds new methods to allow querying the length of the cipher key, block size and initialization vectors. Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- include/crypto/cipher.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'include/crypto') diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index b4d714f..aa51c89 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -107,6 +107,43 @@ struct QCryptoCipher { */ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg); +/** + * qcrypto_cipher_get_block_len: + * @alg: the cipher algorithm + * + * Get the required data block size in bytes. When + * encrypting data, it must be a multiple of the + * block size. + * + * Returns: the block size in bytes + */ +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg); + + +/** + * qcrypto_cipher_get_key_len: + * @alg: the cipher algorithm + * + * Get the required key size in bytes. + * + * Returns: the key size in bytes + */ +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg); + + +/** + * qcrypto_cipher_get_iv_len: + * @alg: the cipher algorithm + * @mode: the cipher mode + * + * Get the required initialization vector size + * in bytes, if one is required. + * + * Returns: the IV size in bytes, or 0 if no IV is permitted + */ +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, + QCryptoCipherMode mode); + /** * qcrypto_cipher_new: -- cgit v1.1