mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
dh: Add compat function for openssl < 1.1.0
Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
33399e52f0
commit
33ad6bc54e
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "openssl/crypto.h"
|
#include "openssl/crypto.h"
|
||||||
#include "openssl/dh.h"
|
#include "openssl/dh.h"
|
||||||
|
#include "libcrypto-compat.h"
|
||||||
|
|
||||||
extern bignum ssh_dh_generator;
|
extern bignum ssh_dh_generator;
|
||||||
extern bignum ssh_dh_group1;
|
extern bignum ssh_dh_group1;
|
||||||
|
|||||||
@@ -335,3 +335,62 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
|
|||||||
OPENSSL_free(ctx);
|
OPENSSL_free(ctx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void DH_get0_pqg(const DH *dh,
|
||||||
|
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
|
||||||
|
{
|
||||||
|
if (p) {
|
||||||
|
*p = dh->p;
|
||||||
|
}
|
||||||
|
if (q) {
|
||||||
|
*q = NULL;
|
||||||
|
}
|
||||||
|
if (g) {
|
||||||
|
*g = dh->g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
|
||||||
|
{
|
||||||
|
if (p) {
|
||||||
|
if (dh->p) {
|
||||||
|
BN_free(dh->p);
|
||||||
|
}
|
||||||
|
dh->p = p;
|
||||||
|
}
|
||||||
|
if (g) {
|
||||||
|
if (dh->g) {
|
||||||
|
BN_free(dh->g);
|
||||||
|
}
|
||||||
|
dh->g = g;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DH_get0_key(const DH *dh,
|
||||||
|
const BIGNUM **pub_key, const BIGNUM **priv_key)
|
||||||
|
{
|
||||||
|
if (pub_key) {
|
||||||
|
*pub_key = dh->pub_key;
|
||||||
|
}
|
||||||
|
if (priv_key) {
|
||||||
|
*priv_key = dh->priv_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
|
||||||
|
{
|
||||||
|
if (pub_key) {
|
||||||
|
if (dh->pub_key) {
|
||||||
|
BN_free(dh->pub_key);
|
||||||
|
}
|
||||||
|
dh->pub_key = pub_key;
|
||||||
|
}
|
||||||
|
if (priv_key) {
|
||||||
|
if (dh->priv_key) {
|
||||||
|
BN_free(dh->priv_key);
|
||||||
|
}
|
||||||
|
dh->priv_key = priv_key;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ HMAC_CTX *HMAC_CTX_new(void);
|
|||||||
int HMAC_CTX_reset(HMAC_CTX *ctx);
|
int HMAC_CTX_reset(HMAC_CTX *ctx);
|
||||||
void HMAC_CTX_free(HMAC_CTX *ctx);
|
void HMAC_CTX_free(HMAC_CTX *ctx);
|
||||||
|
|
||||||
|
void DH_get0_pqg(const DH *dh,
|
||||||
|
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
|
||||||
|
int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
|
||||||
|
void DH_get0_key(const DH *dh,
|
||||||
|
const BIGNUM **pub_key, const BIGNUM **priv_key);
|
||||||
|
int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
|
||||||
#endif /* OPENSSL_VERSION_NUMBER */
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
|
|
||||||
#endif /* LIBCRYPTO_COMPAT_H */
|
#endif /* LIBCRYPTO_COMPAT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user