diff options
| author | liequan che <liequanche@gmail.com> | 2024-10-30 08:51:46 +0000 |
|---|---|---|
| committer | Daniel P. Berrangé <berrange@redhat.com> | 2024-11-05 18:37:18 +0000 |
| commit | d078da86d61cf0f188cd099bef9b7b2dcfeba5a7 (patch) | |
| tree | 7fa359d1900f7460aead1f89e59a81f2f3648835 /crypto/hmac-nettle.c | |
| parent | 62eb377e0a3179ff57274e096eca0102f96d0170 (diff) | |
| download | focaccia-qemu-d078da86d61cf0f188cd099bef9b7b2dcfeba5a7.tar.gz focaccia-qemu-d078da86d61cf0f188cd099bef9b7b2dcfeba5a7.zip | |
crypto: Introduce SM3 hash hmac pbkdf algorithm
Introduce the SM3 cryptographic hash algorithm (GB/T 32905-2016). SM3 (GB/T 32905-2016) is a cryptographic standard issued by the Organization of State Commercial Cryptography Administration (OSCCA) as an authorized cryptographic algorithm for use within China. Detect the SM3 cryptographic hash algorithm and enable the feature silently if it is available. Signed-off-by: cheliequan <cheliequan@inspur.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'crypto/hmac-nettle.c')
| -rw-r--r-- | crypto/hmac-nettle.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/hmac-nettle.c b/crypto/hmac-nettle.c index 54dd75d5ff..dd5b2ab7a1 100644 --- a/crypto/hmac-nettle.c +++ b/crypto/hmac-nettle.c @@ -38,6 +38,9 @@ struct QCryptoHmacNettle { struct hmac_sha256_ctx sha256_ctx; /* equals hmac_sha224_ctx */ struct hmac_sha512_ctx sha512_ctx; /* equals hmac_sha384_ctx */ struct hmac_ripemd160_ctx ripemd160_ctx; +#ifdef CONFIG_CRYPTO_SM3 + struct hmac_sm3_ctx ctx; +#endif } u; }; @@ -89,6 +92,14 @@ struct qcrypto_nettle_hmac_alg { .digest = (qcrypto_nettle_hmac_digest)hmac_ripemd160_digest, .len = RIPEMD160_DIGEST_SIZE, }, +#ifdef CONFIG_CRYPTO_SM3 + [QCRYPTO_HASH_ALGO_SM3] = { + .setkey = (qcrypto_nettle_hmac_setkey)hmac_sm3_set_key, + .update = (qcrypto_nettle_hmac_update)hmac_sm3_update, + .digest = (qcrypto_nettle_hmac_digest)hmac_sm3_digest, + .len = SM3_DIGEST_SIZE, + }, +#endif }; bool qcrypto_hmac_supports(QCryptoHashAlgo alg) |