Revert the size_t modifications from HEAD that had led to more
[openssl.git] / crypto / asn1 / d2i_pu.c
index 142742e8449db332eece78638ab1b24423c19548..3694f51a8c0af5961b7765856f7b99402ed49300 100644 (file)
@@ -1,5 +1,5 @@
 /* crypto/asn1/d2i_pu.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
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "bn.h"
-#include "evp.h"
-#include "objects.h"
-#include "x509.h"
+#include <openssl/bn.h>
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include <openssl/asn1.h>
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#endif
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#endif
+#ifndef OPENSSL_NO_EC
+#include <openssl/ec.h>
+#endif
 
-EVP_PKEY *d2i_PublicKey(type,a,pp,length)
-int type;
-EVP_PKEY **a;
-unsigned char **pp;
-long length;
+EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
+            long length)
        {
        EVP_PKEY *ret;
 
@@ -85,28 +91,40 @@ long length;
        ret->type=EVP_PKEY_type(type);
        switch (ret->type)
                {
-#ifndef NO_RSA
+#ifndef OPENSSL_NO_RSA
        case EVP_PKEY_RSA:
-               if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL,pp,length)) == NULL)
+               if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL,
+                       (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
                        {
                        ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB);
                        goto err;
                        }
                break;
 #endif
-#ifndef NO_DSA
+#ifndef OPENSSL_NO_DSA
        case EVP_PKEY_DSA:
-               if ((ret->pkey.dsa=d2i_DSAPublicKey(NULL,pp,length)) == NULL)
+               if (!d2i_DSAPublicKey(&(ret->pkey.dsa),
+                       (const unsigned char **)pp,length)) /* TMP UGLY CAST */
                        {
                        ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB);
                        goto err;
                        }
                break;
+#endif
+#ifndef OPENSSL_NO_EC
+       case EVP_PKEY_EC:
+               if (!o2i_ECPublicKey(&(ret->pkey.ec),
+                                    (const unsigned char **)pp, length))
+                       {
+                       ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB);
+                       goto err;
+                       }
+       break;
 #endif
        default:
                ASN1err(ASN1_F_D2I_PUBLICKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
                goto err;
-               break;
+               /* break; */
                }
        if (a != NULL) (*a)=ret;
        return(ret);