diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-10-23 16:13:50 +0100 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2015-12-23 11:02:20 +0000 |
commit | dd2bf9eb95f875f0ad6a15aecb48cfc8b739fcbc (patch) | |
tree | cbc8e4b7a4f1af17d438cf51f5c0a558bd5472f6 /include | |
parent | 5dc42c186d63b7b338594fc071cf290805dcc5a5 (diff) |
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 <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/cipher.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index b4d714f269..aa51c89f8e 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: |