mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
openssl: adapt to OpenSSL 1.1.0 opaque structs
* ext/openssl/extconf.rb: Check existence of accessor functions that don't exist in OpenSSL 0.9.8. OpenSSL 1.1.0 made most of its structures opaque and requires use of these accessor functions. [ruby-core:75225] [Feature #12324] * ext/openssl/openssl_missing.[ch]: Implement them if missing. * ext/openssl/ossl*.c: Use these accessor functions. * test/openssl/test_hmac.rb: Add missing test for HMAC#reset. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5df1a31c06
commit
0a523ab20d
23 changed files with 458 additions and 172 deletions
|
@ -20,6 +20,30 @@
|
|||
|
||||
#include "openssl_missing.h"
|
||||
|
||||
/* added in 0.9.8X */
|
||||
#if !defined(HAVE_EVP_CIPHER_CTX_NEW)
|
||||
EVP_CIPHER_CTX *
|
||||
EVP_CIPHER_CTX_new(void)
|
||||
{
|
||||
EVP_CIPHER_CTX *ctx = OPENSSL_malloc(sizeof(EVP_CIPHER_CTX));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
EVP_CIPHER_CTX_init(ctx);
|
||||
return ctx;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_EVP_CIPHER_CTX_FREE)
|
||||
void
|
||||
EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
|
||||
{
|
||||
if (ctx) {
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* added in 1.0.0 */
|
||||
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
|
||||
/*
|
||||
|
@ -46,15 +70,19 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
|
|||
|
||||
#if !defined(OPENSSL_NO_HMAC)
|
||||
#if !defined(HAVE_HMAC_CTX_COPY)
|
||||
void
|
||||
int
|
||||
HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
|
||||
{
|
||||
if (!out || !in) return;
|
||||
if (!out || !in)
|
||||
return 0;
|
||||
|
||||
memcpy(out, in, sizeof(HMAC_CTX));
|
||||
|
||||
EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
|
||||
EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
|
||||
EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* HAVE_HMAC_CTX_COPY */
|
||||
#endif /* NO_HMAC */
|
||||
|
@ -95,3 +123,49 @@ EC_curve_nist2nid(const char *name)
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*** added in 1.1.0 ***/
|
||||
#if !defined(HAVE_HMAC_CTX_NEW)
|
||||
HMAC_CTX *
|
||||
HMAC_CTX_new(void)
|
||||
{
|
||||
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
HMAC_CTX_init(ctx);
|
||||
return ctx;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_HMAC_CTX_FREE)
|
||||
void
|
||||
HMAC_CTX_free(HMAC_CTX *ctx)
|
||||
{
|
||||
if (ctx) {
|
||||
HMAC_CTX_cleanup(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
|
||||
void
|
||||
X509_CRL_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, X509_CRL *crl)
|
||||
{
|
||||
if (psig != NULL)
|
||||
*psig = crl->signature;
|
||||
if (palg != NULL)
|
||||
*palg = crl->sig_alg;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_X509_REQ_GET0_SIGNATURE)
|
||||
void
|
||||
X509_REQ_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, X509_REQ *req)
|
||||
{
|
||||
if (psig != NULL)
|
||||
*psig = req->signature;
|
||||
if (palg != NULL)
|
||||
*palg = req->sig_alg;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue