58 lines
1.4 KiB
C++

//----------------------------------------------------------------------------
//
// Copyright (C) 2007 Intel Corporation
//
// File: CertHash.h
//
// Contents: Certificate hash utility
//
//----------------------------------------------------------------------------
#ifndef _CERT_HASH
#define _CERT_HASH
#include <string>
#include <vector>
#define MAX_PATH_LEN 300
#define MAX_HASH_LENGTH 48
#define CERT_HASH_SHA1_LENGTH 20
#define CERT_HASH_SHA256_LENGTH 32
#define CERT_HASH_SHA384_LENGTH 48
enum CertHashAlgorithm
{
USB_CERT_HASH_ALGORITHM_MD5 = 0, // 16 bytes
USB_CERT_HASH_ALGORITHM_SHA1, // 20 bytes
USB_CERT_HASH_ALGORITHM_SHA256, // 32 bytes
USB_CERT_HASH_ALGORITHM_SHA384, // 48 bytes
INVALID_USB_CERT_HASH_ALGORITHM // invalid value
};
using namespace std;
class CertHash
{
public:
bool _valid;
bool _dllFailed;
unsigned char* _hash;
string _friendlyName;
CertHashAlgorithm _hashAlgorithm;
unsigned int _hashLength;
CertHash() : _valid(false), _dllFailed(false), _hash(NULL), _friendlyName(), _hashAlgorithm(USB_CERT_HASH_ALGORITHM_SHA1), _hashLength(0) {}
// copy constructor
CertHash(const CertHash& h);
CertHash& operator=(const CertHash& h);
// create a hash from a given root certificate file
CertHash(const string& fileName, const string& friendlyName, const CertHashAlgorithm& hashAlgorithm);
CertHash(const string& hashstring, const string& friendlyName);
~CertHash();
};
#endif