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

Function dsa_test

extra/yassl/taocrypt/test/test.cpp:1242–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1240
1241
1242int dsa_test()
1243{
1244 Source source;
1245 FileSource("../certs/dsa1024.der", source);
1246 if (source.size() == 0) {
1247 FileSource("../../certs/dsa1024.der", source); // for testsuite
1248 if (source.size() == 0) {
1249 FileSource("../../../certs/dsa1024.der", source); // win32 Debug dir
1250 if (source.size() == 0)
1251 err_sys("where's your certs dir?", -89);
1252 }
1253 }
1254
1255 const char msg[] = "this is the message";
1256 byte signature[40];
1257
1258 DSA_PrivateKey priv(source);
1259 DSA_Signer signer(priv);
1260
1261 SHA sha;
1262 byte digest[SHA::DIGEST_SIZE];
1263 sha.Update((byte*)msg, sizeof(msg));
1264 sha.Final(digest);
1265
1266 signer.Sign(digest, signature, rng);
1267
1268 byte encoded[sizeof(signature) + 6];
1269 byte decoded[40];
1270
1271 word32 encSz = EncodeDSA_Signature(signer.GetR(), signer.GetS(), encoded);
1272 DecodeDSA_Signature(decoded, encoded, encSz);
1273
1274 DSA_PublicKey pub(priv);
1275 DSA_Verifier verifier(pub);
1276
1277 if (!verifier.Verify(digest, decoded))
1278 return -90;
1279
1280 return 0;
1281}
1282
1283
1284int pwdbased_test()

Callers 1

taocrypt_testFunction · 0.85

Calls 9

FileSourceClass · 0.85
EncodeDSA_SignatureFunction · 0.85
DecodeDSA_SignatureFunction · 0.85
SignMethod · 0.80
VerifyMethod · 0.80
err_sysFunction · 0.70
sizeMethod · 0.45
UpdateMethod · 0.45
FinalMethod · 0.45

Tested by

no test coverage detected