mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04:00
added sha256 calculation functions, and non backward compatible SSL Id computation code to active later (0.7)
This commit is contained in:
parent
ba7cf4995b
commit
7472f78223
5 changed files with 63 additions and 6 deletions
|
@ -610,6 +610,22 @@ bool getX509id(X509 *x509, RsPeerId& xid)
|
|||
|
||||
X509_get0_signature(&signature,&algor,x509);
|
||||
#endif
|
||||
|
||||
#ifndef 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).
|
||||
//
|
||||
int signlen = ASN1_STRING_length(signature);
|
||||
if (signlen < CERTSIGNLEN)
|
||||
{
|
||||
|
@ -627,14 +643,16 @@ bool getX509id(X509 *x509, RsPeerId& xid)
|
|||
* more randomness
|
||||
*/
|
||||
|
||||
#warning csoler 2017-02-19: This is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
#warning csoler 2017-02-19: This is cryptographically horrible. We should hash the entire signature here!
|
||||
|
||||
xid = RsPeerId(&signdata[signlen - CERTSIGNLEN]) ;
|
||||
#else
|
||||
|
||||
//for(int i = signlen - CERTSIGNLEN; i < signlen; i++)
|
||||
//{
|
||||
// rs_sprintf_append(xid, "%02x", (uint16_t) (((uint8_t *) (signdata))[i]));
|
||||
//}
|
||||
if(RsPeerId::SIZE_IN_BYTES > Sha256CheckSum::SIZE_IN_BYTES)
|
||||
return false ;
|
||||
|
||||
xid = RsPeerId(RsDirUtil::sha256sum(ASN1_STRING_data(const_cast<ASN1_BIT_STRING*>(signature)),ASN1_STRING_length(signature)).toByteArray()) ;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue