Skip to content

Commit

Permalink
crypto: move QCryptoHashAlgorithm enum definition into QAPI
Browse files Browse the repository at this point in the history
The QCryptoHashAlgorithm enum is defined in the crypto/hash.h
header. In the future some QAPI types will want to reference
the hash enums, so move the enum definition into QAPI too.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
  • Loading branch information
berrange committed Dec 23, 2015
1 parent 7b36064 commit d84b79d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crypto/hash.c
Expand Up @@ -24,13 +24,13 @@
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>

static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG_LAST] = {
static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] = {
[QCRYPTO_HASH_ALG_MD5] = GNUTLS_DIG_MD5,
[QCRYPTO_HASH_ALG_SHA1] = GNUTLS_DIG_SHA1,
[QCRYPTO_HASH_ALG_SHA256] = GNUTLS_DIG_SHA256,
};

static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG_LAST] = {
static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = {
[QCRYPTO_HASH_ALG_MD5] = 16,
[QCRYPTO_HASH_ALG_SHA1] = 20,
[QCRYPTO_HASH_ALG_SHA256] = 32,
Expand Down
9 changes: 1 addition & 8 deletions include/crypto/hash.h
Expand Up @@ -24,14 +24,7 @@
#include "qemu-common.h"
#include "qapi/error.h"

typedef enum {
QCRYPTO_HASH_ALG_MD5,
QCRYPTO_HASH_ALG_SHA1,
QCRYPTO_HASH_ALG_SHA256,

QCRYPTO_HASH_ALG_LAST
} QCryptoHashAlgorithm;

/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */

/**
* qcrypto_hash_supports:
Expand Down
15 changes: 15 additions & 0 deletions qapi/crypto.json
Expand Up @@ -33,3 +33,18 @@
{ 'enum': 'QCryptoSecretFormat',
'prefix': 'QCRYPTO_SECRET_FORMAT',
'data': ['raw', 'base64']}


##
# QCryptoHashAlgorithm:
#
# The supported algorithms for computing content digests
#
# @md5: MD5. Should not be used in any new code, legacy compat only
# @sha1: SHA-1. Should not be used in any new code, legacy compat only
# @sha256: SHA-256. Current recommended strong hash.
# Since: 2.6
##
{ 'enum': 'QCryptoHashAlgorithm',
'prefix': 'QCRYPTO_HASH_ALG',
'data': ['md5', 'sha1', 'sha256']}

0 comments on commit d84b79d

Please sign in to comment.