Add ossl_siv symbols
Partial fix for #12964
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14473)
diff --git a/crypto/modes/siv128.c b/crypto/modes/siv128.c
index c8bfdb0..3e94d0e 100644
--- a/crypto/modes/siv128.c
+++ b/crypto/modes/siv128.c
@@ -140,7 +140,7 @@
/*
* Create a new SIV128_CONTEXT
*/
-SIV128_CONTEXT *CRYPTO_siv128_new(const unsigned char *key, int klen,
+SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen,
EVP_CIPHER *cbc, EVP_CIPHER *ctr,
OSSL_LIB_CTX *libctx, const char *propq)
{
@@ -148,7 +148,7 @@
int ret;
if ((ctx = OPENSSL_malloc(sizeof(*ctx))) != NULL) {
- ret = CRYPTO_siv128_init(ctx, key, klen, cbc, ctr, libctx, propq);
+ ret = ossl_siv128_init(ctx, key, klen, cbc, ctr, libctx, propq);
if (ret)
return ctx;
OPENSSL_free(ctx);
@@ -160,7 +160,7 @@
/*
* Initialise an existing SIV128_CONTEXT
*/
-int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
+int ossl_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
const EVP_CIPHER *cbc, const EVP_CIPHER *ctr,
OSSL_LIB_CTX *libctx, const char *propq)
{
@@ -218,7 +218,7 @@
/*
* Copy an SIV128_CONTEXT object
*/
-int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src)
+int ossl_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src)
{
memcpy(&dest->d, &src->d, sizeof(src->d));
if (dest->cipher_ctx == NULL) {
@@ -243,7 +243,7 @@
* Per RFC5297, the last piece of associated data
* is the nonce, but it's not treated special
*/
-int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
+int ossl_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
size_t len)
{
SIV_BLOCK mac_out;
@@ -270,7 +270,7 @@
/*
* Provide any data to be encrypted. This can be called once.
*/
-int CRYPTO_siv128_encrypt(SIV128_CONTEXT *ctx,
+int ossl_siv128_encrypt(SIV128_CONTEXT *ctx,
const unsigned char *in, unsigned char *out,
size_t len)
{
@@ -297,7 +297,7 @@
/*
* Provide any data to be decrypted. This can be called once.
*/
-int CRYPTO_siv128_decrypt(SIV128_CONTEXT *ctx,
+int ossl_siv128_decrypt(SIV128_CONTEXT *ctx,
const unsigned char *in, unsigned char *out,
size_t len)
{
@@ -333,7 +333,7 @@
/*
* Return the already calculated final result.
*/
-int CRYPTO_siv128_finish(SIV128_CONTEXT *ctx)
+int ossl_siv128_finish(SIV128_CONTEXT *ctx)
{
return ctx->final_ret;
}
@@ -341,7 +341,7 @@
/*
* Set the tag
*/
-int CRYPTO_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag, size_t len)
+int ossl_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag, size_t len)
{
if (len != SIV_LEN)
return 0;
@@ -354,7 +354,7 @@
/*
* Retrieve the calculated tag
*/
-int CRYPTO_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len)
+int ossl_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len)
{
if (len != SIV_LEN)
return 0;
@@ -367,7 +367,7 @@
/*
* Release all resources
*/
-int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx)
+int ossl_siv128_cleanup(SIV128_CONTEXT *ctx)
{
if (ctx != NULL) {
EVP_CIPHER_CTX_free(ctx->cipher_ctx);
@@ -384,7 +384,7 @@
return 1;
}
-int CRYPTO_siv128_speed(SIV128_CONTEXT *ctx, int arg)
+int ossl_siv128_speed(SIV128_CONTEXT *ctx, int arg)
{
ctx->crypto_ok = (arg == 1) ? -1 : 1;
return 1;
diff --git a/include/crypto/siv.h b/include/crypto/siv.h
index 52560e7..ff27fe8 100644
--- a/include/crypto/siv.h
+++ b/include/crypto/siv.h
@@ -11,26 +11,23 @@
typedef struct siv128_context SIV128_CONTEXT;
-SIV128_CONTEXT *CRYPTO_siv128_new(const unsigned char *key, int klen,
- EVP_CIPHER *cbc, EVP_CIPHER *ctr,
- OSSL_LIB_CTX *libctx, const char *propq);
-int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
- const EVP_CIPHER *cbc, const EVP_CIPHER *ctr,
- OSSL_LIB_CTX *libctx, const char *propq);
-int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src);
-int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
- size_t len);
-int CRYPTO_siv128_encrypt(SIV128_CONTEXT *ctx,
- const unsigned char *in, unsigned char *out,
- size_t len);
-int CRYPTO_siv128_decrypt(SIV128_CONTEXT *ctx,
- const unsigned char *in, unsigned char *out,
- size_t len);
-int CRYPTO_siv128_finish(SIV128_CONTEXT *ctx);
-int CRYPTO_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag,
- size_t len);
-int CRYPTO_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len);
-int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx);
-int CRYPTO_siv128_speed(SIV128_CONTEXT *ctx, int arg);
+SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen,
+ EVP_CIPHER *cbc, EVP_CIPHER *ctr,
+ OSSL_LIB_CTX *libctx, const char *propq);
+int ossl_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
+ const EVP_CIPHER *cbc, const EVP_CIPHER *ctr,
+ OSSL_LIB_CTX *libctx, const char *propq);
+int ossl_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src);
+int ossl_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad, size_t len);
+int ossl_siv128_encrypt(SIV128_CONTEXT *ctx,
+ const unsigned char *in, unsigned char *out, size_t len);
+int ossl_siv128_decrypt(SIV128_CONTEXT *ctx,
+ const unsigned char *in, unsigned char *out, size_t len);
+int ossl_siv128_finish(SIV128_CONTEXT *ctx);
+int ossl_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag,
+ size_t len);
+int ossl_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len);
+int ossl_siv128_cleanup(SIV128_CONTEXT *ctx);
+int ossl_siv128_speed(SIV128_CONTEXT *ctx, int arg);
#endif /* OPENSSL_NO_SIV */
diff --git a/providers/implementations/ciphers/cipher_aes_siv_hw.c b/providers/implementations/ciphers/cipher_aes_siv_hw.c
index f4ad663..5b2128a 100644
--- a/providers/implementations/ciphers/cipher_aes_siv_hw.c
+++ b/providers/implementations/ciphers/cipher_aes_siv_hw.c
@@ -52,7 +52,7 @@
* klen is the length of the underlying cipher, not the input key,
* which should be twice as long
*/
- return CRYPTO_siv128_init(sctx, key, klen, ctx->cbc, ctx->ctr, libctx,
+ return ossl_siv128_init(sctx, key, klen, ctx->cbc, ctx->ctr, libctx,
propq);
}
@@ -65,7 +65,7 @@
out->siv.cipher_ctx = NULL;
out->siv.mac_ctx_init = NULL;
out->siv.mac = NULL;
- if (!CRYPTO_siv128_copy_ctx(&out->siv, &in->siv))
+ if (!ossl_siv128_copy_ctx(&out->siv, &in->siv))
return 0;
if (out->cbc != NULL)
EVP_CIPHER_up_ref(out->cbc);
@@ -79,7 +79,7 @@
PROV_AES_SIV_CTX *ctx = (PROV_AES_SIV_CTX *)vctx;
SIV128_CONTEXT *sctx = &ctx->siv;
- return CRYPTO_siv128_set_tag(sctx, tag, tagl);
+ return ossl_siv128_set_tag(sctx, tag, tagl);
}
static void aes_siv_setspeed(void *vctx, int speed)
@@ -87,7 +87,7 @@
PROV_AES_SIV_CTX *ctx = (PROV_AES_SIV_CTX *)vctx;
SIV128_CONTEXT *sctx = &ctx->siv;
- CRYPTO_siv128_speed(sctx, (int)speed);
+ ossl_siv128_speed(sctx, (int)speed);
}
static void aes_siv_cleanup(void *vctx)
@@ -95,7 +95,7 @@
PROV_AES_SIV_CTX *ctx = (PROV_AES_SIV_CTX *)vctx;
SIV128_CONTEXT *sctx = &ctx->siv;
- CRYPTO_siv128_cleanup(sctx);
+ ossl_siv128_cleanup(sctx);
EVP_CIPHER_free(ctx->cbc);
EVP_CIPHER_free(ctx->ctr);
}
@@ -108,16 +108,16 @@
/* EncryptFinal or DecryptFinal */
if (in == NULL)
- return CRYPTO_siv128_finish(sctx) == 0;
+ return ossl_siv128_finish(sctx) == 0;
/* Deal with associated data */
if (out == NULL)
- return (CRYPTO_siv128_aad(sctx, in, len) == 1);
+ return (ossl_siv128_aad(sctx, in, len) == 1);
if (ctx->enc)
- return CRYPTO_siv128_encrypt(sctx, in, out, len) > 0;
+ return ossl_siv128_encrypt(sctx, in, out, len) > 0;
- return CRYPTO_siv128_decrypt(sctx, in, out, len) > 0;
+ return ossl_siv128_decrypt(sctx, in, out, len) > 0;
}
static const PROV_CIPHER_HW_AES_SIV aes_siv_hw =