Commit d5df00b1 authored by ASN.1 Documenter's avatar ASN.1 Documenter
Browse files

adapt certgen for old openssl

parent 42941e4f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@ extern "C" {
#endif


int ecc_api_init();
int ecc_api_done();

typedef enum {
	ecies_nistp256,
@@ -24,6 +22,9 @@ typedef enum {
	ecies_brainpoolp384r,
}ecc_curve_id;

int ecc_api_init();
int ecc_api_done();
const char* ecc_curve_name(ecc_curve_id curve);
typedef enum {
	sha_256,
	sha_384
+30 −3
Original line number Diff line number Diff line
@@ -21,6 +21,28 @@

#define ARRAYSIZE(A) (sizeof(A)/sizeof(A[0]))

#if OPENSSL_VERSION_NUMBER < 0x10101000L
#define EC_POINT_get_affine_coordinates EC_POINT_get_affine_coordinates_GFp
#define EC_POINT_set_affine_coordinates EC_POINT_set_affine_coordinates_GFp
#define EC_POINT_set_compressed_coordinates EC_POINT_set_compressed_coordinates_GFp
void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
{                                                                                                                                                                                                                      if (pr != NULL)
        *pr = sig->r;
    if (ps != NULL)
        *ps = sig->s;
}

int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
{
    if (r == NULL || s == NULL)
        return 0;
    BN_clear_free(sig->r);
    BN_clear_free(sig->s);
    sig->r = r;
    sig->s = s;
    return 1;
}
#endif
char * _bin2hex(char * hex, size_t hlen, const char * bin, size_t blen);

typedef struct {
@@ -49,9 +71,6 @@ int ecc_api_init()
	int i;
	for (i = 0; i < ARRAYSIZE(_config); i++){
		_curves[i] = EC_GROUP_new_by_curve_name(_config[i].nid);
		if(_curves[i] == NULL){
		    fprintf(stderr, "ERROR: unknown curve %s\n", _config[i].name);
		}
	}
	return 0;
}
@@ -65,6 +84,14 @@ int ecc_api_done()
	return 0;
}

const char* ecc_curve_name(ecc_curve_id curve)
{
	if (curve < ARRAYSIZE(_config)) {
		return _config[curve].name;
	}
	return "unknown curve id";
}

void * ecc_key_gen(ecc_curve_id pk_alg)
{
	EC_KEY * key = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
 * Modifications:  Fixed tm_isdst usage - 27 August 2008 Craig Howland.
 */

#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 
#define _CRT_SECURE_NO_WARNINGS
#endif