12#ifndef OPENVPN_PKI_PKCS1_H
13#define OPENVPN_PKI_PKCS1_H
24const unsigned char MD2[] = {
25 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08,
26 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
27 0x02, 0x02, 0x05, 0x00, 0x04, 0x10
29const unsigned char MD5[] = {
30 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08,
31 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
32 0x02, 0x05, 0x05, 0x00, 0x04, 0x10
34const unsigned char SHA1[] = {
35 0x30, 0x21, 0x30, 0x09, 0x06, 0x05,
36 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05,
39const unsigned char SHA256[] = {
40 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09,
41 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
42 0x04, 0x02, 0x01, 0x05, 0x00, 0x04,
44const unsigned char SHA384[] = {
45 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09,
46 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
47 0x04, 0x02, 0x02, 0x05, 0x00, 0x04,
50const unsigned char SHA512[] = {
51 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09,
52 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
53 0x04, 0x02, 0x03, 0x05, 0x00, 0x04,
103 if (
match(buf, MD2,
sizeof(MD2)))
105 else if (
match(buf, MD5,
sizeof(MD5)))
107 else if (
match(buf, SHA1,
sizeof(SHA1)))
109 else if (
match(buf, SHA256,
sizeof(SHA256)))
111 else if (
match(buf, SHA384,
sizeof(SHA384)))
113 else if (
match(buf, SHA512,
sizeof(SHA512)))
120 bool match(
Buffer &buf,
const unsigned char *data,
const size_t size)
const
122 if (buf.
size() < size)
124 else if (std::memcmp(buf.
c_data(), data, size) == 0)
const T * c_data() const
Returns a const pointer to the start of the buffer.
size_t size() const
Returns the size of the buffer in T objects.
void advance(const size_t delta)
Advances the buffer by the specified delta.
Parse(const T none, const T md2, const T md5, const T sha1, const T sha256, const T sha384, const T sha512)
Parse(const T none, const T md5, const T sha1, const T sha256, const T sha384, const T sha512)
bool match(Buffer &buf, const unsigned char *data, const size_t size) const
T alg_from_prefix(Buffer &buf) const