2018-07-10 15:01:34 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <fnd/types.h>
|
|
|
|
#include <fnd/IFile.h>
|
2018-09-23 03:29:22 +00:00
|
|
|
#include <fnd/SharedPtr.h>
|
2018-07-10 15:01:34 +00:00
|
|
|
#include <fnd/List.h>
|
|
|
|
#include <fnd/Vec.h>
|
2018-08-07 07:17:51 +00:00
|
|
|
#include <nn/pki/SignedData.h>
|
|
|
|
#include <nn/pki/CertificateBody.h>
|
2018-08-21 12:03:19 +00:00
|
|
|
#include "KeyConfiguration.h"
|
2018-09-13 11:06:48 +00:00
|
|
|
#include "common.h"
|
2018-07-10 15:01:34 +00:00
|
|
|
|
2018-08-06 09:11:15 +00:00
|
|
|
class PkiCertProcess
|
2018-07-10 15:01:34 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-08-06 09:11:15 +00:00
|
|
|
PkiCertProcess();
|
2018-07-10 15:01:34 +00:00
|
|
|
|
|
|
|
void process();
|
|
|
|
|
2018-09-23 03:29:22 +00:00
|
|
|
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
2018-08-21 12:03:19 +00:00
|
|
|
void setKeyCfg(const KeyConfiguration& keycfg);
|
2018-07-10 15:01:34 +00:00
|
|
|
void setCliOutputMode(CliOutputMode type);
|
|
|
|
void setVerifyMode(bool verify);
|
|
|
|
|
|
|
|
private:
|
2018-08-06 09:11:15 +00:00
|
|
|
const std::string kModuleName = "PkiCertProcess";
|
|
|
|
static const size_t kSmallHexDumpLen = 0x10;
|
2018-07-10 15:01:34 +00:00
|
|
|
|
2018-09-23 03:29:22 +00:00
|
|
|
fnd::SharedPtr<fnd::IFile> mFile;
|
2018-08-21 12:03:19 +00:00
|
|
|
KeyConfiguration mKeyCfg;
|
2018-07-10 15:01:34 +00:00
|
|
|
CliOutputMode mCliOutputMode;
|
|
|
|
bool mVerify;
|
|
|
|
|
2018-08-07 08:13:18 +00:00
|
|
|
fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>> mCert;
|
2018-07-10 15:01:34 +00:00
|
|
|
|
|
|
|
void importCerts();
|
|
|
|
void validateCerts();
|
|
|
|
void displayCerts();
|
2018-08-07 08:13:18 +00:00
|
|
|
void displayCert(const nn::pki::SignedData<nn::pki::CertificateBody>& cert);
|
2018-07-10 15:01:34 +00:00
|
|
|
|
2018-08-06 09:11:15 +00:00
|
|
|
size_t getHexDumpLen(size_t max_size) const;
|
2018-08-07 08:13:18 +00:00
|
|
|
const char* getSignTypeStr(nn::pki::sign::SignatureId type) const;
|
2018-07-10 15:01:34 +00:00
|
|
|
const char* getEndiannessStr(bool isLittleEndian) const;
|
2018-08-07 08:13:18 +00:00
|
|
|
const char* getPublicKeyTypeStr(nn::pki::cert::PublicKeyType type) const;
|
2018-07-10 15:01:34 +00:00
|
|
|
};
|