[*] Amend crypto headers and type usage

This commit is contained in:
Reece Wilson 2021-07-01 10:32:52 +01:00
parent 6e1037200c
commit b9da9c313e
7 changed files with 29 additions and 18 deletions

View File

@ -7,19 +7,24 @@
***/
#pragma once
namespace Aurora::Crypto::RSA
{
class IRSAPublic;
}
namespace Aurora::Crypto::CA
{
class ICertificateStore
{
public:
virtual void AddSignature(const PublicRSAKey& CA, const AuList<AuUInt8>& sig,
virtual void AddSignature(const AuSPtr<RSA::IRSAPublic>& CA, const AuList<AuUInt8>& sig,
EHashType method, EPaddingType type) = 0;
virtual void AddPublicCert(const X509::Certificate& cert) = 0;
/// For future support of http gets of the CA list
virtual bool& AllowHTTPTree() = 0;
virtual bool CheckKey(const PublicKey& pub) = 0;
virtual bool CheckKey(const AuSPtr<RSA::IRSAPublic>& pub) = 0;
virtual bool CheckCert(const X509::Certificate& cert) = 0;
};

View File

@ -15,6 +15,12 @@ namespace Aurora::Crypto
{
using Certificate = AuList<AuUInt8>;
}
struct RSAPair
{
AuString certificate;
AuString privKey;
};
}
#include "EHashType.hpp"

View File

@ -7,7 +7,7 @@
***/
#pragma once
namespace Aurora::Crypto::ECC25519
namespace Aurora::Crypto::ECC::C25519
{
}

View File

@ -7,7 +7,7 @@
***/
#pragma once
namespace Aurora::Crypto::ECCNIST
namespace Aurora::Crypto::ECC::NIST
{
}

View File

@ -16,8 +16,8 @@ namespace Aurora::Crypto::PEM
AUKN_SYM AuString PrivateRSAToString(const DerBuffer &in);
AUKN_SYM bool FromString(const AuString &in, Aurora::Crypto::X509::Certificate &out);
AUKN_SYM bool PublicFromString(const AuString &in, PublicKey &out);
AUKN_SYM bool PrivateFromString(const AuString &in, PrivateKey &out);
AUKN_SYM bool PublicRSAFromString(const AuString &in, PrivateRSAKey &out);
AUKN_SYM bool PrivateRSAFromString(const AuString &in, PublicRSAKey &out);
AUKN_SYM bool PublicFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool PrivateFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool PublicRSAFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool PrivateRSAFromString(const AuString &in, DerBuffer &out);
}

View File

@ -62,22 +62,22 @@ namespace Aurora::Crypto::PEM
return SerializePEM("-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----", in);
}
AUKN_SYM AuString PrivateToString(const PrivateKey &in)
AUKN_SYM AuString PrivateToString(const DerBuffer &in)
{
return SerializePEM("-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----", in);
}
AUKN_SYM AuString PublicToString(const PublicKey &in)
AUKN_SYM AuString PublicToString(const DerBuffer &in)
{
return SerializePEM("-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----", in);
}
AUKN_SYM AuString PublicRSAToString(const PrivateRSAKey &in)
AUKN_SYM AuString PublicRSAToString(const DerBuffer &in)
{
return SerializePEM("-----BEGIN RSA PUBLIC KEY-----", "-----END RSA PUBLIC KEY-----", in);
}
AUKN_SYM AuString PrivateRSAToString(const PublicRSAKey &in)
AUKN_SYM AuString PrivateRSAToString(const DerBuffer &in)
{
return SerializePEM("-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----", in);
}
@ -87,22 +87,22 @@ namespace Aurora::Crypto::PEM
return ParsePEM("-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----", in, out);
}
AUKN_SYM bool PrivateFromString(const AuString &in, PrivateKey &out)
AUKN_SYM bool PrivateFromString(const AuString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----", in, out);
}
AUKN_SYM bool PublicRSAFromString(const AuString &in, PrivateRSAKey &out)
AUKN_SYM bool PublicRSAFromString(const AuString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN RSA PUBLIC KEY-----", "-----END RSA PUBLIC KEY-----", in, out);
}
AUKN_SYM bool PrivateRSAFromString(const AuString &in, PublicRSAKey &out)
AUKN_SYM bool PrivateRSAFromString(const AuString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----", in, out);
}
AUKN_SYM bool PublicFromString(const AuString &in, PublicKey &out)
AUKN_SYM bool PublicFromString(const AuString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----", in, out);
}

View File

@ -158,7 +158,7 @@ namespace Aurora::Crypto::RSA
if (key.meta.side == EKeyType::eKeyPublic)
{
SysPushErrorArg("Attempted to import a public key as a private key.");
return false;
return nullptr;
}
if (!ImportRSAKey(in, key))