Ultima modifica:
Buongiorno, questo è un piccolo aggiornamento da eseguire a libserverkey per OpenSSL 1.0 o superiore, ho verificato che compila correttamente con OpenSSL v1.4d (Windows).
Tutti questi cambiamenti sono relativi al file libserverkey/RSACrypto.cpp
Funzione
Rimpiazzare:
con:
-------------------------------------------------------------------------------------------------
Funzione
Rimpiazzare:
con:
-------------------------------------------------------------------------------------------------
Funzione
Rimpiazzare:
con:
-------------------------------------------------------------------------------------------------
Funzione
Rimpiazzare:
con:
-------------------------------------------------------------------------------------------------
Funzione
Rimpiazzare:
con:
Rimpiazzare:
con:
-------------------------------------------------------------------------------------------------
Funzione
Rimpiazzare:
con:
Rimpiazzare:
con:
Rimpiazzare:
con:
Spiegazione dei cambiamenti:
1) Gli ifdef sono li per compatibilità con le vecchie versioni
2) OpenSSL 1.0 non espone la struttura "rsa_", quindi dobbiamo usare le nuove API di OpenSSL per prendere i dati richiesti.
Buona fortuna.
Tutti questi cambiamenti sono relativi al file libserverkey/RSACrypto.cpp
Funzione
Codice:
RSACrypto::PublicKey::PublicKey
Rimpiazzare:
Codice:
BN_hex2bn(&rsa_->n, n);
BN_hex2bn(&rsa_->e, e);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
BN_hex2bn(&rsa_->n, n);
BN_hex2bn(&rsa_->e, e);
#else
BIGNUM* rsa_n, * rsa_e, * rsa_d;
RSA_get0_key(rsa_, (const BIGNUM**)&rsa_n, (const BIGNUM**)&rsa_e, (const BIGNUM**)&rsa_d);
BN_hex2bn(&rsa_n, n);
BN_hex2bn(&rsa_e, e);
RSA_set0_key(rsa_, rsa_n, rsa_e, rsa_d);
#endif
-------------------------------------------------------------------------------------------------
Funzione
Codice:
RSACrypto::PublicKey::Alloc
Rimpiazzare:
Codice:
rsa->n = BN_new();
rsa->e = BN_new();
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
rsa->n = BN_new();
rsa->e = BN_new();
#else
BIGNUM* n = BN_new(), * e = BN_new();
RSA_set0_key(rsa, n, e, NULL);
#endif
-------------------------------------------------------------------------------------------------
Funzione
Codice:
RSACrypto::PublicKey::Copy
Rimpiazzare:
Codice:
BN_copy(to->n, from->n);
BN_copy(to->e, from->e);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
BN_copy(to->n, from->n);
BN_copy(to->e, from->e);
#else
BIGNUM* to_n, * to_e,* to_d;
const BIGNUM* from_n = RSA_get0_n(from), * from_e = RSA_get0_e(from);
RSA_get0_key(to, (const BIGNUM**)&to_n, (const BIGNUM**)&to_e, (const BIGNUM**)&to_d);
BN_copy(to_n, from_n);
BN_copy(to_e, from_e);
RSA_set0_key(to, to_n, to_e, to_d);
#endif
-------------------------------------------------------------------------------------------------
Funzione
Codice:
RSACrypto::PrivateKey::Alloc
Rimpiazzare:
Codice:
rsa->d = BN_new();
rsa->p = BN_new();
rsa->q = BN_new();
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
rsa->d = BN_new();
rsa->p = BN_new();
rsa->q = BN_new();
#else
BIGNUM* d = BN_new(), * p = BN_new(), * q = BN_new();
RSA_set0_key(rsa, NULL, NULL, d);
RSA_set0_factors(rsa, p, q);
#endif
-------------------------------------------------------------------------------------------------
Funzione
Codice:
RSACrypto::PrintKey (k, n, e)
Rimpiazzare:
Codice:
char* tmp = BN_bn2hex(k->rsa_->e);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
char* tmp = BN_bn2hex(k->rsa_->e);
#else
const BIGNUM* rsa_e = RSA_get0_e(k->rsa_);
char* tmp = BN_bn2hex(rsa_e);
#endif
Rimpiazzare:
Codice:
tmp = BN_bn2hex(k->rsa_->n);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
tmp = BN_bn2hex(k->rsa_->n);
#else
const BIGNUM* rsa_n = RSA_get0_n(k->rsa_);
tmp = BN_bn2hex(rsa_n);
#endif
-------------------------------------------------------------------------------------------------
Funzione
Codice:
RSACrypto::PrintKey(k, n, e, d)
Rimpiazzare:
Codice:
char* tmp = BN_bn2hex(k->rsa_->n);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
char* tmp = BN_bn2hex(k->rsa_->n);
#else
const BIGNUM* rsa_n = RSA_get0_n(k->rsa_);
char* tmp = BN_bn2hex(rsa_n);
#endif
Rimpiazzare:
Codice:
tmp = BN_bn2hex(k->rsa_->e);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
tmp = BN_bn2hex(k->rsa_->e);
#else
const BIGNUM* rsa_e = RSA_get0_e(k->rsa_);
tmp = BN_bn2hex(rsa_e);
#endif
Rimpiazzare:
Codice:
tmp = BN_bn2hex(k->rsa_->d);
con:
Codice:
#if OPENSSL_VERSION_NUMBER < 0x10100000L
tmp = BN_bn2hex(k->rsa_->d);
#else
const BIGNUM* rsa_d = RSA_get0_d(k->rsa_);
tmp = BN_bn2hex(rsa_d);
#endif
Spiegazione dei cambiamenti:
1) Gli ifdef sono li per compatibilità con le vecchie versioni
2) OpenSSL 1.0 non espone la struttura "rsa_", quindi dobbiamo usare le nuove API di OpenSSL per prendere i dati richiesti.
Buona fortuna.