Add source code for ctrtool

This commit is contained in:
jakcron
2022-03-12 16:00:33 +08:00
parent 6ad2f13c50
commit 800f5776bc
681 changed files with 219734 additions and 0 deletions
@@ -0,0 +1,29 @@
#include <tc/crypto/RsaKey.h>
tc::crypto::RsaPublicKey::RsaPublicKey(const byte_t* modulus, size_t modulus_size)
{
static const byte_t kPublicExponent[3] = { 0x01, 0x00, 0x01 };
if (modulus != nullptr && modulus_size != 0)
{
this->n = tc::ByteData(modulus, modulus_size);
this->e = tc::ByteData(kPublicExponent, sizeof(kPublicExponent));
}
}
tc::crypto::RsaPrivateKey::RsaPrivateKey(const byte_t* modulus, size_t modulus_size, const byte_t* private_exponent, size_t private_exponent_size)
{
static const byte_t kPublicExponent[3] = { 0x01, 0x00, 0x01 };
if (modulus != nullptr && modulus_size != 0 && private_exponent != nullptr && private_exponent_size != 0)
{
this->n = tc::ByteData(modulus, modulus_size);
this->d = tc::ByteData(private_exponent, private_exponent_size);
this->e = tc::ByteData(kPublicExponent, sizeof(kPublicExponent));
}
}
tc::crypto::RsaKey tc::crypto::RsaPrivateKey::getPublicKey()
{
return RsaPublicKey(this->n.data(), this->n.size());
}