-
Notifications
You must be signed in to change notification settings - Fork 5
/
Utility.h
33 lines (22 loc) · 954 Bytes
/
Utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include "stdafx.h"
#include <strstream>
#include <string>
#include "include/cryptoki.h"
using namespace std;
class Utility
{
public:
// Converts a PKCS#11 CK_UTF8Char to a string
static string CK_UTF8CHARtoString(CK_UTF8CHAR * value, int len);
// Converts a PKCS#11 CK_VERSION to a string
static string CK_VERSIONtoString(CK_VERSION value);
// Takes a PKCS#11 CK_RV result and throws an error if it is considered a failure.
static void ThrowOnError(CK_RV result, char * source, char * call);
// Parses a hexadecimal numeric string to produce a byte array.
static void HexStringToArray(char * data, const char *hexstring, unsigned int len);
// Converts a byte array to a hexadecimal string
static string ArraytoHexString(char * value, int len);
// Returns a formatted string with the current local date and time.
static string CurrentDateTime();
};