Move the Win32 #undefs of X509_NAME and PKCS7_ISSUER_AND_SERIAL so they will
[openssl.git] / crypto / x509 / x509.h
index 1ba0be7786d2bc70d1f53d7a73a5d58b68812928..de574791f75e536949f3b7c25b87e151ae78c198 100644 (file)
 extern "C" {
 #endif
 
+#ifdef VMS
+#undef X509_REVOKED_get_ext_by_critical
+#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic
+#endif
+
 #include <openssl/stack.h>
 #include <openssl/asn1.h>
 #include <openssl/safestack.h>
 
 #ifndef NO_RSA
 #include <openssl/rsa.h>
-#else
-#define RSA    long
 #endif
 
 #ifndef NO_DSA
 #include <openssl/dsa.h>
-#else
-#define DSA    long
 #endif
 
 #ifndef NO_DH
 #include <openssl/dh.h>
-#else
-#define DH     long
 #endif
 
 #include <openssl/evp.h>
 
+
+#ifdef WIN32
+/* Under Win32 this is defined in wincrypt.h */
+#undef X509_NAME
+#endif
+
 #define X509_FILETYPE_PEM      1
 #define X509_FILETYPE_ASN1     2
 #define X509_FILETYPE_DEFAULT  3
@@ -142,10 +147,13 @@ typedef struct X509_name_entry_st
        int size;       /* temp variable */
        } X509_NAME_ENTRY;
 
+DECLARE_STACK_OF(X509_NAME_ENTRY)
+DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
+
 /* we always keep X509_NAMEs in 2 forms. */
 typedef struct X509_name_st
        {
-       STACK *entries; /* of X509_NAME_ENTRY */
+       STACK_OF(X509_NAME_ENTRY) *entries;
        int modified;   /* true if 'bytes' needs to be built */
 #ifdef HEADER_BUFFER_H
        BUF_MEM *bytes;
@@ -170,13 +178,31 @@ typedef struct X509_extension_st
        void (*ex_free)();              /* clear argp stuff */
        } X509_EXTENSION;
 
+DECLARE_STACK_OF(X509_EXTENSION)
+DECLARE_ASN1_SET_OF(X509_EXTENSION)
+
+/* a sequence of these are used */
+typedef struct x509_attributes_st
+       {
+       ASN1_OBJECT *object;
+       int set; /* 1 for a set, 0 for a single item (which is wrong) */
+       union   {
+               char            *ptr;
+/* 1 */                STACK_OF(ASN1_TYPE) *set;
+/* 0 */                ASN1_TYPE       *single;
+               } value;
+       } X509_ATTRIBUTE;
+
+DECLARE_STACK_OF(X509_ATTRIBUTE)
+DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
+
 typedef struct X509_req_info_st
        {
        ASN1_INTEGER *version;
        X509_NAME *subject;
        X509_PUBKEY *pubkey;
        /*  d=2 hl=2 l=  0 cons: cont: 00 */
-       STACK /* X509_ATTRIBUTE */ *attributes; /* [ 0 ] */
+       STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
        int req_kludge;
        } X509_REQ_INFO;
 
@@ -199,7 +225,7 @@ typedef struct x509_cinf_st
        X509_PUBKEY *key;
        ASN1_BIT_STRING *issuerUID;             /* [ 1 ] optional in v2 */
        ASN1_BIT_STRING *subjectUID;            /* [ 2 ] optional in v2 */
-       STACK /* X509_EXTENSION */ *extensions; /* [ 3 ] optional in v3 */
+       STACK_OF(X509_EXTENSION) *extensions;   /* [ 3 ] optional in v3 */
        } X509_CINF;
 
 typedef struct x509_st
@@ -219,7 +245,7 @@ typedef struct X509_revoked_st
        {
        ASN1_INTEGER *serialNumber;
        ASN1_UTCTIME *revocationDate;
-       STACK /* optional X509_EXTENSION */ *extensions;
+       STACK_OF(X509_EXTENSION) /* optional */ *extensions;
        int sequence; /* load sequence */
        } X509_REVOKED;
 
@@ -231,7 +257,7 @@ typedef struct X509_crl_info_st
        ASN1_UTCTIME *lastUpdate;
        ASN1_UTCTIME *nextUpdate;
        STACK /* X509_REVOKED */ *revoked;
-       STACK /* [0] X509_EXTENSION */ *extensions;
+       STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
        } X509_CRL_INFO;
 
 typedef struct X509_crl_st
