crypto/virtio: support HMAC-SHA1
authorJay Zhou <jianjay.zhou@huawei.com>
Tue, 17 Apr 2018 09:23:24 +0000 (17:23 +0800)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Mon, 23 Apr 2018 17:20:10 +0000 (18:20 +0100)
The AES-CBC with HMAC-SHA1 has been supported now.

Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
Reviewed-by: Fan Zhang <roy.fan.zhang@intel.com>
drivers/crypto/virtio/virtio_crypto_capabilities.h
drivers/crypto/virtio/virtio_cryptodev.c

index db6932f..03c30de 100644 (file)
@@ -6,6 +6,27 @@
 #define _VIRTIO_CRYPTO_CAPABILITIES_H_
 
 #define VIRTIO_SYM_CAPABILITIES                                        \
+       {       /* SHA1 HMAC */                                         \
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,                     \
+               {.sym = {                                               \
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,        \
+                       {.auth = {                                      \
+                               .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,      \
+                               .block_size = 64,                       \
+                               .key_size = {                           \
+                                       .min = 1,                       \
+                                       .max = 64,                      \
+                                       .increment = 1                  \
+                               },                                      \
+                               .digest_size = {                        \
+                                       .min = 1,                       \
+                                       .max = 20,                      \
+                                       .increment = 1                  \
+                               },                                      \
+                               .iv_size = { 0 }                        \
+                       }, }                                            \
+               }, }                                                    \
+       },                                                              \
        {       /* AES CBC */                                           \
                .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,                     \
                {.sym = {                                               \
index f924b04..df88953 100644 (file)
@@ -1196,11 +1196,13 @@ virtio_crypto_sym_pad_auth_param(
        }
 
        switch (auth_xform->algo) {
+       case RTE_CRYPTO_AUTH_SHA1_HMAC:
+               *algo = VIRTIO_CRYPTO_MAC_HMAC_SHA1;
+               break;
        default:
                VIRTIO_CRYPTO_SESSION_LOG_ERR(
                        "Crypto: Undefined Hash algo %u specified",
                        auth_xform->algo);
-               *algo = VIRTIO_CRYPTO_NO_MAC;
                return -1;
        }