2018-08-05 15:09:07 +00:00
|
|
|
#pragma once
|
|
|
|
#include <fnd/types.h>
|
|
|
|
#include <fnd/List.h>
|
|
|
|
#include <fnd/Vec.h>
|
2018-08-07 08:35:03 +00:00
|
|
|
#include <fnd/rsa.h>
|
2018-08-07 07:17:51 +00:00
|
|
|
#include <nn/pki/SignedData.h>
|
|
|
|
#include <nn/pki/CertificateBody.h>
|
2018-08-05 15:09:07 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class PkiValidator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PkiValidator();
|
|
|
|
|
2018-08-07 08:35:03 +00:00
|
|
|
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);
|
2018-08-05 15:09:07 +00:00
|
|
|
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;
|
2018-08-05 15:09:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string kModuleName = "NNPkiValidator";
|
|
|
|
|
|
|
|
|
2018-08-07 08:35:03 +00:00
|
|
|
fnd::rsa::sRsa4096Key mRootKey;
|
2018-08-07 08:13:18 +00:00
|
|
|
fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>> mCertificateBank;
|
2018-08-05 15:09:07 +00:00
|
|
|
|
2018-08-07 08:13:18 +00:00
|
|
|
void makeCertIdent(const nn::pki::SignedData<nn::pki::CertificateBody>& cert, std::string& ident) const;
|
2018-08-05 15:09:07 +00:00
|
|
|
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;
|
2018-08-07 08:35:03 +00:00
|
|
|
fnd::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const;
|
2018-08-05 15:09:07 +00:00
|
|
|
};
|