31 #include "../crypto/internal.h"
32 #include "../crypto/test/file_test.h"
33 #include "../crypto/test/test_util.h"
38 const bool validate = *
reinterpret_cast<bool *
>(
arg);
41 size_t digest_len = 0;
43 if (t->HasInstruction(
"EB - SHA224")) {
46 }
else if (t->HasInstruction(
"EC - SHA256")) {
49 }
else if (t->HasInstruction(
"ED - SHA384")) {
52 }
else if (t->HasInstruction(
"EE - SHA512")) {
59 if (!t->HasAttribute(
"COUNT")) {
63 bssl::UniquePtr<BIGNUM> their_x(
GetBIGNUM(t,
"QeCAVSx"));
64 bssl::UniquePtr<BIGNUM> their_y(
GetBIGNUM(t,
"QeCAVSy"));
67 if (!their_x || !their_y || !ec_key || !
ctx) {
75 group, their_point.get(), their_x.get(), their_y.get(),
ctx.get())) {
80 bssl::UniquePtr<BIGNUM> our_k(
GetBIGNUM(t,
"deIUT"));
84 !t->HasAttribute(
"QeIUTx") ||
85 !t->HasAttribute(
"QeIUTy")) {
99 std::vector<uint8_t> expected_shared_bytes;
100 if (!t->GetBytes(&expected_shared_bytes,
"CAVSHashZZ")) {
104 digest_len == expected_shared_bytes.size() &&
105 OPENSSL_memcmp(digest, expected_shared_bytes.data(), digest_len) == 0;
107 printf(
"%sIUTHashZZ = %s\r\nResult = %c\r\n\r\n\r\n",
108 t->CurrentTestToString().c_str(),
113 bssl::UniquePtr<BIGNUM>
x(
BN_new());
114 bssl::UniquePtr<BIGNUM>
y(
BN_new());
120 bssl::UniquePtr<char> x_hex(
BN_bn2hex(
x.get()));
121 bssl::UniquePtr<char> y_hex(
BN_bn2hex(
y.get()));
123 printf(
"%sQeIUTx = %s\r\nQeIUTy = %s\r\nHashZZ = %s\r\n",
124 t->CurrentTestToString().c_str(), x_hex.get(), y_hex.get(),
133 fprintf(
stderr,
"usage: %s (validity|function) <test file>\n",
139 if (strcmp(argv[1],
"validity") == 0) {
141 }
else if (strcmp(argv[1],
"function") == 0) {
144 fprintf(
stderr,
"Unknown test type: %s\n", argv[1]);
150 opts.arg = &validity;
154 opts.is_kas_test =
true;