/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void
printUsage(char *prog)
{
printf("Usage: %s [-fp] [-nd]\n" "\t-n: NIST curves\n" "\t-d: non-NIST curves\n" "You have to specify at at least one of n or d.\n" "By default no tests are executed.\n",
prog);
}
/* Performs tests of elliptic curve cryptography over prime fields If *testsfail,thenitprintsanerrormessage,aborts,andreturnsan
* error code. Otherwise, returns 0. */ int
main(int argv, char **argc)
{
SECStatus rv = SECSuccess; int numkats = 0; int i = 0; int nist = 0; int nonnist = 0;
for (i = 1; i < argv; i++) { if (PL_strcasecmp(argc[i], "-n") == 0) {
nist = 1;
} elseif (PL_strcasecmp(argc[i], "-d") == 0) {
nonnist = 1;
} else {
printUsage(argc[0]); return1;
}
} if (!nist && !nonnist) {
printUsage(argc[0]); return1;
}
/* Test P256, P384, P521 */ if (nist) { while (ecdh_testvecs[numkats].curve != ECCurve_pastLastCurve) {
numkats++;
}
printf("1..%d\n", numkats); for (i = 0; ecdh_testvecs[i].curve != ECCurve_pastLastCurve; i++) { if (ectest_ecdh_kat(&ecdh_testvecs[i]) != SECSuccess) {
printf("not okay %d - %s\n", i + 1, ecdh_testvecs[i].name);
rv = SECFailure;
} else {
printf("okay %d - %s\n", i + 1, ecdh_testvecs[i].name);
}
}
}
/* Test KAT for non-NIST curves */ if (nonnist) { for (i = 0; nonnist_testvecs[i].curve != ECCurve_pastLastCurve; i++) { if (ectest_ecdh_kat(&nonnist_testvecs[i]) != SECSuccess) {
printf("not okay %d - %s\n", i + 1, nonnist_testvecs[i].name);
rv = SECFailure;
} else {
printf("okay %d - %s\n", i + 1, nonnist_testvecs[i].name);
}
} for (i = 0; nonnist_testvecs_bad_values[i].curve != ECCurve_pastLastCurve; i++) { if (ectest_validate_point(&nonnist_testvecs_bad_values[i]) == SECSuccess) {
printf("not okay %d - %s\n", i + 1, nonnist_testvecs_bad_values[i].name);
rv = SECFailure;
} else {
printf("okay %d - %s\n", i + 1, nonnist_testvecs_bad_values[i].name);
}
}
}
cleanup:
rv |= SECOID_Shutdown();
if (rv != SECSuccess) {
printf("Error: exiting with error value\n");
} return rv;
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.21Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.