mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
crypto: add CTR mode support
Introduce CTR mode support for the cipher APIs. CTR mode uses a counter rather than a traditional IV. The counter has additional properties, including a nonce and initial counter block. We reuse the ctx->iv as the counter for conveniences. Both libgcrypt and nettle are support CTR mode, the cipher-builtin doesn't support yet. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
f844836ddc
commit
3c28292f39
6 changed files with 94 additions and 11 deletions
|
@ -215,16 +215,16 @@ int qcrypto_cipher_decrypt(QCryptoCipher *cipher,
|
|||
/**
|
||||
* qcrypto_cipher_setiv:
|
||||
* @cipher: the cipher object
|
||||
* @iv: the initialization vector bytes
|
||||
* @iv: the initialization vector or counter (CTR mode) bytes
|
||||
* @niv: the length of @iv
|
||||
* @errpr: pointer to a NULL-initialized error object
|
||||
*
|
||||
* If the @cipher object is setup to use a mode that requires
|
||||
* initialization vectors, this sets the initialization vector
|
||||
* initialization vectors or counter, this sets the @niv
|
||||
* bytes. The @iv data should have the same length as the
|
||||
* cipher key used when originally constructing the cipher
|
||||
* object. It is an error to set an initialization vector
|
||||
* if the cipher mode does not require one.
|
||||
* or counter if the cipher mode does not require one.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue