qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-2.9 v3 4/6] crypto: support HMAC algorithms


From: Daniel P. Berrange
Subject: Re: [Qemu-devel] [PATCH for-2.9 v3 4/6] crypto: support HMAC algorithms based on glibc
Date: Tue, 13 Dec 2016 09:34:31 +0000
User-agent: Mutt/1.7.1 (2016-10-04)

On Tue, Dec 13, 2016 at 03:01:51PM +0800, Longpeng(Mike) wrote:
> This patch add glibc-backed HMAC algorithms support

s/glibc/glib/  and also in $SUBJECT

> diff --git a/crypto/hmac-glib.c b/crypto/hmac-glib.c
> index 3e2a933..f07c841 100644
> --- a/crypto/hmac-glib.c
> +++ b/crypto/hmac-glib.c
> @@ -16,8 +16,40 @@
>  #include "qapi/error.h"
>  #include "crypto/hmac.h"
>  
> +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] = {
> +/* Support for HMAC Algos has been added in GLib 2.30 */
> +#if GLIB_CHECK_VERSION(2, 30, 0)
> +    [QCRYPTO_HASH_ALG_MD5] = G_CHECKSUM_MD5,
> +    [QCRYPTO_HASH_ALG_SHA1] = G_CHECKSUM_SHA1,
> +    [QCRYPTO_HASH_ALG_SHA256] = G_CHECKSUM_SHA256,
> +#else
> +    [QCRYPTO_HASH_ALG_MD5] = -1,
> +    [QCRYPTO_HASH_ALG_SHA1] = -1,
> +    [QCRYPTO_HASH_ALG_SHA256] = -1,
> +#endif
> +/* Support for HMAC SHA-512 in GLib 2.42 */
> +#if GLIB_CHECK_VERSION(2, 42, 0)
> +    [QCRYPTO_HASH_ALG_SHA512] = G_CHECKSUM_SHA512,
> +#else
> +    [QCRYPTO_HASH_ALG_SHA512] = -1,
> +#endif
> +    [QCRYPTO_HASH_ALG_SHA224] = -1,
> +    [QCRYPTO_HASH_ALG_SHA384] = -1,
> +    [QCRYPTO_HASH_ALG_RIPEMD160] = -1,
> +};

As mentioned in reply to the build failure - the 2.30.0 check
will have to surround the entire file...

> +
> +typedef struct QCryptoHmacGlib QCryptoHmacGlib;
> +struct QCryptoHmacGlib {
> +    GHmac *ghmac;

...otherwise this triggers failure due to missing typedefs.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]