use a generic EC_KEY structure (EC keys are not ECDSA specific)
[openssl.git] / crypto / asn1 / t_pkey.c
index 652b26b7b0c27c6aebd9e8bb4a284ef24139e372..fb01e38d79db701016a5b5263e93a19c12a241f5 100644 (file)
@@ -70,8 +70,8 @@
 #ifndef OPENSSL_NO_DSA
 #include <openssl/dsa.h>
 #endif
-#ifndef OPENSSL_NO_ECDSA
-#include <openssl/ecdsa.h>
+#ifndef OPENSSL_NO_EC
+#include <openssl/ec.h>
 #endif
 
 static int print(BIO *fp,const char *str,BIGNUM *num,
@@ -257,6 +257,22 @@ int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off)
        BIO_free(b);
        return(ret);
        }
+
+int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off)
+       {
+       BIO *b;
+       int ret;
+       if ((b=BIO_new(BIO_s_file())) == NULL)
+               {
+               ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB);
+               return(0);
+               }
+       BIO_set_fp(b, fp, BIO_NOCLOSE);
+       ret = EC_KEY_print(b, x, off);
+       BIO_free(b);
+       return(ret);
+       }
 #endif
 
 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
@@ -436,29 +452,8 @@ err:
                OPENSSL_free(buffer);
        return(ret);    
        }
-#endif /* OPENSSL_NO_EC */
-
-
-#ifndef OPENSSL_NO_ECDSA
-#ifndef OPENSSL_NO_FP_API
-int ECDSA_print_fp(FILE *fp, const ECDSA *x, int off)
-{
-       BIO *b;
-       int ret;
-       if ((b=BIO_new(BIO_s_file())) == NULL)
-       {
-               ECDSAerr(ECDSA_F_ECDSA_PRINT_FP, ERR_R_BIO_LIB);
-               return(0);
-       }
-       BIO_set_fp(b, fp, BIO_NOCLOSE);
-       ret = ECDSA_print(b, x, off);
-       BIO_free(b);
-       return(ret);
-}
-#endif
 
-int ECDSA_print(BIO *bp, const ECDSA *x, int off)
+int EC_KEY_print(BIO *bp, const EC_KEY *x, int off)
        {
        char str[128];
        unsigned char *buffer=NULL;
@@ -474,7 +469,7 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off)
                }
 
        if ((pub_key = EC_POINT_point2bn(x->group, x->pub_key,
-               ECDSA_get_conversion_form(x), NULL, ctx)) == NULL)
+               x->conv_form, NULL, ctx)) == NULL)
                {
                reason = ERR_R_EC_LIB;
                goto err;
@@ -516,7 +511,7 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off)
        ret=1;
 err:
        if (!ret)
-               ECDSAerr(ECDSA_F_ECDSA_PRINT, reason);
+               ECerr(EC_F_EC_KEY_PRINT, reason);
        if (pub_key) 
                BN_free(pub_key);
        if (ctx)
@@ -525,7 +520,7 @@ err:
                OPENSSL_free(buffer);
        return(ret);
        }
-#endif
+#endif /* OPENSSL_NO_EC */
 
 static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
             int off)
@@ -690,26 +685,26 @@ err:
 
 #endif /* !OPENSSL_NO_DSA */
 
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
 #ifndef OPENSSL_NO_FP_API
-int ECDSAParameters_print_fp(FILE *fp, const ECDSA *x)
+int ECParameters_print_fp(FILE *fp, const EC_KEY *x)
        {
        BIO *b;
        int ret;
  
        if ((b=BIO_new(BIO_s_file())) == NULL)
-       {
-               ECDSAerr(ECDSA_F_ECDSAPARAMETERS_PRINT_FP, ERR_R_BIO_LIB);
+               {
+               ECerr(EC_F_ECPARAMETERS_PRINT_FP, ERR_R_BIO_LIB);
                return(0);
-       }
+               }
        BIO_set_fp(b, fp, BIO_NOCLOSE);
-       ret = ECDSAParameters_print(b, x);
+       ret = ECParameters_print(b, x);
        BIO_free(b);
        return(ret);
        }
 #endif
 
-int ECDSAParameters_print(BIO *bp, const ECDSA *x)
+int ECParameters_print(BIO *bp, const EC_KEY *x)
        {
        int     reason=ERR_R_EC_LIB, ret=0;
        BIGNUM  *order=NULL;
@@ -741,7 +736,7 @@ int ECDSAParameters_print(BIO *bp, const ECDSA *x)
 err:
        if (order)
                BN_free(order);
-       ECDSAerr(ECDSA_F_ECDSAPARAMETERS_PRINT, reason);
+       ECerr(EC_F_ECPARAMETERS_PRINT, reason);
        return(ret);
        }