Loading tools/itscertgen/generator/certgen.c +0 −1 Original line number Original line Diff line number Diff line Loading @@ -1393,7 +1393,6 @@ static int location_tag (cxml_handler_t* const _h, cxml_tag_t * const tag) absolute = cstrequal(v, "absolute"); absolute = cstrequal(v, "absolute"); v = cxml_tag_attr_value(tag, "latitude"); v = cxml_tag_attr_value(tag, "latitude"); int relative = 1; if(v == NULL){ if(v == NULL){ fprintf(stderr, "ERROR: Latitude must be specified for location.\n"); fprintf(stderr, "ERROR: Latitude must be specified for location.\n"); return -1; return -1; Loading tools/itscertgen/generator/ecc_openssl.c +21 −13 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <openssl/ecdsa.h> #include <openssl/ecdsa.h> #include <string.h> #include <string.h> #define FIELD_SIZE 32 #define ARRAYSIZE(A) (sizeof(A)/sizeof(A[0])) #define ARRAYSIZE(A) (sizeof(A)/sizeof(A[0])) static char * _bin2hex(char * hex, int hlen, const char * bin, int blen); static char * _bin2hex(char * hex, int hlen, const char * bin, int blen); Loading Loading @@ -172,6 +174,7 @@ int ecc_api_key_public(void* key, char * px, char * py) BIGNUM x, y; BIGNUM x, y; int bcount = -1; int bcount = -1; if( key && px && py ) { ecgroup = EC_KEY_get0_group(eckey); ecgroup = EC_KEY_get0_group(eckey); ecpoint = EC_KEY_get0_public_key(eckey); ecpoint = EC_KEY_get0_public_key(eckey); Loading @@ -179,16 +182,17 @@ int ecc_api_key_public(void* key, char * px, char * py) BN_init(&x); BN_init(&y); BN_init(&x); BN_init(&y); if (EC_POINT_get_affine_coordinates_GFp(ecgroup, ecpoint, &x, &y, NULL)){ if (EC_POINT_get_affine_coordinates_GFp(ecgroup, ecpoint, &x, &y, NULL)){ bcount = BN_num_bytes(&x); bcount = BN_num_bytes(&x); if (px){ for(; bcount < FIELD_SIZE; bcount++) *(px++) = 0; // add padding with zeros BN_bn2bin(&x, (unsigned char*)px); BN_bn2bin(&x, (unsigned char*)px); } bcount = BN_num_bytes(&y); bcount = BN_num_bytes(&y); if (py){ for(; bcount < FIELD_SIZE; bcount++) *(py++) = 0; // add padding with zeros BN_bn2bin(&y, (unsigned char*)py); BN_bn2bin(&y, (unsigned char*)py); } } } BN_clear_free(&x); BN_clear_free(&y); BN_clear_free(&x); BN_clear_free(&y); } return bcount; return bcount; } } Loading Loading @@ -446,12 +450,16 @@ int ecc_sign(void * key, const char * data, int length, char ** psig, int max ecdsa = ECDSA_do_sign(hash, 32, eckey); ecdsa = ECDSA_do_sign(hash, 32, eckey); EC_KEY_free(eckey); EC_KEY_free(eckey); if (ecdsa){ if (ecdsa){ int bcount; int i, bcount; *(sig++) = 0; // ECC_POINT type (x_coordinate_only) *(sig++) = 0; // ECC_POINT type (x_coordinate_only) bcount = BN_num_bytes(ecdsa->r); bcount = BN_num_bytes(ecdsa->r); for(i=bcount; i < FIELD_SIZE; i++) *(sig++) = 0; // add padding with zeros BN_bn2bin(ecdsa->r, sig); BN_bn2bin(ecdsa->r, sig); sig += bcount; sig += bcount; bcount = BN_num_bytes(ecdsa->s); bcount = BN_num_bytes(ecdsa->s); for(i=bcount; i < FIELD_SIZE; i++) *(sig++) = 0; // add padding with zeros BN_bn2bin(ecdsa->s, sig); BN_bn2bin(ecdsa->s, sig); sig += bcount; sig += bcount; ECDSA_SIG_free(ecdsa); ECDSA_SIG_free(ecdsa); Loading Loading
tools/itscertgen/generator/certgen.c +0 −1 Original line number Original line Diff line number Diff line Loading @@ -1393,7 +1393,6 @@ static int location_tag (cxml_handler_t* const _h, cxml_tag_t * const tag) absolute = cstrequal(v, "absolute"); absolute = cstrequal(v, "absolute"); v = cxml_tag_attr_value(tag, "latitude"); v = cxml_tag_attr_value(tag, "latitude"); int relative = 1; if(v == NULL){ if(v == NULL){ fprintf(stderr, "ERROR: Latitude must be specified for location.\n"); fprintf(stderr, "ERROR: Latitude must be specified for location.\n"); return -1; return -1; Loading
tools/itscertgen/generator/ecc_openssl.c +21 −13 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <openssl/ecdsa.h> #include <openssl/ecdsa.h> #include <string.h> #include <string.h> #define FIELD_SIZE 32 #define ARRAYSIZE(A) (sizeof(A)/sizeof(A[0])) #define ARRAYSIZE(A) (sizeof(A)/sizeof(A[0])) static char * _bin2hex(char * hex, int hlen, const char * bin, int blen); static char * _bin2hex(char * hex, int hlen, const char * bin, int blen); Loading Loading @@ -172,6 +174,7 @@ int ecc_api_key_public(void* key, char * px, char * py) BIGNUM x, y; BIGNUM x, y; int bcount = -1; int bcount = -1; if( key && px && py ) { ecgroup = EC_KEY_get0_group(eckey); ecgroup = EC_KEY_get0_group(eckey); ecpoint = EC_KEY_get0_public_key(eckey); ecpoint = EC_KEY_get0_public_key(eckey); Loading @@ -179,16 +182,17 @@ int ecc_api_key_public(void* key, char * px, char * py) BN_init(&x); BN_init(&y); BN_init(&x); BN_init(&y); if (EC_POINT_get_affine_coordinates_GFp(ecgroup, ecpoint, &x, &y, NULL)){ if (EC_POINT_get_affine_coordinates_GFp(ecgroup, ecpoint, &x, &y, NULL)){ bcount = BN_num_bytes(&x); bcount = BN_num_bytes(&x); if (px){ for(; bcount < FIELD_SIZE; bcount++) *(px++) = 0; // add padding with zeros BN_bn2bin(&x, (unsigned char*)px); BN_bn2bin(&x, (unsigned char*)px); } bcount = BN_num_bytes(&y); bcount = BN_num_bytes(&y); if (py){ for(; bcount < FIELD_SIZE; bcount++) *(py++) = 0; // add padding with zeros BN_bn2bin(&y, (unsigned char*)py); BN_bn2bin(&y, (unsigned char*)py); } } } BN_clear_free(&x); BN_clear_free(&y); BN_clear_free(&x); BN_clear_free(&y); } return bcount; return bcount; } } Loading Loading @@ -446,12 +450,16 @@ int ecc_sign(void * key, const char * data, int length, char ** psig, int max ecdsa = ECDSA_do_sign(hash, 32, eckey); ecdsa = ECDSA_do_sign(hash, 32, eckey); EC_KEY_free(eckey); EC_KEY_free(eckey); if (ecdsa){ if (ecdsa){ int bcount; int i, bcount; *(sig++) = 0; // ECC_POINT type (x_coordinate_only) *(sig++) = 0; // ECC_POINT type (x_coordinate_only) bcount = BN_num_bytes(ecdsa->r); bcount = BN_num_bytes(ecdsa->r); for(i=bcount; i < FIELD_SIZE; i++) *(sig++) = 0; // add padding with zeros BN_bn2bin(ecdsa->r, sig); BN_bn2bin(ecdsa->r, sig); sig += bcount; sig += bcount; bcount = BN_num_bytes(ecdsa->s); bcount = BN_num_bytes(ecdsa->s); for(i=bcount; i < FIELD_SIZE; i++) *(sig++) = 0; // add padding with zeros BN_bn2bin(ecdsa->s, sig); BN_bn2bin(ecdsa->s, sig); sig += bcount; sig += bcount; ECDSA_SIG_free(ecdsa); ECDSA_SIG_free(ecdsa); Loading