Of these four functions, only OPENSSL_uni2asc() has const in OpenSSL.
jsing suggested that we could add const to the the name arguments of
X509_NAME_get_index_by_{OBJ,NID}() when I touched some functions nearby.
Lastly, the change to EVP_PKEY_size() will be needed in an upcoming
diff. Note that the pkey_size() callback (in asn1/asn1_locl.h:94) has
const since it was imported nine years ago.
These all went through a bulk build by sthen. No fallout since we only
have contravariant const additions.
Index: lib/libcrypto/evp/evp.h
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/evp/evp.h,v
retrieving revision 1.63
diff -u -p -r1.63 evp.h
--- lib/libcrypto/evp/evp.h 13 May 2018 06:40:55 -0000 1.63
+++ lib/libcrypto/evp/evp.h 30 May 2018 00:44:54 -0000
@@ -868,7 +868,7 @@ int EVP_PKEY_type(int type);
int EVP_PKEY_id(const EVP_PKEY *pkey);
int EVP_PKEY_base_id(const EVP_PKEY *pkey);
int EVP_PKEY_bits(const EVP_PKEY *pkey);
-int EVP_PKEY_size(EVP_PKEY *pkey);
+int EVP_PKEY_size(const EVP_PKEY *pkey);
int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);
Index: lib/libcrypto/evp/p_lib.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/evp/p_lib.c,v
retrieving revision 1.23
diff -u -p -r1.23 p_lib.c
--- lib/libcrypto/evp/p_lib.c 13 May 2018 06:38:46 -0000 1.23
+++ lib/libcrypto/evp/p_lib.c 30 May 2018 00:44:54 -0000
@@ -93,7 +93,7 @@ EVP_PKEY_bits(const EVP_PKEY *pkey)
}
int
-EVP_PKEY_size(EVP_PKEY *pkey)
+EVP_PKEY_size(const EVP_PKEY *pkey)
{
if (pkey && pkey->ameth && pkey->ameth->pkey_size)
return pkey->ameth->pkey_size(pkey);
Index: lib/libcrypto/pkcs12/p12_utl.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/p12_utl.c,v
retrieving revision 1.15
diff -u -p -r1.15 p12_utl.c
--- lib/libcrypto/pkcs12/p12_utl.c 30 Dec 2016 15:34:35 -0000 1.15
+++ lib/libcrypto/pkcs12/p12_utl.c 30 May 2018 00:38:13 -0000
@@ -100,7 +100,7 @@ OPENSSL_asc2uni(const char *asc, int asc
}
char *
-OPENSSL_uni2asc(unsigned char *uni, int unilen)
+OPENSSL_uni2asc(const unsigned char *uni, int unilen)
{
size_t asclen, u16len, i;
char *asctmp;
Index: lib/libcrypto/pkcs12/pkcs12.h
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/pkcs12/pkcs12.h,v
retrieving revision 1.23
diff -u -p -r1.23 pkcs12.h
--- lib/libcrypto/pkcs12/pkcs12.h 13 May 2018 14:28:14 -0000 1.23
+++ lib/libcrypto/pkcs12/pkcs12.h 30 May 2018 00:38:13 -0000
@@ -237,7 +237,7 @@ int PKCS12_setup_mac(PKCS12 *p12, int it
int saltlen, const EVP_MD *md_type);
unsigned char *OPENSSL_asc2uni(const char *asc, int asclen,
unsigned char **uni, int *unilen);
-char *OPENSSL_uni2asc(unsigned char *uni, int unilen);
+char *OPENSSL_uni2asc(const unsigned char *uni, int unilen);
PKCS12 *PKCS12_new(void);
void PKCS12_free(PKCS12 *a);
Index: lib/libcrypto/x509/x509.h
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/x509/x509.h,v
retrieving revision 1.67
diff -u -p -r1.67 x509.h
--- lib/libcrypto/x509/x509.h 19 May 2018 10:58:08 -0000 1.67
+++ lib/libcrypto/x509/x509.h 30 May 2018 00:44:38 -0000
@@ -1100,8 +1100,9 @@ int X509_NAME_get_text_by_OBJ(X509_NAME
/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use
* lastpos, search after that position on. */
-int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
-int X509_NAME_get_index_by_OBJ(X509_NAME *name,
+int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid,
+ int lastpos);
+int X509_NAME_get_index_by_OBJ(const X509_NAME *name,
const ASN1_OBJECT *obj, int lastpos);
X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);
X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
Index: lib/libcrypto/x509/x509name.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/x509/x509name.c,v
retrieving revision 1.25
diff -u -p -r1.25 x509name.c
--- lib/libcrypto/x509/x509name.c 19 May 2018 10:58:08 -0000 1.25
+++ lib/libcrypto/x509/x509name.c 30 May 2018 00:44:38 -0000
@@ -107,7 +107,7 @@ X509_NAME_entry_count(const X509_NAME *n
}
int
-X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos)
+X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos)
{
ASN1_OBJECT *obj;
@@ -119,7 +119,8 @@ X509_NAME_get_index_by_NID(X509_NAME *na
/* NOTE: you should be passsing -1, not 0 as lastpos */
int
-X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int
lastpos)
+X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
+ int lastpos)
{
int n;
X509_NAME_ENTRY *ne;