@@ -243,20 +269,6 @@ typedef struct X509_crl_st
        int references;
        } X509_CRL;
 
-/* a sequence of these are used */
-typedef struct x509_attributes_st
-       {
-       ASN1_OBJECT *object;
-       int set; /* 1 for a set, 0 for a single item (which is wrong) */
-       union   {
-               char            *ptr;
-/* 1 */                STACK /* ASN1_TYPE */ *set;
-/* 0 */                ASN1_TYPE       *single;
-               } value;
-       } X509_ATTRIBUTE;
-
-DECLARE_STACK_OF(X509_ATTRIBUTE)
-
 typedef struct private_key_st
        {
        int version;
@@ -291,6 +303,8 @@ typedef struct X509_info_st
 
        int references;
        } X509_INFO;
+
+DECLARE_STACK_OF(X509_INFO)
 #endif
 
 /* The next 2 structures and their 8 routines were sent to me by
@@ -543,34 +557,42 @@ int X509_NAME_digest(X509_NAME *data,EVP_MD *type,
 #endif
 
 #ifndef NO_FP_API
-X509 *d2i_X509_fp(FILE *fp, X509 *x509);
+X509 *d2i_X509_fp(FILE *fp, X509 **x509);
 int i2d_X509_fp(FILE *fp,X509 *x509);
-X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL *crl);
+X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
 int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
-X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ *req);
+X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
 int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
-RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
+#ifndef NO_RSA
+RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
 int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
-DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
-int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
-RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA *rsa);
+RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
 int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
 #endif
+#ifndef NO_DSA
+DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
+int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
+#endif
+#endif
 
 #ifdef HEADER_BIO_H
-X509 *d2i_X509_bio(BIO *bp,X509 *x509);
+X509 *d2i_X509_bio(BIO *bp,X509 **x509);
 int i2d_X509_bio(BIO *bp,X509 *x509);
-X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL *crl);
+X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
 int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
-X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ *req);
+X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
 int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
-RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
+#ifndef NO_RSA
+RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
 int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
-DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
-int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
-RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA *rsa);
+RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
 int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
 #endif
+#ifndef NO_DSA
+DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
+int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
+#endif
+#endif
 
 X509 *X509_dup(X509 *x509);
 X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
@@ -580,8 +602,10 @@ X509_REQ *X509_REQ_dup(X509_REQ *req);
 X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
 X509_NAME *X509_NAME_dup(X509_NAME *xn);
 X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
+#ifndef NO_RSA
 RSA *RSAPublicKey_dup(RSA *rsa);
 RSA *RSAPrivateKey_dup(RSA *rsa);
+#endif
 
 #endif /* !SSLEAY_MACROS */
 
@@ -642,7 +666,7 @@ void                X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
 int            i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a,unsigned char **pp);
 X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a,unsigned char **pp,
                        long length);
-X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, char *value);
+X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
 
 
 X509_EXTENSION *X509_EXTENSION_new(void );
@@ -802,13 +826,17 @@ int               X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
 ASN1_OBJECT *  X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
 ASN1_STRING *  X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
 
-int            X509v3_get_ext_count(STACK *x);
-int            X509v3_get_ext_by_NID(STACK *x, int nid, int lastpos);
-int            X509v3_get_ext_by_OBJ(STACK *x,ASN1_OBJECT *obj,int lastpos);
-int            X509v3_get_ext_by_critical(STACK *x, int crit, int lastpos);
-X509_EXTENSION *X509v3_get_ext(STACK *x, int loc);
-X509_EXTENSION *X509v3_delete_ext(STACK *x, int loc);
-STACK *                X509v3_add_ext(STACK **x, X509_EXTENSION *ex, int loc);
+int            X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
+int            X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
+                                     int nid, int lastpos);
+int            X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
+                                     ASN1_OBJECT *obj,int lastpos);
+int            X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
+                                          int crit, int lastpos);
+X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
+X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
+STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
+                                        X509_EXTENSION *ex, int loc);
 
 int            X509_get_ext_count(X509 *x);
 int            X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
@@ -883,6 +911,9 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
 
 /* Password based encryption routines */
 
+int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
+            unsigned char *salt, int saltlen, int iter, EVP_CIPHER_CTX *ctx,
+            int en_de);
 int EVP_PBE_ALGOR_CipherInit(X509_ALGOR *algor, const char *pass,
                             int passlen, EVP_CIPHER_CTX *ctx, int en_de);
 int EVP_PBE_alg_add(int nid, EVP_CIPHER *cipher, EVP_MD *md,