nstool/programs/nstool/source/PkiValidator.h

34 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#include <fnd/types.h>
#include <fnd/List.h>
#include <fnd/Vec.h>
#include <fnd/rsa.h>
2018-08-07 07:17:51 +00:00
#include <nn/pki/SignedData.h>
#include <nn/pki/CertificateBody.h>
#include <string>
class PkiValidator
{
public:
PkiValidator();
void setRootKey(const fnd::rsa::sRsa4096Key& root_key);
2018-08-07 08:13:18 +00:00
void addCertificates(const fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>>& certs);
void addCertificate(const nn::pki::SignedData<nn::pki::CertificateBody>& cert);
void clearCertificates();
2018-08-07 08:13:18 +00:00
void validateSignature(const std::string& issuer, nn::pki::sign::SignatureId signature_id, const fnd::Vec<byte_t>& signature, const fnd::Vec<byte_t>& hash) const;
private:
const std::string kModuleName = "NNPkiValidator";
fnd::rsa::sRsa4096Key mRootKey;
2018-08-07 08:13:18 +00:00
fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>> mCertificateBank;
2018-08-07 08:13:18 +00:00
void makeCertIdent(const nn::pki::SignedData<nn::pki::CertificateBody>& cert, std::string& ident) const;
void makeCertIdent(const std::string& issuer, const std::string& subject, std::string& ident) const;
bool doesCertExist(const std::string& ident) const;
2018-08-07 08:13:18 +00:00
const nn::pki::SignedData<nn::pki::CertificateBody>& getCert(const std::string& ident) const;
fnd::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const;
};