Lines Matching refs:ret
43 #define OPENMP_EG(ret, err) do { \ argument
44 if(ret){ \
49 #define OPENMP_MUST_HAVE(cnd, ret, err) do { \ argument
50 ret = !!(cnd); \
51 ret = -((~ret) & 1); \
52 OPENMP_EG(ret, err); \
60 #define OPENMP_EG(ret, err) do { \ argument
61 EG(ret, err); \
63 #define OPENMP_MUST_HAVE(cnd, ret, err) do { \ argument
64 MUST_HAVE(cnd, ret, err); \
77 int ret; in check_wycheproof_ecdsa() local
94 ret = local_memset(&pub_key, 0, sizeof(pub_key)); OPENMP_EG(ret, err); in check_wycheproof_ecdsa()
95 ret = local_memset(¶ms, 0, sizeof(params)); OPENMP_EG(ret, err); in check_wycheproof_ecdsa()
98 ret = import_params(¶ms, t->curve); in check_wycheproof_ecdsa()
99 if (ret) { in check_wycheproof_ecdsa()
101 ret = -1; in check_wycheproof_ecdsa()
102 OPENMP_EG(ret, err); in check_wycheproof_ecdsa()
106 …ret = ec_pub_key_import_from_aff_buf(&pub_key, ¶ms, t->pubkey, (u8)(t->pubkeylen), t->sig_alg); in check_wycheproof_ecdsa()
107 if (ret) { in check_wycheproof_ecdsa()
109 ret = -1; in check_wycheproof_ecdsa()
110 OPENMP_EG(ret, err); in check_wycheproof_ecdsa()
114 …ret = ec_verify(t->sig, (u8)(t->siglen), &pub_key, t->msg, t->msglen, t->sig_alg, t->hash, NULL, 0… in check_wycheproof_ecdsa()
116 if ((t->result == 1) && ret) { in check_wycheproof_ecdsa()
119 ret = -1; in check_wycheproof_ecdsa()
120 OPENMP_EG(ret, err); in check_wycheproof_ecdsa()
123 if ((t->result == -1) && !ret) { in check_wycheproof_ecdsa()
126 ret = -1; in check_wycheproof_ecdsa()
127 OPENMP_EG(ret, err); in check_wycheproof_ecdsa()
131 if(ret){ in check_wycheproof_ecdsa()
138 ext_printf("\t[~] ECDSA test %d / %s (verification %d while acceptable)\n", i, t->name, ret); in check_wycheproof_ecdsa()
144 ret = 0; in check_wycheproof_ecdsa()
148 return ret; in check_wycheproof_ecdsa()
161 int ret; in check_wycheproof_eddsa() local
184 ret = local_memset(&pub_key, 0, sizeof(pub_key)); OPENMP_EG(ret, err); in check_wycheproof_eddsa()
185 ret = local_memset(&priv_key, 0, sizeof(priv_key)); OPENMP_EG(ret, err); in check_wycheproof_eddsa()
186 ret = local_memset(¶ms, 0, sizeof(params)); OPENMP_EG(ret, err); in check_wycheproof_eddsa()
189 ret = import_params(¶ms, t->curve); in check_wycheproof_eddsa()
190 if (ret) { in check_wycheproof_eddsa()
192 ret = -1; in check_wycheproof_eddsa()
193 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
197 ret = eddsa_import_pub_key(&pub_key, t->pubkey, (u8)(t->pubkeylen), ¶ms, t->sig_alg); in check_wycheproof_eddsa()
198 if (ret) { in check_wycheproof_eddsa()
200 ret = -1; in check_wycheproof_eddsa()
201 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
204 ret = eddsa_import_priv_key(&priv_key, t->privkey, (u8)(t->privkeylen), ¶ms, t->sig_alg); in check_wycheproof_eddsa()
205 if (ret) { in check_wycheproof_eddsa()
207 ret = -1; in check_wycheproof_eddsa()
208 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
211 ret = eddsa_init_pub_key(&pub_key_check, &priv_key); in check_wycheproof_eddsa()
212 if (ret) { in check_wycheproof_eddsa()
214 ret = -1; in check_wycheproof_eddsa()
215 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
218 ret = eddsa_export_pub_key(&pub_key, exported_pub_key, (u8)(t->pubkeylen)); in check_wycheproof_eddsa()
219 if(ret){ in check_wycheproof_eddsa()
221 ret = -1; in check_wycheproof_eddsa()
222 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
225 ret = are_equal(t->pubkey, &exported_pub_key, (u8)(t->pubkeylen), &check); OPENMP_EG(ret, err); in check_wycheproof_eddsa()
228 ret = -1; in check_wycheproof_eddsa()
229 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
232 …ret = ec_verify(t->sig, (u8)(t->siglen), &pub_key, t->msg, t->msglen, t->sig_alg, t->hash, NULL, 0… in check_wycheproof_eddsa()
234 if ((t->result == 1) && ret) { in check_wycheproof_eddsa()
237 ret = -1; in check_wycheproof_eddsa()
238 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
241 if ((t->result == -1) && !ret) { in check_wycheproof_eddsa()
244 ret = -1; in check_wycheproof_eddsa()
245 OPENMP_EG(ret, err); in check_wycheproof_eddsa()
250 if(ret){ in check_wycheproof_eddsa()
257 ext_printf("\t[~] EDDSA test %d / %s (verification %d while acceptable)\n", i, t->name, ret); in check_wycheproof_eddsa()
264 ret = 0; in check_wycheproof_eddsa()
268 return ret; in check_wycheproof_eddsa()
281 int ret; in check_wycheproof_xdh() local
306 OPENMP_MUST_HAVE(((t->curve) == &wei25519_str_params), ret, err); in check_wycheproof_xdh()
312 OPENMP_MUST_HAVE(((t->curve) == &wei448_str_params), ret, err); in check_wycheproof_xdh()
318 ret = -1; in check_wycheproof_xdh()
319 OPENMP_EG(ret, err); in check_wycheproof_xdh()
326 ret = -1; in check_wycheproof_xdh()
327 OPENMP_EG(ret, err); in check_wycheproof_xdh()
337 ret = -1; in check_wycheproof_xdh()
338 OPENMP_EG(ret, err); in check_wycheproof_xdh()
348 ret = -1; in check_wycheproof_xdh()
349 OPENMP_EG(ret, err); in check_wycheproof_xdh()
359 ret = -1; in check_wycheproof_xdh()
360 OPENMP_EG(ret, err); in check_wycheproof_xdh()
369 ret = x25519_init_pub_key(t->privkey, pubkey_check); in check_wycheproof_xdh()
370 if(ret){ in check_wycheproof_xdh()
373 ret = -1; in check_wycheproof_xdh()
374 OPENMP_EG(ret, err); in check_wycheproof_xdh()
378 ret = are_equal(t->ourpubkey, pubkey_check, alglen, &check); OPENMP_EG(ret, err); in check_wycheproof_xdh()
382 ret = -1; in check_wycheproof_xdh()
383 OPENMP_EG(ret, err); in check_wycheproof_xdh()
387 ret = x25519_derive_secret(t->privkey, t->peerpubkey, sharedsecret_check); in check_wycheproof_xdh()
388 if(ret){ in check_wycheproof_xdh()
402 ret = -1; in check_wycheproof_xdh()
403 OPENMP_EG(ret, err); in check_wycheproof_xdh()
408 ret = -1; in check_wycheproof_xdh()
409 OPENMP_EG(ret, err); in check_wycheproof_xdh()
412 ret = are_equal(t->sharedsecret, sharedsecret_check, alglen, &check); OPENMP_EG(ret, err); in check_wycheproof_xdh()
416 ret = -1; in check_wycheproof_xdh()
417 OPENMP_EG(ret, err); in check_wycheproof_xdh()
424 ret = x448_init_pub_key(t->privkey, pubkey_check); in check_wycheproof_xdh()
425 if(ret){ in check_wycheproof_xdh()
428 ret = -1; in check_wycheproof_xdh()
429 OPENMP_EG(ret, err); in check_wycheproof_xdh()
433 ret = are_equal(t->ourpubkey, pubkey_check, alglen, &check); OPENMP_EG(ret, err); in check_wycheproof_xdh()
437 ret = -1; in check_wycheproof_xdh()
438 OPENMP_EG(ret, err); in check_wycheproof_xdh()
442 ret = x448_derive_secret(t->privkey, t->peerpubkey, sharedsecret_check); in check_wycheproof_xdh()
443 if(ret){ in check_wycheproof_xdh()
457 OPENMP_EG(ret, err); in check_wycheproof_xdh()
462 ret = -1; in check_wycheproof_xdh()
463 OPENMP_EG(ret, err); in check_wycheproof_xdh()
466 ret = are_equal(t->sharedsecret, sharedsecret_check, alglen, &check); OPENMP_EG(ret, err); in check_wycheproof_xdh()
470 ret = -1; in check_wycheproof_xdh()
471 OPENMP_EG(ret, err); in check_wycheproof_xdh()
487 ret = 0; in check_wycheproof_xdh()
491 return ret; in check_wycheproof_xdh()
500 int ret, sign, check; in uncompress_ecc_point() local
505 MUST_HAVE((params != NULL) && (peerpubkey != NULL) && (serialized_pub_key != NULL), ret, err); in uncompress_ecc_point()
508 MUST_HAVE((serialized_pub_key_size == (2 * peerpubkeylen)), ret, err); in uncompress_ecc_point()
511 MUST_HAVE(((compression == 0x02) || (compression == 0x03)), ret, err); in uncompress_ecc_point()
514 ret = fp_init_from_buf(&x, &(params->ec_fp), peerpubkey, peerpubkeylen); EG(ret, err); in uncompress_ecc_point()
515 ret = fp_init(&tmp, &(params->ec_fp)); EG(ret, err); in uncompress_ecc_point()
517 ret = aff_pt_y_from_x(&tmp, &x, &x, &(params->ec_curve)); EG(ret, err); in uncompress_ecc_point()
522 ret = fp_cmp(&x, &tmp, &check); EG(ret, err); in uncompress_ecc_point()
527 …ret = local_memcpy(&serialized_pub_key[0], &peerpubkey[0], (serialized_pub_key_size / 2)); EG(ret,… in uncompress_ecc_point()
528 …ret = fp_export_to_buf(&serialized_pub_key[(serialized_pub_key_size / 2)], (serialized_pub_key_siz… in uncompress_ecc_point()
535 return ret; in uncompress_ecc_point()
545 int ret; in check_wycheproof_ecdh() local
574 ret = local_memset(&peerpub_key, 0, sizeof(peerpub_key)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
575 ret = local_memset(&ourpub_key, 0, sizeof(ourpub_key)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
576 ret = local_memset(&ourpub_key_check, 0, sizeof(ourpub_key_check)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
577 ret = local_memset(&priv_key, 0, sizeof(priv_key)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
578 ret = local_memset(¶ms, 0, sizeof(params)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
579 ret = local_memset(sharedsecret_check, 0, sizeof(sharedsecret_check)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
580 ret = local_memset(serialized_pub_key, 0, sizeof(serialized_pub_key)); OPENMP_EG(ret, err); in check_wycheproof_ecdh()
583 ret = import_params(¶ms, t->curve); in check_wycheproof_ecdh()
584 if (ret) { in check_wycheproof_ecdh()
586 ret = -1; in check_wycheproof_ecdh()
587 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
591 ret = ecccdh_shared_secret_size(¶ms, &sharedsecretsize); in check_wycheproof_ecdh()
592 if (ret) { in check_wycheproof_ecdh()
594 ret = -1; in check_wycheproof_ecdh()
595 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
597 OPENMP_MUST_HAVE((sharedsecretsize <= sizeof(sharedsecret_check)), ret, err); in check_wycheproof_ecdh()
598 ret = ecccdh_serialized_pub_key_size(¶ms, &serialized_pub_key_size); in check_wycheproof_ecdh()
599 if (ret) { in check_wycheproof_ecdh()
601 ret = -1; in check_wycheproof_ecdh()
602 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
604 OPENMP_MUST_HAVE((serialized_pub_key_size <= sizeof(serialized_pub_key)), ret, err); in check_wycheproof_ecdh()
605 OPENMP_MUST_HAVE((serialized_pub_key_size <= sizeof(serialized_pub_key_check)), ret, err); in check_wycheproof_ecdh()
608 …ret = ec_priv_key_import_from_buf(&priv_key, ¶ms, t->privkey, (u8)(t->privkeylen), t->ecdh_alg… in check_wycheproof_ecdh()
609 if (ret) { in check_wycheproof_ecdh()
611 ret = -1; in check_wycheproof_ecdh()
612 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
617 …ret = ec_pub_key_import_from_aff_buf(&ourpub_key, ¶ms, t->ourpubkey, (u8)(t->ourpubkeylen), t-… in check_wycheproof_ecdh()
618 if (ret && (t->result >= 0)) { in check_wycheproof_ecdh()
621 ret = -1; in check_wycheproof_ecdh()
622 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
625 ret = ecccdh_init_pub_key(&ourpub_key_check, &priv_key); in check_wycheproof_ecdh()
626 if (ret) { in check_wycheproof_ecdh()
628 ret = -1; in check_wycheproof_ecdh()
629 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
632 ret = ecccdh_serialize_pub_key(&ourpub_key, serialized_pub_key, serialized_pub_key_size); in check_wycheproof_ecdh()
633 if (ret){ in check_wycheproof_ecdh()
635 ret = -1; in check_wycheproof_ecdh()
636 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
638 …ret = ecccdh_serialize_pub_key(&ourpub_key_check, serialized_pub_key_check, serialized_pub_key_siz… in check_wycheproof_ecdh()
639 if (ret){ in check_wycheproof_ecdh()
641 ret = -1; in check_wycheproof_ecdh()
642 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
644 …ret = are_equal(serialized_pub_key, serialized_pub_key_check, serialized_pub_key_size, &check); OP… in check_wycheproof_ecdh()
648 ret = -1; in check_wycheproof_ecdh()
649 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
656 …ret = uncompress_ecc_point(¶ms, t->peerpubkey, (u8)(t->peerpubkeylen), serialized_pub_key, ser… in check_wycheproof_ecdh()
657 if ((ret) && (t->result >= 0)) { in check_wycheproof_ecdh()
660 ret = -1; in check_wycheproof_ecdh()
661 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
669 ret = -1; in check_wycheproof_ecdh()
670 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
672 …ret = local_memcpy(serialized_pub_key, t->peerpubkey, serialized_pub_key_size); OPENMP_EG(ret, err… in check_wycheproof_ecdh()
675 …ret = ecccdh_derive_secret(&priv_key, serialized_pub_key, serialized_pub_key_size, sharedsecret_ch… in check_wycheproof_ecdh()
676 if ((ret) && (t->result >= 0)) { in check_wycheproof_ecdh()
679 ret = -1; in check_wycheproof_ecdh()
680 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
682 if((!ret) && (t->result == -1)){ in check_wycheproof_ecdh()
685 ret = -1; in check_wycheproof_ecdh()
686 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
694 ret = -1; in check_wycheproof_ecdh()
695 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
698 …ret = are_equal(sharedsecret_check, t->sharedsecret, sharedsecretsize, &check); OPENMP_EG(ret, err… in check_wycheproof_ecdh()
702 ret = -1; in check_wycheproof_ecdh()
703 OPENMP_EG(ret, err); in check_wycheproof_ecdh()
717 ret = 0; in check_wycheproof_ecdh()
721 return ret; in check_wycheproof_ecdh()
734 int ret; in check_wycheproof_hmac() local
755 ret = local_memset(&hmac_res, 0, sizeof(hmac_res)); OPENMP_EG(ret, err); in check_wycheproof_hmac()
758 ret = hmac(t->key, t->keylen, t->hash, t->msg, t->msglen, hmac_res, &hlen); in check_wycheproof_hmac()
759 if (ret) { in check_wycheproof_hmac()
762 ret = -1; in check_wycheproof_hmac()
763 OPENMP_EG(ret, err); in check_wycheproof_hmac()
768 ret = -1; in check_wycheproof_hmac()
769 OPENMP_EG(ret, err); in check_wycheproof_hmac()
772 ret = are_equal(hmac_res, t->tag, t->taglen, &check); OPENMP_EG(ret, err); in check_wycheproof_hmac()
776 ret = -1; in check_wycheproof_hmac()
777 OPENMP_EG(ret, err); in check_wycheproof_hmac()
790 ret = 0; in check_wycheproof_hmac()
794 return ret; in check_wycheproof_hmac()