26 #include "../ec_extra/internal.h"
27 #include "../fipsmodule/bn/internal.h"
28 #include "../fipsmodule/ec/internal.h"
61 const uint8_t *h_bytes,
size_t h_len,
65 if (
method->group == NULL) {
72 method->prefix_point = prefix_point;
81 &
method->group->generator->raw) ||
97 out_x, &
method->h_precomp, out_y, NULL,
163 EC_SCALAR scalars[3] = {*scalar0, *scalar1, *scalar2};
169 CBB *out_private,
CBB *out_public) {
180 const EC_SCALAR *scalars[] = {&x0, &y0, &x1, &y1, &xs, &ys};
250 &
method->h_precomp, &
key->y0, NULL, NULL) ||
253 &
method->h_precomp, &
key->y1, NULL, NULL) ||
256 &
method->h_precomp, &
key->ys, NULL, NULL) ||
262 key->pub0 = pub_affine[0];
263 key->pub1 = pub_affine[1];
264 key->pubs = pub_affine[2];
272 if (pretokens == NULL) {
277 for (
size_t i = 0;
i <
count;
i++) {
280 if (pretoken == NULL ||
281 !sk_TRUST_TOKEN_PRETOKEN_push(pretokens, pretoken)) {
350 static const uint8_t kDLEQ2Label[] =
"DLEQ2";
385 static const uint8_t kDLEQOR2Label[] =
"DLEQOR2";
393 !
CBB_add_bytes(&cbb, kDLEQOR2Label,
sizeof(kDLEQOR2Label)) ||
419 static const uint8_t kDLEQBatchLabel[] =
"DLEQ BATCH";
420 if (
index > 0xffff) {
432 !
CBB_add_bytes(&cbb, kDLEQBatchLabel,
sizeof(kDLEQBatchLabel)) ||
495 BN_ULONG mask = ((BN_ULONG)0) - (private_metadata & 1);
520 &vo, &pubo_precomp, &minus_co) ||
527 jacobians[idx_T] = *
T;
528 jacobians[idx_S] = *
S;
529 jacobians[idx_W] = *
W;
530 jacobians[idx_Ws] = *Ws;
545 &affines[idx_Ws], &affines[idx_Ks0], &affines[idx_Ks1]) ||
547 &affines[idx_S], &affines[idx_W], &K00, &K01, &K10,
693 jacobians[idx_T] = *
T;
694 jacobians[idx_S] = *
S;
695 jacobians[idx_W] = *
W;
696 jacobians[idx_Ws] = *Ws;
704 &affines[idx_S], &affines[idx_Ws], &affines[idx_Ks0],
705 &affines[idx_Ks1])) {
717 &affines[idx_T], &affines[idx_S], &affines[idx_W],
718 &affines[idx_K00], &affines[idx_K01], &affines[idx_K10],
719 &affines[idx_K11])) {
736 size_t num_requested,
size_t num_to_issue,
739 if (num_requested < num_to_issue) {
744 if (num_to_issue > ((
size_t)-1) /
sizeof(
EC_RAW_POINT) ||
745 num_to_issue > ((
size_t)-1) /
sizeof(
EC_SCALAR)) {
771 for (
size_t i = 0;
i < num_to_issue;
i++) {
781 BN_ULONG mask = ((BN_ULONG)0) - (private_metadata & 1);
790 if (!
method->hash_s(
group, &jacobians[0], &Tp_affine, s) ||
792 &jacobians[0], &yb, NULL, NULL) ||
794 &jacobians[0], &
key->ys, NULL, NULL) ||
812 Sps[
i] = jacobians[0];
813 Wps[
i] = jacobians[1];
814 Wsps[
i] = jacobians[2];
824 for (
size_t i = 0;
i < num_to_issue;
i++) {
849 &Wsp_batch, private_metadata) ||
856 size_t token_len = point_len;
857 if (
method->prefix_point) {
860 if (!
CBS_skip(
cbs, token_len * (num_requested - num_to_issue))) {
883 if (
count > sk_TRUST_TOKEN_PRETOKEN_num(pretokens)) {
920 for (
size_t i = 0;
i <
count;
i++) {
922 sk_TRUST_TOKEN_PRETOKEN_value(pretokens,
i);
984 !sk_TRUST_TOKEN_push(
ret, token)) {
994 for (
size_t i = 0;
i <
count;
i++) {
1002 NULL, Tps, es,
count) ||
1004 NULL, Sps, es,
count) ||
1006 NULL, Wps, es,
count) ||
1008 NULL, Wsps, es,
count)) {
1073 &S_precomp, &
key->ys, NULL, NULL) ||
1081 &
key->y0, NULL, NULL) ||
1083 &
key->y1, NULL, NULL)) {
1089 const int is_valid = is_W0 ^ is_W1;
1096 *out_private_metadata = is_W1;
1105 const uint8_t kHashTLabel[] =
"PMBTokens Experiment V1 HashT";
1113 const uint8_t kHashSLabel[] =
"PMBTokens Experiment V1 HashS";
1138 const uint8_t kHashCLabel[] =
"PMBTokens Experiment V1 HashC";
1151 0x04, 0x82, 0xd5, 0x68, 0xf5, 0x39, 0xf6, 0x08, 0x19, 0xa1, 0x75,
1152 0x9f, 0x98, 0xb5, 0x10, 0xf5, 0x0b, 0x9d, 0x2b, 0xe1, 0x64, 0x4d,
1153 0x02, 0x76, 0x18, 0x11, 0xf8, 0x2f, 0xd3, 0x33, 0x25, 0x1f, 0x2c,
1154 0xb8, 0xf6, 0xf1, 0x9e, 0x93, 0x85, 0x79, 0xb3, 0xb7, 0x81, 0xa3,
1155 0xe6, 0x23, 0xc3, 0x1c, 0xff, 0x03, 0xd9, 0x40, 0x6c, 0xec, 0xe0,
1156 0x4d, 0xea, 0xdf, 0x9d, 0x94, 0xd1, 0x87, 0xab, 0x27, 0xf7, 0x4f,
1157 0x53, 0xea, 0xa3, 0x18, 0x72, 0xb9, 0xd1, 0x56, 0xa0, 0x4e, 0x81,
1158 0xaa, 0xeb, 0x1c, 0x22, 0x6d, 0x39, 0x1c, 0x5e, 0xb1, 0x27, 0xfc,
1159 0x87, 0xc3, 0x95, 0xd0, 0x13, 0xb7, 0x0b, 0x5c, 0xc7,
1209 size_t num_requested,
size_t num_to_issue,
1215 num_to_issue, private_metadata);
1237 out_private_metadata, token, token_len);
1255 const uint8_t kHashTLabel[] =
"PMBTokens Experiment V2 HashT";
1263 const uint8_t kHashSLabel[] =
"PMBTokens Experiment V2 HashS";
1288 const uint8_t kHashCLabel[] =
"PMBTokens Experiment V2 HashC";
1301 0x04, 0xbc, 0x27, 0x24, 0x99, 0xfa, 0xc9, 0xa4, 0x74, 0x6f, 0xf9,
1302 0x07, 0x81, 0x55, 0xf8, 0x1f, 0x6f, 0xda, 0x09, 0xe7, 0x8c, 0x5d,
1303 0x9e, 0x4e, 0x14, 0x7c, 0x53, 0x14, 0xbc, 0x7e, 0x29, 0x57, 0x92,
1304 0x17, 0x94, 0x6e, 0xd2, 0xdf, 0xa5, 0x31, 0x1b, 0x4e, 0xb7, 0xfc,
1305 0x93, 0xe3, 0x6e, 0x14, 0x1f, 0x4f, 0x14, 0xf3, 0xe5, 0x47, 0x61,
1306 0x1c, 0x2c, 0x72, 0x25, 0xf0, 0x4a, 0x45, 0x23, 0x2d, 0x57, 0x93,
1307 0x0e, 0xb2, 0x55, 0xb8, 0x57, 0x25, 0x4c, 0x1e, 0xdb, 0xfd, 0x58,
1308 0x70, 0x17, 0x9a, 0xbb, 0x9e, 0x5e, 0x93, 0x9e, 0x92, 0xd3, 0xe8,
1309 0x25, 0x62, 0xbf, 0x59, 0xb2, 0xd2, 0x3d, 0x71, 0xff
1359 size_t num_requested,
size_t num_to_issue,
1365 num_to_issue, private_metadata);
1387 out_private_metadata, token, token_len);