diff options
Diffstat (limited to 'ext/openssl/openssl_missing.h')
-rw-r--r-- | ext/openssl/openssl_missing.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h index ce3e1ec740..94032167d1 100644 --- a/ext/openssl/openssl_missing.h +++ b/ext/openssl/openssl_missing.h @@ -29,6 +29,10 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx); #endif /*** added in 1.0.0 ***/ +#if !defined(HAVE_EVP_PKEY_BASE_ID) +# define EVP_PKEY_base_id(pkey) EVP_PKEY_type((pkey)->type) +#endif + #if !defined(HAVE_EVP_CIPHER_CTX_COPY) int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in); #endif @@ -162,6 +166,89 @@ void X509_REQ_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, X509_REQ CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_EVP_PKEY); #endif +#if !defined(HAVE_OPAQUE_OPENSSL) +#if !defined(OPENSSL_NO_RSA) +static inline RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) { return pkey->pkey.rsa; } +static inline void RSA_get0_key(RSA *rsa, BIGNUM **n, BIGNUM **e, BIGNUM **d) { + if (n) *n = rsa->n; + if (e) *e = rsa->e; + if (d) *d = rsa->d; } +static inline int RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d) { + if (!n || !e) return 0; + BN_free(rsa->n); rsa->n = n; + BN_free(rsa->e); rsa->e = e; + BN_free(rsa->d); rsa->d = d; + return 1; } +static inline void RSA_get0_factors(RSA *rsa, BIGNUM **p, BIGNUM **q) { + if (p) *p = rsa->p; + if (q) *q = rsa->q; } +static inline int RSA_set0_factors(RSA *rsa, BIGNUM *p, BIGNUM *q) { + if (!p || !q) return 0; + BN_free(rsa->p); rsa->p = p; + BN_free(rsa->q); rsa->q = q; + return 1; } +static inline void RSA_get0_crt_params(RSA *rsa, BIGNUM **dmp1, BIGNUM **dmq1, BIGNUM **iqmp) { + if (dmp1) *dmp1 = rsa->dmp1; + if (dmq1) *dmq1 = rsa->dmq1; + if (iqmp) *iqmp = rsa->iqmp; } +static inline int RSA_set0_crt_params(RSA *rsa, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) { + if (!dmp1 || !dmq1 || !iqmp) return 0; + BN_free(rsa->dmp1); rsa->dmp1 = dmp1; + BN_free(rsa->dmq1); rsa->dmq1 = dmq1; + BN_free(rsa->iqmp); rsa->iqmp = iqmp; + return 1; } +#endif /* RSA */ + +#if !defined(OPENSSL_NO_DSA) +static inline DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey) { return pkey->pkey.dsa; } +static inline void DSA_get0_key(DSA *dsa, BIGNUM **pub_key, BIGNUM **priv_key) { + if (pub_key) *pub_key = dsa->pub_key; + if (priv_key) *priv_key = dsa->priv_key; } +static inline int DSA_set0_key(DSA *dsa, BIGNUM *pub_key, BIGNUM *priv_key) { + if (!pub_key) return 0; + BN_free(dsa->pub_key); dsa->pub_key = pub_key; + BN_free(dsa->priv_key); dsa->priv_key = priv_key; + return 1; } +static inline void DSA_get0_pqg(DSA *dsa, BIGNUM **p, BIGNUM **q, BIGNUM **g) { + if (p) *p = dsa->p; + if (q) *q = dsa->q; + if (g) *g = dsa->g; } +static inline int DSA_set0_pqg(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g) { + if (!p || !q || !g) return 0; + BN_free(dsa->p); dsa->p = p; + BN_free(dsa->q); dsa->q = q; + BN_free(dsa->g); dsa->g = g; + return 1; } +#endif /* DSA */ + +#if !defined(OPENSSL_NO_DH) +static inline DH *EVP_PKEY_get0_DH(EVP_PKEY *pkey) { return pkey->pkey.dh; } +static inline ENGINE *DH_get0_engine(DH *dh) { return dh->engine; } +static inline void DH_get0_key(DH *dh, BIGNUM **pub_key, BIGNUM **priv_key) { + if (pub_key) *pub_key = dh->pub_key; + if (priv_key) *priv_key = dh->priv_key; } +static inline int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) { + if (!pub_key) return 0; + BN_free(dh->pub_key); dh->pub_key = pub_key; + BN_free(dh->priv_key); dh->priv_key = priv_key; + return 1; } +static inline void DH_get0_pqg(DH *dh, BIGNUM **p, BIGNUM **q, BIGNUM **g) { + if (p) *p = dh->p; + if (q) *q = dh->q; + if (g) *g = dh->g; } +static inline int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) { + if (!p || !g) return 0; + BN_free(dh->p); dh->p = p; + BN_free(dh->q); dh->q = q; + BN_free(dh->g); dh->g = g; + return 1; } +#endif /* DH */ + +#if !defined(OPENSSL_NO_EC) +static inline EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) { return pkey->pkey.ec; } +#endif +#endif + #if defined(__cplusplus) } #endif |