AFAICS lst1 stands for "lshift test" not "list".
[oweals/openssl.git] / crypto / pem / pem_info.c
index 7f74bac351bdabd542004aaf51b98aac81aadbeb..b65239a9200fce87cbb95ea8bc427346f1c5a63e 100644 (file)
@@ -65,7 +65,7 @@
 #include <openssl/pem.h>
 
 #ifndef NO_FP_API
-STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, int (*cb)())
+STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u)
        {
         BIO *b;
         STACK_OF(X509_INFO) *ret;
@@ -76,13 +76,13 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, int (
                 return(0);
                }
         BIO_set_fp(b,fp,BIO_NOCLOSE);
-        ret=PEM_X509_INFO_read_bio(b,sk,cb);
+        ret=PEM_X509_INFO_read_bio(b,sk,cb,u);
         BIO_free(b);
         return(ret);
        }
 #endif
 
-STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, int (*cb)())
+STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u)
        {
        X509_INFO *xi=NULL;
        char *name=NULL,*header=NULL,**pp;
@@ -132,6 +132,17 @@ start:
                                }
                        pp=(char **)&(xi->x509);
                        }
+               else if ((strcmp(name,PEM_STRING_X509_TRUSTED) == 0))
+                       {
+                       d2i=(char *(*)())d2i_X509_AUX;
+                       if (xi->x509 != NULL)
+                               {
+                               if (!sk_X509_INFO_push(ret,xi)) goto err;
+                               if ((xi=X509_INFO_new()) == NULL) goto err;
+                               goto start;
+                               }
+                       pp=(char **)&(xi->x509);
+                       }
                else if (strcmp(name,PEM_STRING_X509_CRL) == 0)
                        {
                        d2i=(char *(*)())d2i_X509_CRL;
@@ -205,7 +216,7 @@ start:
 
                                if (!PEM_get_EVP_CIPHER_INFO(header,&cipher))
                                        goto err;
-                               if (!PEM_do_header(&cipher,data,&len,cb))
+                               if (!PEM_do_header(&cipher,data,&len,cb,u))
                                        goto err;
                                p=data;
                                if (d2i(pp,&p,len) == NULL)
@@ -266,13 +277,12 @@ err:
 
 /* A TJH addition */
 int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
-            unsigned char *kstr, int klen, int (*cb)())
+            unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
        {
        EVP_CIPHER_CTX ctx;
        int i,ret=0;
        unsigned char *data=NULL;
        const char *objstr=NULL;
-#define PEM_BUFSIZE    1024
        char buf[PEM_BUFSIZE];
        unsigned char *iv=NULL;
        
@@ -329,7 +339,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
                        /* normal optionally encrypted stuff */
                        if (PEM_write_bio_RSAPrivateKey(bp,
                                xi->x_pkey->dec_pkey->pkey.rsa,
-                               enc,kstr,klen,cb)<=0)
+                               enc,kstr,klen,cb,u)<=0)
                                goto err;
 #endif
                        }