qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix
QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoAkCipherAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_AKCIPHER_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_AK_CIPHER_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoAkCipherAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoAkCipherAlgo instead. The prefix becomes QCRYPTO_AK_CIPHER_ALGO. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20240904111836.3273842-15-armbru@redhat.com>
This commit is contained in:
parent
5e0e510246
commit
cd48d82a50
@ -64,7 +64,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend *backend)
|
|||||||
{
|
{
|
||||||
QCryptoAkCipherOptions opts;
|
QCryptoAkCipherOptions opts;
|
||||||
|
|
||||||
opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
|
opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
|
||||||
opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
|
opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
|
||||||
if (qcrypto_akcipher_supports(&opts)) {
|
if (qcrypto_akcipher_supports(&opts)) {
|
||||||
backend->conf.crypto_services |=
|
backend->conf.crypto_services |=
|
||||||
@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session(
|
|||||||
|
|
||||||
switch (sess_info->algo) {
|
switch (sess_info->algo) {
|
||||||
case VIRTIO_CRYPTO_AKCIPHER_RSA:
|
case VIRTIO_CRYPTO_AKCIPHER_RSA:
|
||||||
opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
|
opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
|
||||||
if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_algo,
|
if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_algo,
|
||||||
sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) != 0) {
|
sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -133,7 +133,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
QCryptoAkCipherOptionsRSA *rsa_opt;
|
QCryptoAkCipherOptionsRSA *rsa_opt;
|
||||||
if (opts->alg != QCRYPTO_AKCIPHER_ALG_RSA) {
|
if (opts->alg != QCRYPTO_AK_CIPHER_ALGO_RSA) {
|
||||||
error_setg(errp, "Unsupported alg: %u", opts->alg);
|
error_setg(errp, "Unsupported alg: %u", opts->alg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -518,7 +518,7 @@ static int cryptodev_lkcf_create_asym_session(
|
|||||||
|
|
||||||
switch (sess_info->algo) {
|
switch (sess_info->algo) {
|
||||||
case VIRTIO_CRYPTO_AKCIPHER_RSA:
|
case VIRTIO_CRYPTO_AKCIPHER_RSA:
|
||||||
sess->akcipher_opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
|
sess->akcipher_opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
|
||||||
if (cryptodev_lkcf_set_rsa_opt(
|
if (cryptodev_lkcf_set_rsa_opt(
|
||||||
sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo,
|
sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo,
|
||||||
&sess->akcipher_opts.u.rsa, &local_error) != 0) {
|
&sess->akcipher_opts.u.rsa, &local_error) != 0) {
|
||||||
|
@ -59,7 +59,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCipherOptions *opts,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
switch (opts->alg) {
|
switch (opts->alg) {
|
||||||
case QCRYPTO_AKCIPHER_ALG_RSA:
|
case QCRYPTO_AK_CIPHER_ALGO_RSA:
|
||||||
return (QCryptoAkCipher *)qcrypto_gcrypt_rsa_new(
|
return (QCryptoAkCipher *)qcrypto_gcrypt_rsa_new(
|
||||||
&opts->u.rsa, type, key, keylen, errp);
|
&opts->u.rsa, type, key, keylen, errp);
|
||||||
|
|
||||||
@ -568,7 +568,7 @@ error:
|
|||||||
bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts)
|
bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts)
|
||||||
{
|
{
|
||||||
switch (opts->alg) {
|
switch (opts->alg) {
|
||||||
case QCRYPTO_AKCIPHER_ALG_RSA:
|
case QCRYPTO_AK_CIPHER_ALGO_RSA:
|
||||||
switch (opts->u.rsa.padding_alg) {
|
switch (opts->u.rsa.padding_alg) {
|
||||||
case QCRYPTO_RSA_PADDING_ALG_RAW:
|
case QCRYPTO_RSA_PADDING_ALG_RAW:
|
||||||
return true;
|
return true;
|
||||||
|
@ -61,7 +61,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCipherOptions *opts,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
switch (opts->alg) {
|
switch (opts->alg) {
|
||||||
case QCRYPTO_AKCIPHER_ALG_RSA:
|
case QCRYPTO_AK_CIPHER_ALGO_RSA:
|
||||||
return qcrypto_nettle_rsa_new(&opts->u.rsa, type, key, keylen, errp);
|
return qcrypto_nettle_rsa_new(&opts->u.rsa, type, key, keylen, errp);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -425,7 +425,7 @@ error:
|
|||||||
bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts)
|
bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts)
|
||||||
{
|
{
|
||||||
switch (opts->alg) {
|
switch (opts->alg) {
|
||||||
case QCRYPTO_AKCIPHER_ALG_RSA:
|
case QCRYPTO_AK_CIPHER_ALGO_RSA:
|
||||||
switch (opts->u.rsa.padding_alg) {
|
switch (opts->u.rsa.padding_alg) {
|
||||||
case QCRYPTO_RSA_PADDING_ALG_PKCS1:
|
case QCRYPTO_RSA_PADDING_ALG_PKCS1:
|
||||||
switch (opts->u.rsa.hash_alg) {
|
switch (opts->u.rsa.hash_alg) {
|
||||||
|
@ -115,7 +115,7 @@ int qcrypto_akcipher_export_p8info(const QCryptoAkCipherOptions *opts,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
switch (opts->alg) {
|
switch (opts->alg) {
|
||||||
case QCRYPTO_AKCIPHER_ALG_RSA:
|
case QCRYPTO_AK_CIPHER_ALGO_RSA:
|
||||||
qcrypto_akcipher_rsakey_export_p8info(key, keylen, dst, dst_len);
|
qcrypto_akcipher_rsakey_export_p8info(key, keylen, dst, dst_len);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver;
|
typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver;
|
||||||
|
|
||||||
struct QCryptoAkCipher {
|
struct QCryptoAkCipher {
|
||||||
QCryptoAkCipherAlgorithm alg;
|
QCryptoAkCipherAlgo alg;
|
||||||
QCryptoAkCipherKeyType type;
|
QCryptoAkCipherKeyType type;
|
||||||
int max_plaintext_len;
|
int max_plaintext_len;
|
||||||
int max_ciphertext_len;
|
int max_ciphertext_len;
|
||||||
|
@ -586,7 +586,7 @@
|
|||||||
'*sanity-check': 'bool',
|
'*sanity-check': 'bool',
|
||||||
'*passwordid': 'str' } }
|
'*passwordid': 'str' } }
|
||||||
##
|
##
|
||||||
# @QCryptoAkCipherAlgorithm:
|
# @QCryptoAkCipherAlgo:
|
||||||
#
|
#
|
||||||
# The supported algorithms for asymmetric encryption ciphers
|
# The supported algorithms for asymmetric encryption ciphers
|
||||||
#
|
#
|
||||||
@ -594,8 +594,7 @@
|
|||||||
#
|
#
|
||||||
# Since: 7.1
|
# Since: 7.1
|
||||||
##
|
##
|
||||||
{ 'enum': 'QCryptoAkCipherAlgorithm',
|
{ 'enum': 'QCryptoAkCipherAlgo',
|
||||||
'prefix': 'QCRYPTO_AKCIPHER_ALG',
|
|
||||||
'data': ['rsa']}
|
'data': ['rsa']}
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -649,6 +648,6 @@
|
|||||||
# Since: 7.1
|
# Since: 7.1
|
||||||
##
|
##
|
||||||
{ 'union': 'QCryptoAkCipherOptions',
|
{ 'union': 'QCryptoAkCipherOptions',
|
||||||
'base': { 'alg': 'QCryptoAkCipherAlgorithm' },
|
'base': { 'alg': 'QCryptoAkCipherAlgo' },
|
||||||
'discriminator': 'alg',
|
'discriminator': 'alg',
|
||||||
'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }}
|
'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }}
|
||||||
|
@ -25,7 +25,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key,
|
|||||||
{
|
{
|
||||||
QCryptoAkCipherOptions opt;
|
QCryptoAkCipherOptions opt;
|
||||||
|
|
||||||
opt.alg = QCRYPTO_AKCIPHER_ALG_RSA;
|
opt.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
|
||||||
opt.u.rsa.padding_alg = padding;
|
opt.u.rsa.padding_alg = padding;
|
||||||
opt.u.rsa.hash_alg = hash;
|
opt.u.rsa.hash_alg = hash;
|
||||||
return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
|
return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
|
||||||
|
@ -785,7 +785,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
|
|||||||
{
|
{
|
||||||
.path = "/crypto/akcipher/rsa1024-raw",
|
.path = "/crypto/akcipher/rsa1024-raw",
|
||||||
.opt = {
|
.opt = {
|
||||||
.alg = QCRYPTO_AKCIPHER_ALG_RSA,
|
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
|
||||||
.u.rsa = {
|
.u.rsa = {
|
||||||
.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
|
.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
|
||||||
},
|
},
|
||||||
@ -805,7 +805,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
|
|||||||
{
|
{
|
||||||
.path = "/crypto/akcipher/rsa1024-pkcs1",
|
.path = "/crypto/akcipher/rsa1024-pkcs1",
|
||||||
.opt = {
|
.opt = {
|
||||||
.alg = QCRYPTO_AKCIPHER_ALG_RSA,
|
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
|
||||||
.u.rsa = {
|
.u.rsa = {
|
||||||
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
|
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
|
||||||
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
|
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
|
||||||
@ -830,7 +830,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
|
|||||||
{
|
{
|
||||||
.path = "/crypto/akcipher/rsa2048-raw",
|
.path = "/crypto/akcipher/rsa2048-raw",
|
||||||
.opt = {
|
.opt = {
|
||||||
.alg = QCRYPTO_AKCIPHER_ALG_RSA,
|
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
|
||||||
.u.rsa = {
|
.u.rsa = {
|
||||||
.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
|
.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
|
||||||
},
|
},
|
||||||
@ -850,7 +850,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
|
|||||||
{
|
{
|
||||||
.path = "/crypto/akcipher/rsa2048-pkcs1",
|
.path = "/crypto/akcipher/rsa2048-pkcs1",
|
||||||
.opt = {
|
.opt = {
|
||||||
.alg = QCRYPTO_AKCIPHER_ALG_RSA,
|
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
|
||||||
.u.rsa = {
|
.u.rsa = {
|
||||||
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
|
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
|
||||||
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
|
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
|
||||||
@ -944,7 +944,7 @@ static void test_rsakey(const void *opaque)
|
|||||||
{
|
{
|
||||||
const QCryptoRSAKeyTestData *data = (const QCryptoRSAKeyTestData *)opaque;
|
const QCryptoRSAKeyTestData *data = (const QCryptoRSAKeyTestData *)opaque;
|
||||||
QCryptoAkCipherOptions opt = {
|
QCryptoAkCipherOptions opt = {
|
||||||
.alg = QCRYPTO_AKCIPHER_ALG_RSA,
|
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
|
||||||
.u.rsa = {
|
.u.rsa = {
|
||||||
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
|
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
|
||||||
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
|
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
|
||||||
|
Loading…
Reference in New Issue
Block a user