From ef73353a0ab3c47090633f72bca4a2d0a0c881f9 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 14 Dec 2014 22:45:09 -0500 Subject: [PATCH] use RSA-raw for SU3 verification --- Reseed.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Reseed.cpp b/Reseed.cpp index c685d69c..238b2510 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -11,7 +11,7 @@ #include "Reseed.h" #include "Log.h" #include "Identity.h" -#include "Signature.h" +#include "CryptoConst.h" #include "NetDb.h" #include "util.h" @@ -231,7 +231,14 @@ namespace data s.read ((char *)tbs, tbsLen); uint8_t * signature = new uint8_t[signatureLength]; s.read ((char *)signature, signatureLength); - if (!verifier.Verify (tbs, tbsLen, signature)) + // RSA-raw + CryptoPP::Integer enSig (a_exp_b_mod_c (CryptoPP::Integer (signature, 512), + CryptoPP::Integer (i2p::crypto::rsae), CryptoPP::Integer (it->second, 512))); + uint8_t enSigBuf[512]; + enSig.Encode (enSigBuf, 512); + uint8_t hash[64]; + CryptoPP::SHA512().CalculateDigest (hash, tbs, tbsLen); // TODO: implement in one pass + if (memcmp (enSigBuf + (512-64), hash, 64)) // TODO: use PKCS#1 v1.5 padding LogPrint (eLogWarning, "SU3 signature verification failed"); delete[] signature; delete[] tbs;