diff options
Diffstat (limited to 'src/common/Cryptography/RSA.cpp')
-rw-r--r-- | src/common/Cryptography/RSA.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/Cryptography/RSA.cpp b/src/common/Cryptography/RSA.cpp index 11bbbe1dac5..96199d34bb0 100644 --- a/src/common/Cryptography/RSA.cpp +++ b/src/common/Cryptography/RSA.cpp @@ -16,6 +16,8 @@ */ #include "RSA.h" +#include "BigNumber.h" +#include <openssl/bn.h> #include <openssl/pem.h> #include <algorithm> #include <iterator> @@ -88,6 +90,13 @@ bool Trinity::Crypto::RSA::LoadFromString(std::string const& keyPem, KeyTag) return true; } +BigNumber Trinity::Crypto::RSA::GetModulus() const +{ + BigNumber bn; + BN_copy(bn.BN(), _rsa->n); + return bn; +} + template <typename KeyTag> bool Trinity::Crypto::RSA::Encrypt(uint8 const* data, std::size_t dataLength, uint8* output, int32 paddingType) { @@ -97,6 +106,14 @@ bool Trinity::Crypto::RSA::Encrypt(uint8 const* data, std::size_t dataLength, ui return result != -1; } +bool Trinity::Crypto::RSA::Sign(int32 hashType, uint8 const* dataHash, std::size_t dataHashLength, uint8* output) +{ + uint32 signatureLength = 0; + int result = RSA_sign(hashType, dataHash, dataHashLength, output, &signatureLength, _rsa); + std::reverse(output, output + GetOutputSize()); + return result != -1; +} + namespace Trinity { namespace Crypto |