X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fevp%2Fp_lib.c;h=395351b3733f7f1658cd6bf78c46dc3bf2c45dc9;hp=11369048e7e08b18b829ab1e7dc28ba75849f585;hb=58964a492275ca9a59a0cd9c8155cb2491b4b909;hpb=d02b48c63a58ea4367a0e905979f140b7d090f86 diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 11369048e7..395351b373 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1,5 +1,5 @@ /* crypto/evp/p_lib.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -72,6 +72,21 @@ static void EVP_PKEY_free_it(EVP_PKEY *x); static void EVP_PKEY_free_it(); #endif +int EVP_PKEY_bits(pkey) +EVP_PKEY *pkey; + { +#ifndef NO_RSA + if (pkey->type == EVP_PKEY_RSA) + return(BN_num_bits(pkey->pkey.rsa->n)); + else +#endif +#ifndef NO_DSA + if (pkey->type == EVP_PKEY_DSA) + return(BN_num_bits(pkey->pkey.dsa->p)); +#endif + return(0); + } + int EVP_PKEY_size(pkey) EVP_PKEY *pkey; { @@ -110,13 +125,13 @@ EVP_PKEY *to,*from; if (to->type != from->type) { EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES); - return(0); + goto err; } if (EVP_PKEY_missing_parameters(from)) { EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARMATERS); - return(0); + goto err; } #ifndef NO_DSA if (to->type == EVP_PKEY_DSA) @@ -157,6 +172,23 @@ EVP_PKEY *pkey; return(0); } +int EVP_PKEY_cmp_parameters(a,b) +EVP_PKEY *a,*b; + { +#ifndef NO_DSA + if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA)) + { + if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) || + BN_cmp(a->pkey.dsa->q,b->pkey.dsa->q) || + BN_cmp(a->pkey.dsa->g,b->pkey.dsa->g)) + return(0); + else + return(1); + } +#endif + return(-1); + } + EVP_PKEY *EVP_PKEY_new() { EVP_PKEY *ret; @@ -198,8 +230,10 @@ int type; case EVP_PKEY_RSA2: return(EVP_PKEY_RSA); case EVP_PKEY_DSA: + case EVP_PKEY_DSA1: case EVP_PKEY_DSA2: case EVP_PKEY_DSA3: + case EVP_PKEY_DSA4: return(EVP_PKEY_DSA); case EVP_PKEY_DH: return(EVP_PKEY_DH); @@ -216,6 +250,9 @@ EVP_PKEY *x; if (x == NULL) return; i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY); +#ifdef REF_PRINT + REF_PRINT("EVP_PKEY",x); +#endif if (i > 0) return; #ifdef REF_CHECK if (i < 0) @@ -243,6 +280,7 @@ EVP_PKEY *x; case EVP_PKEY_DSA: case EVP_PKEY_DSA2: case EVP_PKEY_DSA3: + case EVP_PKEY_DSA4: DSA_free(x->pkey.dsa); break; #endif