qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo
For consistency with other types names *Algo. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20240904111836.3273842-17-armbru@redhat.com>
This commit is contained in:
parent
c96050f43e
commit
8f525028bc
@ -66,13 +66,13 @@ qcrypto_afalg_socket_bind(const char *type, const char *name,
|
|||||||
return sbind;
|
return sbind;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCryptoAFAlg *
|
QCryptoAFAlgo *
|
||||||
qcrypto_afalg_comm_alloc(const char *type, const char *name,
|
qcrypto_afalg_comm_alloc(const char *type, const char *name,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg;
|
QCryptoAFAlgo *afalg;
|
||||||
|
|
||||||
afalg = g_new0(QCryptoAFAlg, 1);
|
afalg = g_new0(QCryptoAFAlgo, 1);
|
||||||
/* initialize crypto API socket */
|
/* initialize crypto API socket */
|
||||||
afalg->opfd = -1;
|
afalg->opfd = -1;
|
||||||
afalg->tfmfd = qcrypto_afalg_socket_bind(type, name, errp);
|
afalg->tfmfd = qcrypto_afalg_socket_bind(type, name, errp);
|
||||||
@ -93,7 +93,7 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg)
|
void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg)
|
||||||
{
|
{
|
||||||
if (!afalg) {
|
if (!afalg) {
|
||||||
return;
|
return;
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
#define ALG_OPTYPE_LEN 4
|
#define ALG_OPTYPE_LEN 4
|
||||||
#define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
|
#define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
|
||||||
|
|
||||||
typedef struct QCryptoAFAlg QCryptoAFAlg;
|
typedef struct QCryptoAFAlgo QCryptoAFAlgo;
|
||||||
|
|
||||||
struct QCryptoAFAlg {
|
struct QCryptoAFAlgo {
|
||||||
QCryptoCipher base;
|
QCryptoCipher base;
|
||||||
|
|
||||||
int tfmfd;
|
int tfmfd;
|
||||||
@ -46,22 +46,22 @@ struct QCryptoAFAlg {
|
|||||||
* @type: the type of crypto operation
|
* @type: the type of crypto operation
|
||||||
* @name: the name of crypto operation
|
* @name: the name of crypto operation
|
||||||
*
|
*
|
||||||
* Allocate a QCryptoAFAlg object and bind itself to
|
* Allocate a QCryptoAFAlgo object and bind itself to
|
||||||
* a AF_ALG socket.
|
* a AF_ALG socket.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* a new QCryptoAFAlg object, or NULL in error.
|
* a new QCryptoAFAlgo object, or NULL in error.
|
||||||
*/
|
*/
|
||||||
QCryptoAFAlg *
|
QCryptoAFAlgo *
|
||||||
qcrypto_afalg_comm_alloc(const char *type, const char *name,
|
qcrypto_afalg_comm_alloc(const char *type, const char *name,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* afalg_comm_free:
|
* afalg_comm_free:
|
||||||
* @afalg: the QCryptoAFAlg object
|
* @afalg: the QCryptoAFAlgo object
|
||||||
*
|
*
|
||||||
* Free the @afalg.
|
* Free the @afalg.
|
||||||
*/
|
*/
|
||||||
void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg);
|
void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,7 +65,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg,
|
|||||||
const uint8_t *key,
|
const uint8_t *key,
|
||||||
size_t nkey, Error **errp)
|
size_t nkey, Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg;
|
QCryptoAFAlgo *afalg;
|
||||||
size_t expect_niv;
|
size_t expect_niv;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,
|
|||||||
const uint8_t *iv,
|
const uint8_t *iv,
|
||||||
size_t niv, Error **errp)
|
size_t niv, Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
|
QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
|
||||||
struct af_alg_iv *alg_iv;
|
struct af_alg_iv *alg_iv;
|
||||||
size_t expect_niv;
|
size_t expect_niv;
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qcrypto_afalg_cipher_op(QCryptoAFAlg *afalg,
|
qcrypto_afalg_cipher_op(QCryptoAFAlgo *afalg,
|
||||||
const void *in, void *out,
|
const void *in, void *out,
|
||||||
size_t len, bool do_encrypt,
|
size_t len, bool do_encrypt,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
@ -202,7 +202,7 @@ qcrypto_afalg_cipher_encrypt(QCryptoCipher *cipher,
|
|||||||
const void *in, void *out,
|
const void *in, void *out,
|
||||||
size_t len, Error **errp)
|
size_t len, Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
|
QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
|
||||||
|
|
||||||
return qcrypto_afalg_cipher_op(afalg, in, out, len, true, errp);
|
return qcrypto_afalg_cipher_op(afalg, in, out, len, true, errp);
|
||||||
}
|
}
|
||||||
@ -212,14 +212,14 @@ qcrypto_afalg_cipher_decrypt(QCryptoCipher *cipher,
|
|||||||
const void *in, void *out,
|
const void *in, void *out,
|
||||||
size_t len, Error **errp)
|
size_t len, Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
|
QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
|
||||||
|
|
||||||
return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp);
|
return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher)
|
static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
|
QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
|
||||||
|
|
||||||
qcrypto_afalg_comm_free(afalg);
|
qcrypto_afalg_comm_free(afalg);
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,12 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg,
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QCryptoAFAlg *
|
static QCryptoAFAlgo *
|
||||||
qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg,
|
qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg,
|
||||||
const uint8_t *key, size_t nkey,
|
const uint8_t *key, size_t nkey,
|
||||||
bool is_hmac, Error **errp)
|
bool is_hmac, Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg;
|
QCryptoAFAlgo *afalg;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = qcrypto_afalg_hash_format_name(alg, is_hmac, errp);
|
name = qcrypto_afalg_hash_format_name(alg, is_hmac, errp);
|
||||||
@ -98,14 +98,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg,
|
|||||||
return afalg;
|
return afalg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QCryptoAFAlg *
|
static QCryptoAFAlgo *
|
||||||
qcrypto_afalg_hash_ctx_new(QCryptoHashAlgo alg,
|
qcrypto_afalg_hash_ctx_new(QCryptoHashAlgo alg,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
return qcrypto_afalg_hash_hmac_ctx_new(alg, NULL, 0, false, errp);
|
return qcrypto_afalg_hash_hmac_ctx_new(alg, NULL, 0, false, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
QCryptoAFAlg *
|
QCryptoAFAlgo *
|
||||||
qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
|
qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
|
||||||
const uint8_t *key, size_t nkey,
|
const uint8_t *key, size_t nkey,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
@ -114,14 +114,14 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac,
|
qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlgo *hmac,
|
||||||
QCryptoHashAlgo alg,
|
QCryptoHashAlgo alg,
|
||||||
const struct iovec *iov,
|
const struct iovec *iov,
|
||||||
size_t niov, uint8_t **result,
|
size_t niov, uint8_t **result,
|
||||||
size_t *resultlen,
|
size_t *resultlen,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg;
|
QCryptoAFAlgo *afalg;
|
||||||
struct iovec outv;
|
struct iovec outv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
bool is_hmac = (hmac != NULL) ? true : false;
|
bool is_hmac = (hmac != NULL) ? true : false;
|
||||||
@ -197,7 +197,7 @@ qcrypto_afalg_hmac_bytesv(QCryptoHmac *hmac,
|
|||||||
|
|
||||||
static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *hmac)
|
static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *hmac)
|
||||||
{
|
{
|
||||||
QCryptoAFAlg *afalg;
|
QCryptoAFAlgo *afalg;
|
||||||
|
|
||||||
afalg = hmac->opaque;
|
afalg = hmac->opaque;
|
||||||
qcrypto_afalg_comm_free(afalg);
|
qcrypto_afalg_comm_free(afalg);
|
||||||
|
@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver;
|
|||||||
|
|
||||||
#include "afalgpriv.h"
|
#include "afalgpriv.h"
|
||||||
|
|
||||||
QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
|
QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
|
||||||
const uint8_t *key, size_t nkey,
|
const uint8_t *key, size_t nkey,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
extern QCryptoHmacDriver qcrypto_hmac_afalg_driver;
|
extern QCryptoHmacDriver qcrypto_hmac_afalg_driver;
|
||||||
|
Loading…
Reference in New Issue
Block a user