2018-08-05 15:09:07 +00:00
|
|
|
#pragma once
|
2021-09-28 11:15:54 +00:00
|
|
|
#include "types.h"
|
|
|
|
#include "KeyBag.h"
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
#include <nn/pki/SignedData.h>
|
|
|
|
#include <nn/pki/CertificateBody.h>
|
2021-09-28 11:15:54 +00:00
|
|
|
|
|
|
|
namespace nstool {
|
2018-08-05 15:09:07 +00:00
|
|
|
|
|
|
|
class PkiValidator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PkiValidator();
|
|
|
|
|
2021-09-28 11:15:54 +00:00
|
|
|
void setKeyCfg(const KeyBag& keycfg);
|
|
|
|
void addCertificates(const std::vector<nn::pki::SignedData<nn::pki::CertificateBody>>& certs);
|
2018-08-07 08:13:18 +00:00
|
|
|
void addCertificate(const nn::pki::SignedData<nn::pki::CertificateBody>& cert);
|
2018-08-05 15:09:07 +00:00
|
|
|
void clearCertificates();
|
|
|
|
|
2021-09-28 11:15:54 +00:00
|
|
|
void validateSignature(const std::string& issuer, nn::pki::sign::SignatureId signature_id, const tc::ByteData& signature, const tc::ByteData& hash) const;
|
2018-08-05 15:09:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string kModuleName = "NNPkiValidator";
|
|
|
|
|
2021-09-28 11:15:54 +00:00
|
|
|
KeyBag mKeyCfg;
|
|
|
|
std::vector<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;
|
2021-09-28 11:15:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|