The class vtable should be set by the class initializer.
This will also allow additional subclassing, reducing the
amount of indirection in the hierarchy.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
return name;
}
+static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver;
+
QCryptoCipher *
qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg,
QCryptoCipherMode mode,
}
afalg->cmsg = CMSG_FIRSTHDR(afalg->msg);
+ afalg->base.driver = &qcrypto_cipher_afalg_driver;
return &afalg->base;
}
qcrypto_afalg_comm_free(afalg);
}
-const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver = {
+static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver = {
.cipher_encrypt = qcrypto_afalg_cipher_encrypt,
.cipher_decrypt = qcrypto_afalg_cipher_decrypt,
.cipher_setiv = qcrypto_afalg_cipher_setiv,
#include "crypto/desrfb.h"
#include "crypto/xts.h"
+static const struct QCryptoCipherDriver qcrypto_cipher_lib_driver;
+
typedef struct QCryptoCipherBuiltinAESContext QCryptoCipherBuiltinAESContext;
struct QCryptoCipherBuiltinAESContext {
AES_KEY enc;
ctxt->encrypt = qcrypto_cipher_encrypt_aes;
ctxt->decrypt = qcrypto_cipher_decrypt_aes;
+ ctxt->base.driver = &qcrypto_cipher_lib_driver;
return &ctxt->base;
error:
ctxt->encrypt = qcrypto_cipher_encrypt_des_rfb;
ctxt->decrypt = qcrypto_cipher_decrypt_des_rfb;
+ ctxt->base.driver = &qcrypto_cipher_lib_driver;
return &ctxt->base;
}
#include <gcrypt.h>
+static const struct QCryptoCipherDriver qcrypto_cipher_lib_driver;
bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
QCryptoCipherMode mode)
}
#endif
+ ctx->base.driver = &qcrypto_cipher_lib_driver;
return &ctx->base;
error:
#include <nettle/xts.h>
#endif
+static const struct QCryptoCipherDriver qcrypto_cipher_lib_driver;
+
typedef void (*QCryptoCipherNettleFuncWrapper)(const void *ctx,
size_t length,
uint8_t *dst,
ctx->iv = g_new0(uint8_t, ctx->blocksize);
+ ctx->base.driver = &qcrypto_cipher_lib_driver;
return &ctx->base;
error:
Error **errp)
{
QCryptoCipher *cipher = NULL;
- const QCryptoCipherDriver *drv = NULL;
#ifdef CONFIG_AF_ALG
cipher = qcrypto_afalg_cipher_ctx_new(alg, mode, key, nkey, NULL);
- if (cipher) {
- drv = &qcrypto_cipher_afalg_driver;
- }
#endif
if (!cipher) {
if (!cipher) {
return NULL;
}
-
- drv = &qcrypto_cipher_lib_driver;
}
cipher->alg = alg;
cipher->mode = mode;
- cipher->driver = drv;
return cipher;
}
const uint8_t *key,
size_t nkey, Error **errp);
-extern const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver;
-
#endif
#endif