mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
changed #ifs into #ifdefs because it us more robust, and moved the definition of variables to retroshare.pri
This commit is contained in:
parent
ef1a61374c
commit
9367aa0d84
@ -1382,7 +1382,7 @@ ops_secret_key_t *secret_key = NULL ;
|
||||
// then do the signature.
|
||||
|
||||
ops_boolean_t not_raw = !use_raw_signature ;
|
||||
#if V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
ops_memory_t *memres = ops_sign_buf(data,len,OPS_SIG_BINARY,OPS_HASH_SHA256,secret_key,ops_false,ops_false,not_raw,not_raw) ;
|
||||
#else
|
||||
ops_memory_t *memres = ops_sign_buf(data,len,OPS_SIG_BINARY,OPS_HASH_SHA1,secret_key,ops_false,ops_false,not_raw,not_raw) ;
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "pgp/pgpkeyutil.h"
|
||||
|
||||
#include "retroshare/rspeers.h" // for RsPeerDetails structure
|
||||
#include "retroshare/rsdefines.h"
|
||||
#include "retroshare/rsids.h" // for RsPeerDetails structure
|
||||
#include "rsserver/p3face.h"
|
||||
|
||||
@ -822,7 +821,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
|
||||
ASN1_BIT_STRING *signature = const_cast<ASN1_BIT_STRING*>(tmp_signature);
|
||||
#endif
|
||||
//EVP_PKEY *pkey = NULL;
|
||||
#if V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
const EVP_MD *type = EVP_sha256();
|
||||
#else
|
||||
const EVP_MD *type = EVP_sha1();
|
||||
@ -872,7 +871,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
|
||||
inl=i2d_re_X509_tbs(x509,&buf_in) ; // this does the i2d over x509->cert_info
|
||||
#endif
|
||||
|
||||
#if V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
sigoutl=2048; // hashoutl; //EVP_PKEY_size(pkey);
|
||||
unsigned char *buf_sigout=(unsigned char *)OPENSSL_malloc((unsigned int)sigoutl);
|
||||
|
||||
@ -966,7 +965,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
|
||||
/* cleanup */
|
||||
if(buf_in != NULL)
|
||||
OPENSSL_free(buf_in) ;
|
||||
#if !V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
if(buf_hashout != NULL)
|
||||
OPENSSL_free(buf_hashout) ;
|
||||
#endif
|
||||
@ -1028,7 +1027,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,uint32_t& diagnostic)
|
||||
#endif
|
||||
|
||||
|
||||
#if V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
const EVP_MD *type = EVP_sha256();
|
||||
#else
|
||||
const EVP_MD *type = EVP_sha1();
|
||||
@ -1078,7 +1077,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,uint32_t& diagnostic)
|
||||
i2d(data,&p);
|
||||
#endif
|
||||
|
||||
#if !V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
/* data in buf_in, ready to be hashed */
|
||||
EVP_DigestInit_ex(ctx,type, NULL);
|
||||
EVP_DigestUpdate(ctx,(unsigned char *)buf_in,inl);
|
||||
@ -1111,7 +1110,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,uint32_t& diagnostic)
|
||||
std::cerr << "AuthSSLimpl::AuthX509() verifying the gpg sig with keyprint : " << pd.fpr << std::endl;
|
||||
std::cerr << "Sigoutl = " << sigoutl << std::endl ;
|
||||
std::cerr << "pd.fpr = " << pd.fpr << std::endl ;
|
||||
#if !V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
std::cerr << "hashoutl = " << hashoutl << std::endl ;
|
||||
#endif
|
||||
#endif
|
||||
@ -1176,7 +1175,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,uint32_t& diagnostic)
|
||||
|
||||
// passed, verify the signature itself
|
||||
|
||||
#if V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
if (!AuthGPG::getAuthGPG()->VerifySignBin(buf_in, inl, buf_sigout, (unsigned int) sigoutl, pd.fpr)) {
|
||||
#else
|
||||
if (!AuthGPG::getAuthGPG()->VerifySignBin(buf_hashout, hashoutl, buf_sigout, (unsigned int) sigoutl, pd.fpr)) {
|
||||
|
@ -611,7 +611,7 @@ bool getX509id(X509 *x509, RsPeerId& xid)
|
||||
X509_get0_signature(&signature,&algor,x509);
|
||||
#endif
|
||||
|
||||
#if V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
||||
// What: Computes the node id by performing a sha256 hash of the certificate's PGP signature, instead of simply picking up the last 20 bytes of it.
|
||||
//
|
||||
// Why: There is no real risk in forging a certificate with the same ID as the authentication is performed over the PGP signature of the certificate
|
||||
|
@ -1,37 +0,0 @@
|
||||
/**************************************************************************************************************************************************
|
||||
*
|
||||
* V07_NON_BACKWARD_COMPATIBLE_CHANGE_001:
|
||||
*
|
||||
* What: Computes the node id by performing a sha256 hash of the certificate's PGP signature, instead of simply picking up the last 20 bytes of it.
|
||||
*
|
||||
* Why: There is no real risk in forging a certificate with the same ID as the authentication is performed over the PGP signature of the certificate
|
||||
* which hashes the full SSL certificate (i.e. the full serialized CERT_INFO structure). However the possibility to
|
||||
* create two certificates with the same IDs is a problem, as it can be used to cause disturbance in the software.
|
||||
*
|
||||
* Backward compat: makes connexions impossible with non patched peers, probably because the SSL id that is computed is not the same on both side,
|
||||
* and in particular unpatched peers see a cerficate with ID different (because computed with the old method) than the ID that was
|
||||
* submitted when making friends.
|
||||
*
|
||||
* Note: the advantage of basing the ID on the signature rather than the public key is not very clear, given that the signature is based on a hash
|
||||
* of the public key (and the rest of the certificate info).
|
||||
*
|
||||
* V07_NON_BACKWARD_COMPATIBLE_CHANGE_002:
|
||||
*
|
||||
* What: Use RSA+SHA256 instead of RSA+SHA1 for PGP certificate signatures
|
||||
*
|
||||
* Why: Sha1 is likely to be prone to primary collisions anytime soon, so it is urgent to turn to a more secure solution.
|
||||
*
|
||||
* Backward compat: unpatched peers are able to verify signatures since openpgp-sdk already handle it.
|
||||
*
|
||||
* V07_NON_BACKWARD_COMPATIBLE_CHANGE_003:
|
||||
*
|
||||
* What: Do not hash PGP certificate twice when signing
|
||||
*
|
||||
* Why: hasing twice is not per se a security issue, but it makes it harder to change the settings for hashing.
|
||||
*
|
||||
* Backward compat: patched peers cannot connect to non patched peers.
|
||||
***************************************************************************************************************************************************/
|
||||
|
||||
#define V07_NON_BACKWARD_COMPATIBLE_CHANGE_001 False
|
||||
#define V07_NON_BACKWARD_COMPATIBLE_CHANGE_002 False
|
||||
#define V07_NON_BACKWARD_COMPATIBLE_CHANGE_003 False
|
@ -262,3 +262,43 @@ rs_async_chat {
|
||||
rs_chatserver {
|
||||
DEFINES *= RS_CHATSERVER
|
||||
}
|
||||
|
||||
###########################################################################################################################################################
|
||||
#
|
||||
# V07_NON_BACKWARD_COMPATIBLE_CHANGE_001:
|
||||
#
|
||||
# What: Computes the node id by performing a sha256 hash of the certificate's PGP signature, instead of simply picking up the last 20 bytes of it.
|
||||
#
|
||||
# Why: There is no real risk in forging a certificate with the same ID as the authentication is performed over the PGP signature of the certificate
|
||||
# which hashes the full SSL certificate (i.e. the full serialized CERT_INFO structure). However the possibility to
|
||||
# create two certificates with the same IDs is a problem, as it can be used to cause disturbance in the software.
|
||||
#
|
||||
# Backward compat: makes connexions impossible with non patched peers, probably because the SSL id that is computed is not the same on both side,
|
||||
# and in particular unpatched peers see a cerficate with ID different (because computed with the old method) than the ID that was
|
||||
# submitted when making friends.
|
||||
#
|
||||
# Note: the advantage of basing the ID on the signature rather than the public key is not very clear, given that the signature is based on a hash
|
||||
# of the public key (and the rest of the certificate info).
|
||||
#
|
||||
# V07_NON_BACKWARD_COMPATIBLE_CHANGE_002:
|
||||
#
|
||||
# What: Use RSA+SHA256 instead of RSA+SHA1 for PGP certificate signatures
|
||||
#
|
||||
# Why: Sha1 is likely to be prone to primary collisions anytime soon, so it is urgent to turn to a more secure solution.
|
||||
#
|
||||
# Backward compat: unpatched peers are able to verify signatures since openpgp-sdk already handle it.
|
||||
#
|
||||
# V07_NON_BACKWARD_COMPATIBLE_CHANGE_003:
|
||||
#
|
||||
# What: Do not hash PGP certificate twice when signing
|
||||
#
|
||||
# Why: hasing twice is not per se a security issue, but it makes it harder to change the settings for hashing.
|
||||
#
|
||||
# Backward compat: patched peers cannot connect to non patched peers.
|
||||
###########################################################################################################################################################
|
||||
|
||||
rs_v07_changes {
|
||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user