Another straightforward diff, this time to catch up with OpenSSL's const
sprinkling over PCKS12_* and PKCS8_* functions.

Part of sthen's bulk.

Index: lib/libcrypto/pkcs12/p12_add.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_add.c,v
retrieving revision 1.15
diff -u -p -r1.15 p12_add.c
--- lib/libcrypto/pkcs12/p12_add.c      29 Jan 2017 17:49:23 -0000      1.15
+++ lib/libcrypto/pkcs12/p12_add.c      13 May 2018 11:11:33 -0000
@@ -232,7 +232,7 @@ PKCS12_unpack_p7encdata(PKCS7 *p7, const
 }
 
 PKCS8_PRIV_KEY_INFO *
-PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, int passlen)
+PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, const char *pass, int passlen)
 {
        return PKCS8_decrypt(bag->value.shkeybag, pass, passlen);
 }
@@ -247,7 +247,7 @@ PKCS12_pack_authsafes(PKCS12 *p12, STACK
 }
 
 STACK_OF(PKCS7) *
-PKCS12_unpack_authsafes(PKCS12 *p12)
+PKCS12_unpack_authsafes(const PKCS12 *p12)
 {
        if (!PKCS7_type_is_data(p12->authsafes)) {
                PKCS12error(PKCS12_R_CONTENT_TYPE_NOT_DATA);
Index: lib/libcrypto/pkcs12/p12_attr.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_attr.c,v
retrieving revision 1.10
diff -u -p -r1.10 p12_attr.c
--- lib/libcrypto/pkcs12/p12_attr.c     11 Jul 2014 08:44:49 -0000      1.10
+++ lib/libcrypto/pkcs12/p12_attr.c     13 May 2018 11:11:33 -0000
@@ -122,7 +122,7 @@ PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *b
 }
 
 ASN1_TYPE *
-PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid)
+PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid)
 {
        X509_ATTRIBUTE *attrib;
        int i;
Index: lib/libcrypto/pkcs12/p12_crt.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_crt.c,v
retrieving revision 1.17
diff -u -p -r1.17 p12_crt.c
--- lib/libcrypto/pkcs12/p12_crt.c      29 Jan 2017 17:49:23 -0000      1.17
+++ lib/libcrypto/pkcs12/p12_crt.c      13 May 2018 11:11:33 -0000
@@ -80,7 +80,7 @@ copy_bag_attr(PKCS12_SAFEBAG *bag, EVP_P
 }
 
 PKCS12 *
-PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
+PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert,
     STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, int mac_iter,
     int keytype)
 {
@@ -221,7 +221,7 @@ err:
 
 PKCS12_SAFEBAG *
 PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, int key_usage,
-    int iter, int nid_key, char *pass)
+    int iter, int nid_key, const char *pass)
 {
        PKCS12_SAFEBAG *bag = NULL;
        PKCS8_PRIV_KEY_INFO *p8 = NULL;
@@ -261,7 +261,7 @@ err:
 
 int
 PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
-    int nid_safe, int iter, char *pass)
+    int nid_safe, int iter, const char *pass)
 {
        PKCS7 *p7 = NULL;
        int free_safes = 0;
Index: lib/libcrypto/pkcs12/p12_decr.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_decr.c,v
retrieving revision 1.18
diff -u -p -r1.18 p12_decr.c
--- lib/libcrypto/pkcs12/p12_decr.c     29 Jan 2017 17:49:23 -0000      1.18
+++ lib/libcrypto/pkcs12/p12_decr.c     13 May 2018 11:11:33 -0000
@@ -67,8 +67,9 @@
  */
 
 unsigned char *
-PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, int passlen,
-    unsigned char *in, int inlen, unsigned char **data, int *datalen, int 
en_de)
+PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, int passlen,
+    const unsigned char *in, int inlen, unsigned char **data, int *datalen,
+    int en_de)
 {
        unsigned char *out;
        int outlen, i;
@@ -119,8 +120,8 @@ err:
  */
 
 void *
-PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
-    const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf)
+PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,
+    const char *pass, int passlen, const ASN1_OCTET_STRING *oct, int zbuf)
 {
        unsigned char *out;
        const unsigned char *p;
Index: lib/libcrypto/pkcs12/p12_npas.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_npas.c,v
retrieving revision 1.12
diff -u -p -r1.12 p12_npas.c
--- lib/libcrypto/pkcs12/p12_npas.c     29 Jan 2017 17:49:23 -0000      1.12
+++ lib/libcrypto/pkcs12/p12_npas.c     13 May 2018 11:11:33 -0000
@@ -65,10 +65,11 @@
 
 /* PKCS#12 password change routine */
 
-static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass);
-static int newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass,
-    char *newpass);
-static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass);
+static int newpass_p12(PKCS12 *p12, const char *oldpass, const char *newpass);
+static int newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *oldpass,
+    const char *newpass);
+static int newpass_bag(PKCS12_SAFEBAG *bag, const char *oldpass,
+    const char *newpass);
 static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen);
 
 /*
@@ -76,7 +77,7 @@ static int alg_get(X509_ALGOR *alg, int 
  */
 
 int
-PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass)
+PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass)
 {
        /* Check for NULL PKCS12 structure */
 
@@ -103,7 +104,7 @@ PKCS12_newpass(PKCS12 *p12, char *oldpas
 /* Parse the outer PKCS#12 structure */
 
 static int
-newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
+newpass_p12(PKCS12 *p12, const char *oldpass, const char *newpass)
 {
        STACK_OF(PKCS7) *asafes, *newsafes;
        STACK_OF(PKCS12_SAFEBAG) *bags;
@@ -189,7 +190,8 @@ err:
 
 
 static int
-newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass, char *newpass)
+newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *oldpass,
+    const char *newpass)
 {
        int i;
 
@@ -204,7 +206,7 @@ newpass_bags(STACK_OF(PKCS12_SAFEBAG) *b
 /* Change password of safebag: only needs handle shrouded keybags */
 
 static int
-newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass)
+newpass_bag(PKCS12_SAFEBAG *bag, const char *oldpass, const char *newpass)
 {
        PKCS8_PRIV_KEY_INFO *p8;
        X509_SIG *p8new;
Index: lib/libcrypto/pkcs12/p12_p8d.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_p8d.c,v
retrieving revision 1.6
diff -u -p -r1.6 p12_p8d.c
--- lib/libcrypto/pkcs12/p12_p8d.c      30 Dec 2016 15:34:35 -0000      1.6
+++ lib/libcrypto/pkcs12/p12_p8d.c      13 May 2018 11:11:33 -0000
@@ -61,7 +61,7 @@
 #include <openssl/pkcs12.h>
 
 PKCS8_PRIV_KEY_INFO *
-PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen)
+PKCS8_decrypt(const X509_SIG *p8, const char *pass, int passlen)
 {
        return PKCS12_item_decrypt_d2i(p8->algor,
            &PKCS8_PRIV_KEY_INFO_it, pass, passlen, p8->digest, 1);
Index: lib/libcrypto/pkcs12/pkcs12.h
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/pkcs12.h,v
retrieving revision 1.17
diff -u -p -r1.17 pkcs12.h
--- lib/libcrypto/pkcs12/pkcs12.h       30 Dec 2016 15:08:58 -0000      1.17
+++ lib/libcrypto/pkcs12/pkcs12.h       13 May 2018 11:11:33 -0000
@@ -178,9 +178,10 @@ X509_CRL *PKCS12_certbag2x509crl(PKCS12_
 PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,
     int nid1, int nid2);
 PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);
-PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int 
passlen);
-PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass,
+PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,
     int passlen);
+PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag,
+    const char *pass, int passlen);
 X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
     const char *pass, int passlen, unsigned char *salt, int saltlen, int iter,
     PKCS8_PRIV_KEY_INFO *p8);
@@ -195,7 +196,7 @@ STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_
     int passlen);
 
 int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
-STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);
+STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12);
 
 int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
     int namelen);
@@ -206,13 +207,14 @@ int PKCS12_add_CSPName_asc(PKCS12_SAFEBA
 int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name,
     int namelen);
 int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
-ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);
+ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs,
+    int attr_nid);
 char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
-unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
-    int passlen, unsigned char *in, int inlen, unsigned char **data,
+unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass,
+    int passlen, const unsigned char *in, int inlen, unsigned char **data,
     int *datalen, int en_de);
-void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
-    const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf);
+void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,
+    const char *pass, int passlen, const ASN1_OCTET_STRING *oct, int zbuf);
 ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,
     const ASN1_ITEM *it, const char *pass, int passlen, void *obj, int zbuf);
 PKCS12 *PKCS12_init(int mode);
@@ -264,22 +266,22 @@ extern const ASN1_ITEM PKCS12_AUTHSAFES_
 void PKCS12_PBE_add(void);
 int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
     STACK_OF(X509) **ca);
-PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
-    STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,
+PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey,
+    X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,
     int mac_iter, int keytype);
 
 PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);
 PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key,
-    int key_usage, int iter, int key_nid, char *pass);
+    int key_usage, int iter, int key_nid, const char *pass);
 int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
-    int safe_nid, int iter, char *pass);
+    int safe_nid, int iter, const char *pass);
 PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);
 
 int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);
 int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
 PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
 PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
-int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
+int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);
 
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes

Reply via email to