#else
EC_KEY *lk;
BIGNUM *bn_sec, *kinv = NULL, *rp = NULL;
- EVP_MD_CTX sha_ctx;
+ EVP_MD_CTX *sha_ctx;
unsigned char h[64];
guint diglen = rspamd_cryptobox_signature_bytes (mode);
/* Prehash */
- g_assert (EVP_DigestInit (&sha_ctx, EVP_sha512()) == 1);
- EVP_DigestUpdate (&sha_ctx, m, mlen);
- EVP_DigestFinal (&sha_ctx, h, NULL);
+ sha_ctx = EVP_MD_CTX_create ();
+ g_assert (EVP_DigestInit (sha_ctx, EVP_sha512()) == 1);
+ EVP_DigestUpdate (sha_ctx, m, mlen);
+ EVP_DigestFinal (sha_ctx, h, NULL);
/* Key setup */
lk = EC_KEY_new_by_curve_name (CRYPTOBOX_CURVE_NID);
g_assert (diglen <= sizeof (rspamd_signature_t));
EC_KEY_free (lk);
+ EVP_MD_CTX_destroy (sha_ctx);
BN_free (bn_sec);
BN_free (kinv);
BN_free (rp);
EC_KEY *lk;
EC_POINT *ec_pub;
BIGNUM *bn_pub;
- EVP_MD_CTX sha_ctx;
+ EVP_MD_CTX *sha_ctx;
unsigned char h[64];
/* Prehash */
- g_assert (EVP_DigestInit (&sha_ctx, EVP_sha512()) == 1);
- EVP_DigestUpdate (&sha_ctx, m, mlen);
- EVP_DigestFinal (&sha_ctx, h, NULL);
+ sha_ctx = EVP_MD_CTX_create ();
+ g_assert (EVP_DigestInit (sha_ctx, EVP_sha512()) == 1);
+ EVP_DigestUpdate (sha_ctx, m, mlen);
+ EVP_DigestFinal (sha_ctx, h, NULL);
/* Key setup */
lk = EC_KEY_new_by_curve_name (CRYPTOBOX_CURVE_NID);
rspamd_cryptobox_signature_bytes (mode), lk) == 1;
EC_KEY_free (lk);
+ EVP_MD_CTX_destroy (sha_ctx);
BN_free (bn_pub);
EC_POINT_free (ec_pub);
#endif
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s;
+ EVP_CIPHER_CTX **s;
s = cryptobox_align_ptr (enc_ctx, CRYPTOBOX_ALIGNMENT);
memset (s, 0, sizeof (*s));
- g_assert (EVP_EncryptInit_ex (s, EVP_aes_256_gcm (), NULL, NULL, NULL) == 1);
- g_assert (EVP_CIPHER_CTX_ctrl (s, EVP_CTRL_GCM_SET_IVLEN,
+ *s = EVP_CIPHER_CTX_new ();
+ g_assert (EVP_EncryptInit_ex (*s, EVP_aes_256_gcm (), NULL, NULL, NULL) == 1);
+ g_assert (EVP_CIPHER_CTX_ctrl (*s, EVP_CTRL_GCM_SET_IVLEN,
rspamd_cryptobox_nonce_bytes (mode), NULL) == 1);
- g_assert (EVP_EncryptInit_ex (s, NULL, NULL, nm, nonce) == 1);
+ g_assert (EVP_EncryptInit_ex (*s, NULL, NULL, nm, nonce) == 1);
return s;
#endif
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = enc_ctx;
+ EVP_CIPHER_CTX **s = enc_ctx;
gint r;
r = inlen;
- g_assert (EVP_EncryptUpdate (s, out, &r, in, inlen) == 1);
+ g_assert (EVP_EncryptUpdate (*s, out, &r, in, inlen) == 1);
if (outlen) {
*outlen = r;
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = enc_ctx;
+ EVP_CIPHER_CTX **s = enc_ctx;
gint r = remain;
- g_assert (EVP_EncryptFinal_ex (s, out, &r) == 1);
+ g_assert (EVP_EncryptFinal_ex (*s, out, &r) == 1);
return r;
#endif
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = auth_ctx;
+ EVP_CIPHER_CTX **s = auth_ctx;
- g_assert (EVP_CIPHER_CTX_ctrl (s, EVP_CTRL_GCM_GET_TAG,
+ g_assert (EVP_CIPHER_CTX_ctrl (*s, EVP_CTRL_GCM_GET_TAG,
sizeof (rspamd_mac_t), sig) == 1);
return TRUE;
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s;
+ EVP_CIPHER_CTX **s;
s = cryptobox_align_ptr (enc_ctx, CRYPTOBOX_ALIGNMENT);
memset (s, 0, sizeof (*s));
- g_assert (EVP_DecryptInit_ex(s, EVP_aes_256_gcm (), NULL, NULL, NULL) == 1);
- g_assert (EVP_CIPHER_CTX_ctrl (s, EVP_CTRL_GCM_SET_IVLEN,
+ *s = EVP_CIPHER_CTX_new ();
+ g_assert (EVP_DecryptInit_ex(*s, EVP_aes_256_gcm (), NULL, NULL, NULL) == 1);
+ g_assert (EVP_CIPHER_CTX_ctrl (*s, EVP_CTRL_GCM_SET_IVLEN,
rspamd_cryptobox_nonce_bytes (mode), NULL) == 1);
- g_assert (EVP_DecryptInit_ex (s, NULL, NULL, nm, nonce) == 1);
+ g_assert (EVP_DecryptInit_ex (*s, NULL, NULL, nm, nonce) == 1);
return s;
#endif
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = enc_ctx;
+ EVP_CIPHER_CTX **s = enc_ctx;
gint r;
r = outlen ? *outlen : inlen;
- g_assert (EVP_DecryptUpdate (s, out, &r, in, inlen) == 1);
+ g_assert (EVP_DecryptUpdate (*s, out, &r, in, inlen) == 1);
if (outlen) {
*outlen = r;
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = enc_ctx;
+ EVP_CIPHER_CTX **s = enc_ctx;
gint r = remain;
- if (EVP_DecryptFinal_ex (s, out, &r) < 0) {
+ if (EVP_DecryptFinal_ex (*s, out, &r) < 0) {
return FALSE;
}
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = auth_ctx;
+ EVP_CIPHER_CTX **s = auth_ctx;
- if (EVP_CIPHER_CTX_ctrl (s, EVP_CTRL_GCM_SET_TAG, 16, (guchar *)sig) != 1) {
+ if (EVP_CIPHER_CTX_ctrl (*s, EVP_CTRL_GCM_SET_TAG, 16, (guchar *)sig) != 1) {
return FALSE;
}
#ifndef HAVE_USABLE_OPENSSL
g_assert (0);
#else
- EVP_CIPHER_CTX *s = enc_ctx;
+ EVP_CIPHER_CTX **s = enc_ctx;
- EVP_CIPHER_CTX_cleanup (s);
+ EVP_CIPHER_CTX_cleanup (*s);
+ EVP_CIPHER_CTX_free (*s);
#endif
}
}