Ocean
Ocean::IO::Signature Class Reference

This class implements functions allowing to sign data or to provide hash values for data. More...

Static Public Member Functions

static unsigned int crc32 (const unsigned char *buffer, const size_t bufferSize)
 Determines the CRC32 hash for a specified data buffer. More...
 
static void md5 (const unsigned char *buffer, const size_t bufferSize, unsigned char hash[16])
 Determines the MD5 hash for a specified data buffer. More...
 
static void sha1 (const unsigned char *buffer, const size_t bufferSize, unsigned char hash[20])
 Determines the SHA1 hash for a specified data buffer. More...
 
static void hmacSHA1 (const unsigned char *buffer, const size_t bufferSize, const unsigned char *key, const size_t keySize, unsigned char hash[20])
 Determines the keyed hash message authentication code using SHA1 for a specified data buffer and secrete key. More...
 
static bool evaluateCodeSignature (const std::wstring &filePath, bool &trustedCodeSignature, std::wstring *subjectName)
 Evaluates if the code signature of the specified file exists and is trusted by the platform-specfic certificate store. More...
 

Static Private Member Functions

static bool evaluateCodeSignatureAppleMacos (const std::wstring &filePath, bool &trustedCodeSignature, std::wstring *subjectName)
 Evaluates if the code signature of the specified file exists and is trusted by the certificate store on macOS. More...
 
static bool evaluateCodeSignatureWindows (const std::wstring &filePath, bool &trustedCodeSignature, std::wstring *subjectName)
 Evaluates if the code signature of the specified file exists and is trusted by the certificate store on Windows. More...
 
static bool determineSignatureSubjectName (const std::wstring &filePath, std::wstring &subjectName)
 Returns the subject name of the digital signature for the specified file. More...
 

Detailed Description

This class implements functions allowing to sign data or to provide hash values for data.

Member Function Documentation

◆ crc32()

static unsigned int Ocean::IO::Signature::crc32 ( const unsigned char *  buffer,
const size_t  bufferSize 
)
static

Determines the CRC32 hash for a specified data buffer.

Parameters
bufferThe buffer for which the hash will be determined, must be valid
bufferSizeThe size of the buffer in bytes, with range (0, 2^32 - 1)
Returns
The resulting CRC32 hash value for the given buffer

◆ determineSignatureSubjectName()

static bool Ocean::IO::Signature::determineSignatureSubjectName ( const std::wstring &  filePath,
std::wstring &  subjectName 
)
staticprivate

Returns the subject name of the digital signature for the specified file.

The method will fail if the specified file has no digital signature.

Parameters
filePathFile path to signed code file
subjectNameReceives the subject name
Returns
Ture if succeeded; otherwise, false is returned.

◆ evaluateCodeSignature()

bool Ocean::IO::Signature::evaluateCodeSignature ( const std::wstring &  filePath,
bool &  trustedCodeSignature,
std::wstring *  subjectName 
)
inlinestatic

Evaluates if the code signature of the specified file exists and is trusted by the platform-specfic certificate store.

On Apple platforms the subject name may contain a team identifier code (e.g., subject (ABCDEFG))

Parameters
filePathFile path to signed code file
trustedCodeSignatureReceives true if the code signature of the file is valid and trusted; otherwise false is returned.
subjectNameOptional parameter that receives the subject name
Returns
True if signature evaluation and subject name determination succeeded; otherwise, false is returned.
See also
evaluateCodeSignatureAppleMacos(), evaluateCodeSignatureWindows()

◆ evaluateCodeSignatureAppleMacos()

static bool Ocean::IO::Signature::evaluateCodeSignatureAppleMacos ( const std::wstring &  filePath,
bool &  trustedCodeSignature,
std::wstring *  subjectName 
)
staticprivate

Evaluates if the code signature of the specified file exists and is trusted by the certificate store on macOS.

The subject name may contain a team identifier code (e.g., subject (ABCDEFG))

Parameters
filePathFile path to signed code file
trustedCodeSignatureReceives true if the code signature of the file is valid and trusted; otherwise false is returned.
subjectNameOptional parameter that receives the subject name
Returns
Ture if signature evaluation and subject name determination succeeded; otherwise, false is returned.
See also
evaluateCodeSignature()

◆ evaluateCodeSignatureWindows()

static bool Ocean::IO::Signature::evaluateCodeSignatureWindows ( const std::wstring &  filePath,
bool &  trustedCodeSignature,
std::wstring *  subjectName 
)
staticprivate

Evaluates if the code signature of the specified file exists and is trusted by the certificate store on Windows.

On Apple platforms the subject name may contain a team identifier code (e.g., subject (ABCDEFG))

Parameters
filePathFile path to signed code file
trustedCodeSignatureReceives true if the code signature of the file is valid and trusted; otherwise false is returned.
subjectNameOptional parameter that receives the subject name
Returns
True if signature evaluation and subject name determination succeeded; otherwise, false is returned.
See also
evaluateCodeSignatureAppleMacos()

◆ hmacSHA1()

static void Ocean::IO::Signature::hmacSHA1 ( const unsigned char *  buffer,
const size_t  bufferSize,
const unsigned char *  key,
const size_t  keySize,
unsigned char  hash[20] 
)
static

Determines the keyed hash message authentication code using SHA1 for a specified data buffer and secrete key.

Parameters
bufferThe buffer for which the hash will be determined, may be nullptr if bufferSize is 0
bufferSizeThe size of the buffer in bytes, with range [0, infinity)
keyThe key which will be used to determine the hash, may be nullptr if keySize is 0
keySizeThe size of the key in bytes, with range [0, infinity)
hashThe resulting SHA1 hash value for the given buffer

◆ md5()

static void Ocean::IO::Signature::md5 ( const unsigned char *  buffer,
const size_t  bufferSize,
unsigned char  hash[16] 
)
static

Determines the MD5 hash for a specified data buffer.

Parameters
bufferThe buffer for which the hash will be determined, may be nullptr if bufferSize is 0
bufferSizeThe size of the buffer in bytes, with range [0, infinity)
hashThe resulting MD5 hash value for the given buffer

◆ sha1()

static void Ocean::IO::Signature::sha1 ( const unsigned char *  buffer,
const size_t  bufferSize,
unsigned char  hash[20] 
)
static

Determines the SHA1 hash for a specified data buffer.

Parameters
bufferThe buffer for which the hash will be determined, may be nullptr if bufferSize is 0
bufferSizeThe size of the buffer in bytes, with range [0, infinity)
hashThe resulting SHA1 hash value for the given buffer

The documentation for this class was generated from the following file: