MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / SetAlgoID

Method SetAlgoID

extra/yassl/taocrypt/src/asn.cpp:1076–1143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1074
1075
1076word32 DER_Encoder::SetAlgoID(HashType aOID, byte* output)
1077{
1078 // adding TAG_NULL and 0 to end
1079 static const byte shaAlgoID[] = { 0x2b, 0x0e, 0x03, 0x02, 0x1a,
1080 0x05, 0x00 };
1081 static const byte md5AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
1082 0x02, 0x05, 0x05, 0x00 };
1083 static const byte md2AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
1084 0x02, 0x02, 0x05, 0x00};
1085 static const byte sha256AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
1086 0x04, 0x02, 0x01, 0x05, 0x00 };
1087 static const byte sha384AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
1088 0x04, 0x02, 0x02, 0x05, 0x00 };
1089 static const byte sha512AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
1090 0x04, 0x02, 0x03, 0x05, 0x00 };
1091 int algoSz = 0;
1092 const byte* algoName = 0;
1093
1094 switch (aOID) {
1095 case SHAh:
1096 algoSz = sizeof(shaAlgoID);
1097 algoName = shaAlgoID;
1098 break;
1099
1100 case SHA256h:
1101 algoSz = sizeof(sha256AlgoID);
1102 algoName = sha256AlgoID;
1103 break;
1104
1105 case SHA384h:
1106 algoSz = sizeof(sha384AlgoID);
1107 algoName = sha384AlgoID;
1108 break;
1109
1110 case SHA512h:
1111 algoSz = sizeof(sha512AlgoID);
1112 algoName = sha512AlgoID;
1113 break;
1114
1115 case MD2h:
1116 algoSz = sizeof(md2AlgoID);
1117 algoName = md2AlgoID;
1118 break;
1119
1120 case MD5h:
1121 algoSz = sizeof(md5AlgoID);
1122 algoName = md5AlgoID;
1123 break;
1124
1125 default:
1126 error_.SetError(UNKOWN_HASH_E);
1127 return 0;
1128 }
1129
1130
1131 byte ID_Length[MAX_LENGTH_SZ];
1132 word32 idSz = SetLength(algoSz - 2, ID_Length); // don't include TAG_NULL/0
1133

Callers

nothing calls this directly

Calls 3

SetLengthFunction · 0.85
SetSequenceFunction · 0.85
SetErrorMethod · 0.45

Tested by

no test coverage detected