Tools/Patcher: Properly sign certificate bundle

This commit is contained in:
Shauren
2017-12-29 12:50:12 +01:00
parent 02022d3cd6
commit b49fa9658a
12 changed files with 155 additions and 123 deletions

View File

@@ -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