Eneboo - Documentación para desarrolladores
|
#include <stdio.h>
#include <stdlib.h>
#include "../e_os.h"
#include <string.h>
#include <time.h>
#include <openssl/ec.h>
#include <openssl/engine.h>
#include <openssl/err.h>
#include <openssl/obj_mac.h>
#include <openssl/objects.h>
#include <openssl/rand.h>
#include <openssl/bn.h>
'defines' | |
#define | ABORT |
#define | TIMING_BASE_PT 0 |
#define | TIMING_RAND_PT 1 |
#define | TIMING_SIMUL 2 |
#define | CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) |
#define | CHAR2_CURVE_TEST(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) |
Funciones | |
void | prime_field_tests (void) |
void | char2_field_tests (void) |
void | internal_curve_test (void) |
int | main (int argc, char *argv[]) |
#define ABORT |
do { \ fflush(stdout); \ fprintf(stderr, "%s:%d: ABORT\n", __FILE__, __LINE__); \ ERR_print_errors_fp(stderr); \ EXIT(1); \ } while (0)
#define CHAR2_CURVE_TEST | ( | _name, | |
_p, | |||
_a, | |||
_b, | |||
_x, | |||
_y, | |||
_y_bit, | |||
_order, | |||
_cof, | |||
_degree, | |||
_variable | |||
) |
if (!BN_hex2bn(&p, _p)) ABORT; \ if (!BN_hex2bn(&a, _a)) ABORT; \ if (!BN_hex2bn(&b, _b)) ABORT; \ if (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) ABORT; \ CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \ fprintf(stdout, "verify degree ..."); \ if (EC_GROUP_get_degree(group) != _degree) ABORT; \ fprintf(stdout, " ok\n"); \ fprintf(stdout, "verify group order ..."); \ fflush(stdout); \ if (!EC_GROUP_get_order(group, z, ctx)) ABORT; \ if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ fprintf(stdout, "."); \ fflush(stdout); \ /* if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; */ \ if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ fprintf(stdout, " ok\n"); \ if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \ if (!EC_GROUP_copy(_variable, group)) ABORT;
#define CHAR2_CURVE_TEST_INTERNAL | ( | _name, | |
_p, | |||
_a, | |||
_b, | |||
_x, | |||
_y, | |||
_y_bit, | |||
_order, | |||
_cof, | |||
_degree, | |||
_variable | |||
) |
if (!BN_hex2bn(&x, _x)) ABORT; \ if (!BN_hex2bn(&y, _y)) ABORT; \ if (!EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; \ if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; \ if (!BN_hex2bn(&z, _order)) ABORT; \ if (!BN_hex2bn(&cof, _cof)) ABORT; \ if (!EC_GROUP_set_generator(group, P, z, cof)) ABORT; \ fprintf(stdout, "\n%s -- Generator:\n x = 0x", _name); \ BN_print_fp(stdout, x); \ fprintf(stdout, "\n y = 0x"); \ BN_print_fp(stdout, y); \ fprintf(stdout, "\n");
#define TIMING_BASE_PT 0 |
#define TIMING_RAND_PT 1 |
#define TIMING_SIMUL 2 |
void char2_field_tests | ( | void | ) |
void internal_curve_test | ( | void | ) |
void prime_field_tests | ( | void | ) |