mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
crypto: hmac: add af_alg-backend hmac support
Adds afalg-backend hmac support: introduces some private APIs firstly, and then intergrates them into qcrypto_hmac_afalg_driver. Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
9a05977348
commit
42e7e15f99
3 changed files with 121 additions and 17 deletions
|
@ -89,17 +89,31 @@ QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
|
|||
Error **errp)
|
||||
{
|
||||
QCryptoHmac *hmac;
|
||||
void *ctx;
|
||||
void *ctx = NULL;
|
||||
Error *err2 = NULL;
|
||||
QCryptoHmacDriver *drv = NULL;
|
||||
|
||||
#ifdef CONFIG_AF_ALG
|
||||
ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);
|
||||
if (ctx) {
|
||||
drv = &qcrypto_hmac_afalg_driver;
|
||||
}
|
||||
#endif
|
||||
|
||||
ctx = qcrypto_hmac_ctx_new(alg, key, nkey, errp);
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
ctx = qcrypto_hmac_ctx_new(alg, key, nkey, errp);
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
drv = &qcrypto_hmac_lib_driver;
|
||||
error_free(err2);
|
||||
}
|
||||
|
||||
hmac = g_new0(QCryptoHmac, 1);
|
||||
hmac->alg = alg;
|
||||
hmac->opaque = ctx;
|
||||
hmac->driver = (void *)&qcrypto_hmac_lib_driver;
|
||||
hmac->driver = (void *)drv;
|
||||
|
||||
return hmac;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue