8#include <botan/internal/hash_id.h>
10#include <botan/exceptn.h>
16const uint8_t MD5_PKCS_ID[] = {
17 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10};
19const uint8_t RIPEMD_160_PKCS_ID[] = {
20 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14};
22const uint8_t SHA_1_PKCS_ID[] = {
23 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14};
25const uint8_t SHA_224_PKCS_ID[] = {
26 0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C};
28const uint8_t SHA_256_PKCS_ID[] = {
29 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20};
31const uint8_t SHA_384_PKCS_ID[] = {
32 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30};
34const uint8_t SHA_512_PKCS_ID[] = {
35 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40};
37const uint8_t SHA_512_256_PKCS_ID[] = {
38 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x06, 0x05, 0x00, 0x04, 0x20};
40const uint8_t SHA3_224_PKCS_ID[] = {
41 0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x07, 0x05, 0x00, 0x04, 0x1C};
43const uint8_t SHA3_256_PKCS_ID[] = {
44 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x08, 0x05, 0x00, 0x04, 0x20};
46const uint8_t SHA3_384_PKCS_ID[] = {
47 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x09, 0x05, 0x00, 0x04, 0x30};
49const uint8_t SHA3_512_PKCS_ID[] = {
50 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x0A, 0x05, 0x00, 0x04, 0x40};
52const uint8_t SM3_PKCS_ID[] = {
80 if(
name ==
"Parallel(MD5,SHA-1)") {
81 return std::vector<uint8_t>();
87 return std::vector<uint8_t>(MD5_PKCS_ID, MD5_PKCS_ID +
sizeof(MD5_PKCS_ID));
90 if(
name ==
"RIPEMD-160") {
91 return std::vector<uint8_t>(RIPEMD_160_PKCS_ID, RIPEMD_160_PKCS_ID +
sizeof(RIPEMD_160_PKCS_ID));
95 return std::vector<uint8_t>(SHA_1_PKCS_ID, SHA_1_PKCS_ID +
sizeof(SHA_1_PKCS_ID));
98 if(
name ==
"SHA-224") {
99 return std::vector<uint8_t>(SHA_224_PKCS_ID, SHA_224_PKCS_ID +
sizeof(SHA_224_PKCS_ID));
102 if(
name ==
"SHA-256") {
103 return std::vector<uint8_t>(SHA_256_PKCS_ID, SHA_256_PKCS_ID +
sizeof(SHA_256_PKCS_ID));
106 if(
name ==
"SHA-384") {
107 return std::vector<uint8_t>(SHA_384_PKCS_ID, SHA_384_PKCS_ID +
sizeof(SHA_384_PKCS_ID));
110 if(
name ==
"SHA-512") {
111 return std::vector<uint8_t>(SHA_512_PKCS_ID, SHA_512_PKCS_ID +
sizeof(SHA_512_PKCS_ID));
114 if(
name ==
"SHA-512-256") {
115 return std::vector<uint8_t>(SHA_512_256_PKCS_ID, SHA_512_256_PKCS_ID +
sizeof(SHA_512_256_PKCS_ID));
118 if(
name ==
"SHA-3(224)") {
119 return std::vector<uint8_t>(SHA3_224_PKCS_ID, SHA3_224_PKCS_ID +
sizeof(SHA3_224_PKCS_ID));
122 if(
name ==
"SHA-3(256)") {
123 return std::vector<uint8_t>(SHA3_256_PKCS_ID, SHA3_256_PKCS_ID +
sizeof(SHA3_256_PKCS_ID));
126 if(
name ==
"SHA-3(384)") {
127 return std::vector<uint8_t>(SHA3_384_PKCS_ID, SHA3_384_PKCS_ID +
sizeof(SHA3_384_PKCS_ID));
130 if(
name ==
"SHA-3(512)") {
131 return std::vector<uint8_t>(SHA3_512_PKCS_ID, SHA3_512_PKCS_ID +
sizeof(SHA3_512_PKCS_ID));
135 return std::vector<uint8_t>(SM3_PKCS_ID, SM3_PKCS_ID +
sizeof(SM3_PKCS_ID));
145 if(
name ==
"SHA-1") {
149 if(
name ==
"SHA-224") {
152 if(
name ==
"SHA-256") {
155 if(
name ==
"SHA-384") {
158 if(
name ==
"SHA-512") {
162 if(
name ==
"RIPEMD-160") {
166 if(
name ==
"Whirlpool") {
uint8_t ieee1363_hash_id(std::string_view name)
std::vector< uint8_t > pkcs_hash_id(std::string_view name)