Lines Matching full:cipher
2 * QEMU Crypto cipher algorithms
24 #include "crypto/cipher.h"
110 error_setg(errp, "Cipher algorithm %d out of range", in qcrypto_cipher_validate_key_length()
122 error_setg(errp, "XTS cipher key length should be a multiple of 2"); in qcrypto_cipher_validate_key_length()
127 error_setg(errp, "Cipher key length %zu should be %zu", in qcrypto_cipher_validate_key_length()
133 error_setg(errp, "Cipher key length %zu should be %zu", in qcrypto_cipher_validate_key_length()
142 #include "cipher-gcrypt.c.inc"
144 #include "cipher-nettle.c.inc"
146 #include "cipher-gnutls.c.inc"
148 #include "cipher-builtin.c.inc"
156 QCryptoCipher *cipher = NULL; in qcrypto_cipher_new() local
159 cipher = qcrypto_afalg_cipher_ctx_new(alg, mode, key, nkey, NULL); in qcrypto_cipher_new()
162 if (!cipher) { in qcrypto_cipher_new()
163 cipher = qcrypto_cipher_ctx_new(alg, mode, key, nkey, errp); in qcrypto_cipher_new()
164 if (!cipher) { in qcrypto_cipher_new()
169 cipher->alg = alg; in qcrypto_cipher_new()
170 cipher->mode = mode; in qcrypto_cipher_new()
172 return cipher; in qcrypto_cipher_new()
176 int qcrypto_cipher_encrypt(QCryptoCipher *cipher, in qcrypto_cipher_encrypt() argument
182 const QCryptoCipherDriver *drv = cipher->driver; in qcrypto_cipher_encrypt()
183 return drv->cipher_encrypt(cipher, in, out, len, errp); in qcrypto_cipher_encrypt()
187 int qcrypto_cipher_decrypt(QCryptoCipher *cipher, in qcrypto_cipher_decrypt() argument
193 const QCryptoCipherDriver *drv = cipher->driver; in qcrypto_cipher_decrypt()
194 return drv->cipher_decrypt(cipher, in, out, len, errp); in qcrypto_cipher_decrypt()
198 int qcrypto_cipher_setiv(QCryptoCipher *cipher, in qcrypto_cipher_setiv() argument
202 const QCryptoCipherDriver *drv = cipher->driver; in qcrypto_cipher_setiv()
203 return drv->cipher_setiv(cipher, iv, niv, errp); in qcrypto_cipher_setiv()
207 void qcrypto_cipher_free(QCryptoCipher *cipher) in qcrypto_cipher_free() argument
209 if (cipher) { in qcrypto_cipher_free()
210 cipher->driver->cipher_free(cipher); in qcrypto_cipher_free()