mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-18 15:07:16 +00:00
Drop unused crypto source files
This commit is contained in:
parent
5637099383
commit
f8d54a8f3c
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_aarch64
|
#define qbus_finalize qbus_finalize_aarch64
|
||||||
#define qbus_initfn qbus_initfn_aarch64
|
#define qbus_initfn qbus_initfn_aarch64
|
||||||
#define qbus_realize qbus_realize_aarch64
|
#define qbus_realize qbus_realize_aarch64
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_aarch64
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_aarch64
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_aarch64
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_aarch64
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_aarch64
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_aarch64
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_aarch64
|
|
||||||
#define qcrypto_init qcrypto_init_aarch64
|
|
||||||
#define qdev_create qdev_create_aarch64
|
#define qdev_create qdev_create_aarch64
|
||||||
#define qdev_get_type qdev_get_type_aarch64
|
#define qdev_get_type qdev_get_type_aarch64
|
||||||
#define qdev_register_types qdev_register_types_aarch64
|
#define qdev_register_types qdev_register_types_aarch64
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_aarch64eb
|
#define qbus_finalize qbus_finalize_aarch64eb
|
||||||
#define qbus_initfn qbus_initfn_aarch64eb
|
#define qbus_initfn qbus_initfn_aarch64eb
|
||||||
#define qbus_realize qbus_realize_aarch64eb
|
#define qbus_realize qbus_realize_aarch64eb
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_aarch64eb
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_aarch64eb
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_aarch64eb
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_aarch64eb
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_aarch64eb
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_aarch64eb
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_aarch64eb
|
|
||||||
#define qcrypto_init qcrypto_init_aarch64eb
|
|
||||||
#define qdev_create qdev_create_aarch64eb
|
#define qdev_create qdev_create_aarch64eb
|
||||||
#define qdev_get_type qdev_get_type_aarch64eb
|
#define qdev_get_type qdev_get_type_aarch64eb
|
||||||
#define qdev_register_types qdev_register_types_aarch64eb
|
#define qdev_register_types qdev_register_types_aarch64eb
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_arm
|
#define qbus_finalize qbus_finalize_arm
|
||||||
#define qbus_initfn qbus_initfn_arm
|
#define qbus_initfn qbus_initfn_arm
|
||||||
#define qbus_realize qbus_realize_arm
|
#define qbus_realize qbus_realize_arm
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_arm
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_arm
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_arm
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_arm
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_arm
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_arm
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_arm
|
|
||||||
#define qcrypto_init qcrypto_init_arm
|
|
||||||
#define qdev_create qdev_create_arm
|
#define qdev_create qdev_create_arm
|
||||||
#define qdev_get_type qdev_get_type_arm
|
#define qdev_get_type qdev_get_type_arm
|
||||||
#define qdev_register_types qdev_register_types_arm
|
#define qdev_register_types qdev_register_types_arm
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_armeb
|
#define qbus_finalize qbus_finalize_armeb
|
||||||
#define qbus_initfn qbus_initfn_armeb
|
#define qbus_initfn qbus_initfn_armeb
|
||||||
#define qbus_realize qbus_realize_armeb
|
#define qbus_realize qbus_realize_armeb
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_armeb
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_armeb
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_armeb
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_armeb
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_armeb
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_armeb
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_armeb
|
|
||||||
#define qcrypto_init qcrypto_init_armeb
|
|
||||||
#define qdev_create qdev_create_armeb
|
#define qdev_create qdev_create_armeb
|
||||||
#define qdev_get_type qdev_get_type_armeb
|
#define qdev_get_type qdev_get_type_armeb
|
||||||
#define qdev_register_types qdev_register_types_armeb
|
#define qdev_register_types qdev_register_types_armeb
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
crypto-obj-y = init.o
|
|
||||||
crypto-obj-y += hash.o
|
|
||||||
crypto-obj-y += aes.o
|
crypto-obj-y += aes.o
|
||||||
|
|
||||||
# Let the userspace emulators avoid linking gnutls/etc
|
# Let the userspace emulators avoid linking gnutls/etc
|
||||||
|
|
|
@ -1,199 +0,0 @@
|
||||||
/*
|
|
||||||
* QEMU Crypto hash algorithms
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "crypto/hash.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_GNUTLS_HASH
|
|
||||||
#include <gnutls/gnutls.h>
|
|
||||||
#include <gnutls/crypto.h>
|
|
||||||
|
|
||||||
static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG_LAST] = {
|
|
||||||
GNUTLS_DIG_MD5,
|
|
||||||
GNUTLS_DIG_SHA1,
|
|
||||||
GNUTLS_DIG_SHA256,
|
|
||||||
};
|
|
||||||
|
|
||||||
gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg)
|
|
||||||
{
|
|
||||||
if (alg < (sizeof(qcrypto_hash_alg_map) / sizeof(qcrypto_hash_alg_map[0]))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
uint8_t **result,
|
|
||||||
size_t *resultlen,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
int i, ret;
|
|
||||||
gnutls_hash_hd_t dig;
|
|
||||||
|
|
||||||
if (alg >= (sizeof(qcrypto_hash_alg_map) / sizeof(qcrypto_hash_alg_map[0]))) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Unknown hash algorithm %d",
|
|
||||||
alg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gnutls_hash_init(&dig, qcrypto_hash_alg_map[alg]);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Unable to initialize hash algorithm: %s",
|
|
||||||
gnutls_strerror(ret));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < niov; i++) {
|
|
||||||
ret = gnutls_hash(dig, iov[i].iov_base, iov[i].iov_len);
|
|
||||||
if (ret < 0) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Unable process hash data: %s",
|
|
||||||
gnutls_strerror(ret));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gnutls_hash_get_len(qcrypto_hash_alg_map[alg]);
|
|
||||||
if (ret <= 0) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Unable to get hash length: %s",
|
|
||||||
gnutls_strerror(ret));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (*resultlen == 0) {
|
|
||||||
*resultlen = ret;
|
|
||||||
*result = g_new0(uint8_t, *resultlen);
|
|
||||||
} else if (*resultlen != ret) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Result buffer size %zu is smaller than hash %d",
|
|
||||||
*resultlen, ret);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
gnutls_hash_deinit(dig, *result);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
gnutls_hash_deinit(dig, NULL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* ! CONFIG_GNUTLS_HASH */
|
|
||||||
|
|
||||||
gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
uint8_t **result,
|
|
||||||
size_t *resultlen,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
error_setg(errp,
|
|
||||||
"Hash algorithm %d not supported without GNUTLS",
|
|
||||||
alg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* ! CONFIG_GNUTLS_HASH */
|
|
||||||
|
|
||||||
int qcrypto_hash_bytes(QCryptoHashAlgorithm alg,
|
|
||||||
const char *buf,
|
|
||||||
size_t len,
|
|
||||||
uint8_t **result,
|
|
||||||
size_t *resultlen,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
struct iovec iov = { (char *)buf, len };
|
|
||||||
return qcrypto_hash_bytesv(alg, &iov, 1, result, resultlen, errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char hex[] = "0123456789abcdef";
|
|
||||||
|
|
||||||
int qcrypto_hash_digestv(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
char **digest,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
uint8_t *result = NULL;
|
|
||||||
size_t resultlen = 0;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (qcrypto_hash_bytesv(alg, iov, niov, &result, &resultlen, errp) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*digest = g_new0(char, (resultlen * 2) + 1);
|
|
||||||
for (i = 0 ; i < resultlen ; i++) {
|
|
||||||
(*digest)[(i * 2)] = hex[(result[i] >> 4) & 0xf];
|
|
||||||
(*digest)[(i * 2) + 1] = hex[result[i] & 0xf];
|
|
||||||
}
|
|
||||||
(*digest)[resultlen * 2] = '\0';
|
|
||||||
g_free(result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qcrypto_hash_digest(QCryptoHashAlgorithm alg,
|
|
||||||
const char *buf,
|
|
||||||
size_t len,
|
|
||||||
char **digest,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
struct iovec iov = { (char *)buf, len };
|
|
||||||
|
|
||||||
return qcrypto_hash_digestv(alg, &iov, 1, digest, errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
int qcrypto_hash_base64v(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
char **base64,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
uint8_t *result = NULL;
|
|
||||||
size_t resultlen = 0;
|
|
||||||
|
|
||||||
if (qcrypto_hash_bytesv(alg, iov, niov, &result, &resultlen, errp) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*base64 = g_base64_encode(result, resultlen);
|
|
||||||
g_free(result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qcrypto_hash_base64(QCryptoHashAlgorithm alg,
|
|
||||||
const char *buf,
|
|
||||||
size_t len,
|
|
||||||
char **base64,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
struct iovec iov = { (char *)buf, len };
|
|
||||||
|
|
||||||
return qcrypto_hash_base64v(alg, &iov, 1, base64, errp);
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* QEMU Crypto initialization
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "crypto/init.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_GNUTLS
|
|
||||||
#include <gnutls/gnutls.h>
|
|
||||||
#include <gnutls/crypto.h>
|
|
||||||
|
|
||||||
/* #define DEBUG_GNUTLS */
|
|
||||||
|
|
||||||
#ifdef DEBUG_GNUTLS
|
|
||||||
static void qcrypto_gnutls_log(int level, const char *str)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%d: %s", level, str);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int qcrypto_init(Error **errp)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
ret = gnutls_global_init();
|
|
||||||
if (ret < 0) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Unable to initialize GNUTLS library: %s",
|
|
||||||
gnutls_strerror(ret));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#ifdef DEBUG_GNUTLS
|
|
||||||
gnutls_global_set_log_level(10);
|
|
||||||
gnutls_global_set_log_function(qcrypto_gnutls_log);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* ! CONFIG_GNUTLS */
|
|
||||||
|
|
||||||
int qcrypto_init(Error **errp)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* ! CONFIG_GNUTLS */
|
|
|
@ -2375,14 +2375,6 @@ symbols = (
|
||||||
'qbus_finalize',
|
'qbus_finalize',
|
||||||
'qbus_initfn',
|
'qbus_initfn',
|
||||||
'qbus_realize',
|
'qbus_realize',
|
||||||
'qcrypto_hash_base64',
|
|
||||||
'qcrypto_hash_base64v',
|
|
||||||
'qcrypto_hash_bytes',
|
|
||||||
'qcrypto_hash_bytesv',
|
|
||||||
'qcrypto_hash_digest',
|
|
||||||
'qcrypto_hash_digestv',
|
|
||||||
'qcrypto_hash_supports',
|
|
||||||
'qcrypto_init',
|
|
||||||
'qdev_create',
|
'qdev_create',
|
||||||
'qdev_get_type',
|
'qdev_get_type',
|
||||||
'qdev_register_types',
|
'qdev_register_types',
|
||||||
|
|
|
@ -1,189 +0,0 @@
|
||||||
/*
|
|
||||||
* QEMU Crypto hash algorithms
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QCRYPTO_HASH_H__
|
|
||||||
#define QCRYPTO_HASH_H__
|
|
||||||
|
|
||||||
#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;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_supports:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
*
|
|
||||||
* Determine if @alg hash algorithm is supported by the
|
|
||||||
* current configured build.
|
|
||||||
*
|
|
||||||
* Returns: true if the algorithm is supported, false otherwise
|
|
||||||
*/
|
|
||||||
gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_bytesv:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
* @iov: the array of memory regions to hash
|
|
||||||
* @niov: the length of @iov
|
|
||||||
* @result: pointer to hold output hash
|
|
||||||
* @resultlen: pointer to hold length of @result
|
|
||||||
* @errp: pointer to uninitialized error object
|
|
||||||
*
|
|
||||||
* Computes the hash across all the memory regions
|
|
||||||
* present in @iov. The @result pointer will be
|
|
||||||
* filled with raw bytes representing the computed
|
|
||||||
* hash, which will have length @resultlen. The
|
|
||||||
* memory pointer in @result must be released
|
|
||||||
* with a call to g_free() when no longer required.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, -1 on error
|
|
||||||
*/
|
|
||||||
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
uint8_t **result,
|
|
||||||
size_t *resultlen,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_bytes:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
* @buf: the memory region to hash
|
|
||||||
* @len: the length of @buf
|
|
||||||
* @result: pointer to hold output hash
|
|
||||||
* @resultlen: pointer to hold length of @result
|
|
||||||
* @errp: pointer to uninitialized error object
|
|
||||||
*
|
|
||||||
* Computes the hash across all the memory region
|
|
||||||
* @buf of length @len. The @result pointer will be
|
|
||||||
* filled with raw bytes representing the computed
|
|
||||||
* hash, which will have length @resultlen. The
|
|
||||||
* memory pointer in @result must be released
|
|
||||||
* with a call to g_free() when no longer required.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, -1 on error
|
|
||||||
*/
|
|
||||||
int qcrypto_hash_bytes(QCryptoHashAlgorithm alg,
|
|
||||||
const char *buf,
|
|
||||||
size_t len,
|
|
||||||
uint8_t **result,
|
|
||||||
size_t *resultlen,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_digestv:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
* @iov: the array of memory regions to hash
|
|
||||||
* @niov: the length of @iov
|
|
||||||
* @digest: pointer to hold output hash
|
|
||||||
* @errp: pointer to uninitialized error object
|
|
||||||
*
|
|
||||||
* Computes the hash across all the memory regions
|
|
||||||
* present in @iov. The @digest pointer will be
|
|
||||||
* filled with the printable hex digest of the computed
|
|
||||||
* hash, which will be terminated by '\0'. The
|
|
||||||
* memory pointer in @digest must be released
|
|
||||||
* with a call to g_free() when no longer required.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, -1 on error
|
|
||||||
*/
|
|
||||||
int qcrypto_hash_digestv(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
char **digest,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_digest:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
* @buf: the memory region to hash
|
|
||||||
* @len: the length of @buf
|
|
||||||
* @digest: pointer to hold output hash
|
|
||||||
* @errp: pointer to uninitialized error object
|
|
||||||
*
|
|
||||||
* Computes the hash across all the memory region
|
|
||||||
* @buf of length @len. The @digest pointer will be
|
|
||||||
* filled with the printable hex digest of the computed
|
|
||||||
* hash, which will be terminated by '\0'. The
|
|
||||||
* memory pointer in @digest must be released
|
|
||||||
* with a call to g_free() when no longer required.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, -1 on error
|
|
||||||
*/
|
|
||||||
int qcrypto_hash_digest(QCryptoHashAlgorithm alg,
|
|
||||||
const char *buf,
|
|
||||||
size_t len,
|
|
||||||
char **digest,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_base64v:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
* @iov: the array of memory regions to hash
|
|
||||||
* @niov: the length of @iov
|
|
||||||
* @base64: pointer to hold output hash
|
|
||||||
* @errp: pointer to uninitialized error object
|
|
||||||
*
|
|
||||||
* Computes the hash across all the memory regions
|
|
||||||
* present in @iov. The @base64 pointer will be
|
|
||||||
* filled with the base64 encoding of the computed
|
|
||||||
* hash, which will be terminated by '\0'. The
|
|
||||||
* memory pointer in @base64 must be released
|
|
||||||
* with a call to g_free() when no longer required.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, -1 on error
|
|
||||||
*/
|
|
||||||
int qcrypto_hash_base64v(QCryptoHashAlgorithm alg,
|
|
||||||
const struct iovec *iov,
|
|
||||||
size_t niov,
|
|
||||||
char **base64,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qcrypto_hash_base64:
|
|
||||||
* @alg: the hash algorithm
|
|
||||||
* @buf: the memory region to hash
|
|
||||||
* @len: the length of @buf
|
|
||||||
* @base64: pointer to hold output hash
|
|
||||||
* @errp: pointer to uninitialized error object
|
|
||||||
*
|
|
||||||
* Computes the hash across all the memory region
|
|
||||||
* @buf of length @len. The @base64 pointer will be
|
|
||||||
* filled with the base64 encoding of the computed
|
|
||||||
* hash, which will be terminated by '\0'. The
|
|
||||||
* memory pointer in @base64 must be released
|
|
||||||
* with a call to g_free() when no longer required.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, -1 on error
|
|
||||||
*/
|
|
||||||
int qcrypto_hash_base64(QCryptoHashAlgorithm alg,
|
|
||||||
const char *buf,
|
|
||||||
size_t len,
|
|
||||||
char **base64,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
#endif /* QCRYPTO_HASH_H__ */
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* QEMU Crypto initialization
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QCRYPTO_INIT_H__
|
|
||||||
#define QCRYPTO_INIT_H__
|
|
||||||
|
|
||||||
#include "qemu-common.h"
|
|
||||||
#include "qapi/error.h"
|
|
||||||
|
|
||||||
int qcrypto_init(Error **errp);
|
|
||||||
|
|
||||||
#endif /* QCRYPTO_INIT_H__ */
|
|
|
@ -132,13 +132,6 @@ void qemu_anon_ram_free(void *ptr, size_t size);
|
||||||
#define FMT_pid "%d"
|
#define FMT_pid "%d"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_IOVEC
|
|
||||||
struct iovec {
|
|
||||||
void *iov_base;
|
|
||||||
size_t iov_len;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_getauxval:
|
* qemu_getauxval:
|
||||||
* @type: the auxiliary vector key to lookup
|
* @type: the auxiliary vector key to lookup
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_m68k
|
#define qbus_finalize qbus_finalize_m68k
|
||||||
#define qbus_initfn qbus_initfn_m68k
|
#define qbus_initfn qbus_initfn_m68k
|
||||||
#define qbus_realize qbus_realize_m68k
|
#define qbus_realize qbus_realize_m68k
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_m68k
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_m68k
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_m68k
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_m68k
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_m68k
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_m68k
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_m68k
|
|
||||||
#define qcrypto_init qcrypto_init_m68k
|
|
||||||
#define qdev_create qdev_create_m68k
|
#define qdev_create qdev_create_m68k
|
||||||
#define qdev_get_type qdev_get_type_m68k
|
#define qdev_get_type qdev_get_type_m68k
|
||||||
#define qdev_register_types qdev_register_types_m68k
|
#define qdev_register_types qdev_register_types_m68k
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_mips
|
#define qbus_finalize qbus_finalize_mips
|
||||||
#define qbus_initfn qbus_initfn_mips
|
#define qbus_initfn qbus_initfn_mips
|
||||||
#define qbus_realize qbus_realize_mips
|
#define qbus_realize qbus_realize_mips
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_mips
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_mips
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_mips
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_mips
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_mips
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_mips
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_mips
|
|
||||||
#define qcrypto_init qcrypto_init_mips
|
|
||||||
#define qdev_create qdev_create_mips
|
#define qdev_create qdev_create_mips
|
||||||
#define qdev_get_type qdev_get_type_mips
|
#define qdev_get_type qdev_get_type_mips
|
||||||
#define qdev_register_types qdev_register_types_mips
|
#define qdev_register_types qdev_register_types_mips
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_mips64
|
#define qbus_finalize qbus_finalize_mips64
|
||||||
#define qbus_initfn qbus_initfn_mips64
|
#define qbus_initfn qbus_initfn_mips64
|
||||||
#define qbus_realize qbus_realize_mips64
|
#define qbus_realize qbus_realize_mips64
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_mips64
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_mips64
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_mips64
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_mips64
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_mips64
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_mips64
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_mips64
|
|
||||||
#define qcrypto_init qcrypto_init_mips64
|
|
||||||
#define qdev_create qdev_create_mips64
|
#define qdev_create qdev_create_mips64
|
||||||
#define qdev_get_type qdev_get_type_mips64
|
#define qdev_get_type qdev_get_type_mips64
|
||||||
#define qdev_register_types qdev_register_types_mips64
|
#define qdev_register_types qdev_register_types_mips64
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_mips64el
|
#define qbus_finalize qbus_finalize_mips64el
|
||||||
#define qbus_initfn qbus_initfn_mips64el
|
#define qbus_initfn qbus_initfn_mips64el
|
||||||
#define qbus_realize qbus_realize_mips64el
|
#define qbus_realize qbus_realize_mips64el
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_mips64el
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_mips64el
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_mips64el
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_mips64el
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_mips64el
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_mips64el
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_mips64el
|
|
||||||
#define qcrypto_init qcrypto_init_mips64el
|
|
||||||
#define qdev_create qdev_create_mips64el
|
#define qdev_create qdev_create_mips64el
|
||||||
#define qdev_get_type qdev_get_type_mips64el
|
#define qdev_get_type qdev_get_type_mips64el
|
||||||
#define qdev_register_types qdev_register_types_mips64el
|
#define qdev_register_types qdev_register_types_mips64el
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_mipsel
|
#define qbus_finalize qbus_finalize_mipsel
|
||||||
#define qbus_initfn qbus_initfn_mipsel
|
#define qbus_initfn qbus_initfn_mipsel
|
||||||
#define qbus_realize qbus_realize_mipsel
|
#define qbus_realize qbus_realize_mipsel
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_mipsel
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_mipsel
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_mipsel
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_mipsel
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_mipsel
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_mipsel
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_mipsel
|
|
||||||
#define qcrypto_init qcrypto_init_mipsel
|
|
||||||
#define qdev_create qdev_create_mipsel
|
#define qdev_create qdev_create_mipsel
|
||||||
#define qdev_get_type qdev_get_type_mipsel
|
#define qdev_get_type qdev_get_type_mipsel
|
||||||
#define qdev_register_types qdev_register_types_mipsel
|
#define qdev_register_types qdev_register_types_mipsel
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_powerpc
|
#define qbus_finalize qbus_finalize_powerpc
|
||||||
#define qbus_initfn qbus_initfn_powerpc
|
#define qbus_initfn qbus_initfn_powerpc
|
||||||
#define qbus_realize qbus_realize_powerpc
|
#define qbus_realize qbus_realize_powerpc
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_powerpc
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_powerpc
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_powerpc
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_powerpc
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_powerpc
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_powerpc
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_powerpc
|
|
||||||
#define qcrypto_init qcrypto_init_powerpc
|
|
||||||
#define qdev_create qdev_create_powerpc
|
#define qdev_create qdev_create_powerpc
|
||||||
#define qdev_get_type qdev_get_type_powerpc
|
#define qdev_get_type qdev_get_type_powerpc
|
||||||
#define qdev_register_types qdev_register_types_powerpc
|
#define qdev_register_types qdev_register_types_powerpc
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_sparc
|
#define qbus_finalize qbus_finalize_sparc
|
||||||
#define qbus_initfn qbus_initfn_sparc
|
#define qbus_initfn qbus_initfn_sparc
|
||||||
#define qbus_realize qbus_realize_sparc
|
#define qbus_realize qbus_realize_sparc
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_sparc
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_sparc
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_sparc
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_sparc
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_sparc
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_sparc
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_sparc
|
|
||||||
#define qcrypto_init qcrypto_init_sparc
|
|
||||||
#define qdev_create qdev_create_sparc
|
#define qdev_create qdev_create_sparc
|
||||||
#define qdev_get_type qdev_get_type_sparc
|
#define qdev_get_type qdev_get_type_sparc
|
||||||
#define qdev_register_types qdev_register_types_sparc
|
#define qdev_register_types qdev_register_types_sparc
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_sparc64
|
#define qbus_finalize qbus_finalize_sparc64
|
||||||
#define qbus_initfn qbus_initfn_sparc64
|
#define qbus_initfn qbus_initfn_sparc64
|
||||||
#define qbus_realize qbus_realize_sparc64
|
#define qbus_realize qbus_realize_sparc64
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_sparc64
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_sparc64
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_sparc64
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_sparc64
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_sparc64
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_sparc64
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_sparc64
|
|
||||||
#define qcrypto_init qcrypto_init_sparc64
|
|
||||||
#define qdev_create qdev_create_sparc64
|
#define qdev_create qdev_create_sparc64
|
||||||
#define qdev_get_type qdev_get_type_sparc64
|
#define qdev_get_type qdev_get_type_sparc64
|
||||||
#define qdev_register_types qdev_register_types_sparc64
|
#define qdev_register_types qdev_register_types_sparc64
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include "vl.h"
|
#include "vl.h"
|
||||||
#include "uc_priv.h"
|
#include "uc_priv.h"
|
||||||
#include "exec/semihost.h"
|
#include "exec/semihost.h"
|
||||||
#include "crypto/init.h"
|
|
||||||
|
|
||||||
#define DEFAULT_RAM_SIZE 128
|
#define DEFAULT_RAM_SIZE 128
|
||||||
|
|
||||||
|
@ -110,7 +109,6 @@ int machine_initialize(struct uc_struct *uc)
|
||||||
{
|
{
|
||||||
MachineClass *machine_class;
|
MachineClass *machine_class;
|
||||||
MachineState *current_machine;
|
MachineState *current_machine;
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
module_call_init(uc, MODULE_INIT_QOM);
|
module_call_init(uc, MODULE_INIT_QOM);
|
||||||
register_types_object(uc);
|
register_types_object(uc);
|
||||||
|
@ -119,13 +117,6 @@ int machine_initialize(struct uc_struct *uc)
|
||||||
cpu_register_types(uc);
|
cpu_register_types(uc);
|
||||||
qdev_register_types(uc);
|
qdev_register_types(uc);
|
||||||
|
|
||||||
// Init crypto
|
|
||||||
if (qcrypto_init(&err) < 0) {
|
|
||||||
//fprintf(stderr, "Cannot initialize crypto: %s\n",
|
|
||||||
// error_get_pretty(err));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize arch specific.
|
// Initialize arch specific.
|
||||||
uc->init_arch(uc);
|
uc->init_arch(uc);
|
||||||
|
|
||||||
|
|
|
@ -2369,14 +2369,6 @@
|
||||||
#define qbus_finalize qbus_finalize_x86_64
|
#define qbus_finalize qbus_finalize_x86_64
|
||||||
#define qbus_initfn qbus_initfn_x86_64
|
#define qbus_initfn qbus_initfn_x86_64
|
||||||
#define qbus_realize qbus_realize_x86_64
|
#define qbus_realize qbus_realize_x86_64
|
||||||
#define qcrypto_hash_base64 qcrypto_hash_base64_x86_64
|
|
||||||
#define qcrypto_hash_base64v qcrypto_hash_base64v_x86_64
|
|
||||||
#define qcrypto_hash_bytes qcrypto_hash_bytes_x86_64
|
|
||||||
#define qcrypto_hash_bytesv qcrypto_hash_bytesv_x86_64
|
|
||||||
#define qcrypto_hash_digest qcrypto_hash_digest_x86_64
|
|
||||||
#define qcrypto_hash_digestv qcrypto_hash_digestv_x86_64
|
|
||||||
#define qcrypto_hash_supports qcrypto_hash_supports_x86_64
|
|
||||||
#define qcrypto_init qcrypto_init_x86_64
|
|
||||||
#define qdev_create qdev_create_x86_64
|
#define qdev_create qdev_create_x86_64
|
||||||
#define qdev_get_type qdev_get_type_x86_64
|
#define qdev_get_type qdev_get_type_x86_64
|
||||||
#define qdev_register_types qdev_register_types_x86_64
|
#define qdev_register_types qdev_register_types_x86_64
|
||||||
|
|
Loading…
Reference in a new issue