summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2016-11-04 18:35:30 +0000
committerjsing <jsing@openbsd.org>2016-11-04 18:35:30 +0000
commit2ca517534ca9f787744fffdd12e82c4c93261da9 (patch)
tree0b31426d225dc95f284ddf5dc6fa17be933de67c
parentMark a couple local functions as static (diff)
downloadwireguard-openbsd-2ca517534ca9f787744fffdd12e82c4c93261da9.tar.xz
wireguard-openbsd-2ca517534ca9f787744fffdd12e82c4c93261da9.zip
Kill a bunch of OLD_ASN1 usage by replacing ASN1_{d2i,i2d}_* with
ASN1_item_{d2i,i2d}_* equivalents. ok guenther@ miod@
-rw-r--r--lib/libcrypto/dh/dh.h12
-rw-r--r--lib/libcrypto/dh/dh_asn1.c26
-rw-r--r--lib/libcrypto/dsa/dsa.h13
-rw-r--r--lib/libcrypto/dsa/dsa_asn1.c26
-rw-r--r--lib/libcrypto/ocsp/ocsp.h18
-rw-r--r--lib/libcrypto/ocsp/ocsp_asn.c27
-rw-r--r--lib/libcrypto/ts/ts_asn1.c38
7 files changed, 107 insertions, 53 deletions
diff --git a/lib/libcrypto/dh/dh.h b/lib/libcrypto/dh/dh.h
index 631cd5c6859..920af3b92d4 100644
--- a/lib/libcrypto/dh/dh.h
+++ b/lib/libcrypto/dh/dh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh.h,v 1.17 2016/06/30 02:02:06 bcook Exp $ */
+/* $OpenBSD: dh.h,v 1.18 2016/11/04 18:35:30 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -165,12 +165,10 @@ struct dh_st
this for backward compatibility: */
#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
-#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
- (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
-#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
- (unsigned char *)(x))
-#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
-#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
+DH *d2i_DHparams_bio(BIO *bp, DH **a);
+int i2d_DHparams_bio(BIO *bp, DH *a);
+DH *d2i_DHparams_fp(FILE *fp, DH **a);
+int i2d_DHparams_fp(FILE *fp, DH *a);
DH *DHparams_dup(DH *);
diff --git a/lib/libcrypto/dh/dh_asn1.c b/lib/libcrypto/dh/dh_asn1.c
index 7060130ed86..d7fd4f7d88a 100644
--- a/lib/libcrypto/dh/dh_asn1.c
+++ b/lib/libcrypto/dh/dh_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh_asn1.c,v 1.8 2015/02/14 15:06:55 jsing Exp $ */
+/* $OpenBSD: dh_asn1.c,v 1.9 2016/11/04 18:35:30 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -137,6 +137,30 @@ i2d_DHparams(const DH *a, unsigned char **out)
}
DH *
+d2i_DHparams_bio(BIO *bp, DH **a)
+{
+ return ASN1_item_d2i_bio(&DHparams_it, bp, a);
+}
+
+int
+i2d_DHparams_bio(BIO *bp, DH *a)
+{
+ return ASN1_item_i2d_bio(&DHparams_it, bp, a);
+}
+
+DH *
+d2i_DHparams_fp(FILE *fp, DH **a)
+{
+ return ASN1_item_d2i_fp(&DHparams_it, fp, a);
+}
+
+int
+i2d_DHparams_fp(FILE *fp, DH *a)
+{
+ return ASN1_item_i2d_fp(&DHparams_it, fp, a);
+}
+
+DH *
DHparams_dup(DH *dh)
{
return ASN1_item_dup(ASN1_ITEM_rptr(DHparams), dh);
diff --git a/lib/libcrypto/dsa/dsa.h b/lib/libcrypto/dsa/dsa.h
index b4d7c1ff0f7..6ddd4c35d5c 100644
--- a/lib/libcrypto/dsa/dsa.h
+++ b/lib/libcrypto/dsa/dsa.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsa.h,v 1.21 2016/06/30 02:02:06 bcook Exp $ */
+/* $OpenBSD: dsa.h,v 1.22 2016/11/04 18:35:30 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -173,13 +173,10 @@ struct dsa_st
ENGINE *engine;
};
-#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
- (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
-#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
- (unsigned char *)(x))
-#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)
-#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
-
+DSA *d2i_DSAparams_bio(BIO *bp, DSA **a);
+int i2d_DSAparams_bio(BIO *bp, DSA *a);
+DSA *d2i_DSAparams_fp(FILE *fp, DSA **a);
+int i2d_DSAparams_fp(FILE *fp, DSA *a);
DSA *DSAparams_dup(DSA *x);
DSA_SIG * DSA_SIG_new(void);
diff --git a/lib/libcrypto/dsa/dsa_asn1.c b/lib/libcrypto/dsa/dsa_asn1.c
index 8c5d93105ca..6366acdd79c 100644
--- a/lib/libcrypto/dsa/dsa_asn1.c
+++ b/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsa_asn1.c,v 1.16 2015/02/14 15:06:55 jsing Exp $ */
+/* $OpenBSD: dsa_asn1.c,v 1.17 2016/11/04 18:35:30 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -283,6 +283,30 @@ i2d_DSAparams(const DSA *a, unsigned char **out)
return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSAparams_it);
}
+DSA *
+d2i_DSAparams_bio(BIO *bp, DSA **a)
+{
+ return ASN1_item_d2i_bio(&DSAparams_it, bp, a);
+}
+
+int
+i2d_DSAparams_bio(BIO *bp, DSA *a)
+{
+ return ASN1_item_i2d_bio(&DSAparams_it, bp, a);
+}
+
+DSA *
+d2i_DSAparams_fp(FILE *fp, DSA **a)
+{
+ return ASN1_item_d2i_fp(&DSAparams_it, fp, a);
+}
+
+int
+i2d_DSAparams_fp(FILE *fp, DSA *a)
+{
+ return ASN1_item_i2d_fp(&DSAparams_it, fp, a);
+}
+
/*
* DSA public key is a bit trickier... its effectively a CHOICE type
* decided by a field called write_params which can either write out
diff --git a/lib/libcrypto/ocsp/ocsp.h b/lib/libcrypto/ocsp/ocsp.h
index 90f0edf289a..24592bc3cc5 100644
--- a/lib/libcrypto/ocsp/ocsp.h
+++ b/lib/libcrypto/ocsp/ocsp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ocsp.h,v 1.8 2016/09/04 17:18:18 jsing Exp $ */
+/* $OpenBSD: ocsp.h,v 1.9 2016/11/04 18:35:30 jsing Exp $ */
/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
* project. */
@@ -343,12 +343,6 @@ typedef struct ocsp_service_locator_st {
#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
-#define d2i_OCSP_REQUEST_bio(bp,p) \
- ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
-
-#define d2i_OCSP_RESPONSE_bio(bp,p) \
- ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
-
#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) \
(OCSP_REQUEST *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_REQUEST, \
PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
@@ -365,12 +359,6 @@ typedef struct ocsp_service_locator_st {
PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
bp,(char *)o, NULL,NULL,0,NULL,NULL)
-#define i2d_OCSP_RESPONSE_bio(bp,o) \
- ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
-
-#define i2d_OCSP_REQUEST_bio(bp,o) \
- ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
-
#define OCSP_REQUEST_sign(o,pkey,md) \
ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO), \
o->optionalSignature->signatureAlgorithm,NULL, \
@@ -560,6 +548,8 @@ OCSP_RESPONSE *OCSP_RESPONSE_new(void);
void OCSP_RESPONSE_free(OCSP_RESPONSE *a);
OCSP_RESPONSE *d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len);
int i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out);
+OCSP_RESPONSE *d2i_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE **a);
+int i2d_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE *a);
extern const ASN1_ITEM OCSP_RESPONSE_it;
OCSP_RESPBYTES *OCSP_RESPBYTES_new(void);
void OCSP_RESPBYTES_free(OCSP_RESPBYTES *a);
@@ -580,6 +570,8 @@ OCSP_REQUEST *OCSP_REQUEST_new(void);
void OCSP_REQUEST_free(OCSP_REQUEST *a);
OCSP_REQUEST *d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len);
int i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out);
+OCSP_REQUEST *d2i_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST **a);
+int i2d_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST *a);
extern const ASN1_ITEM OCSP_REQUEST_it;
OCSP_SIGNATURE *OCSP_SIGNATURE_new(void);
void OCSP_SIGNATURE_free(OCSP_SIGNATURE *a);
diff --git a/lib/libcrypto/ocsp/ocsp_asn.c b/lib/libcrypto/ocsp/ocsp_asn.c
index 72e7638c759..bb58ca79abf 100644
--- a/lib/libcrypto/ocsp/ocsp_asn.c
+++ b/lib/libcrypto/ocsp/ocsp_asn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ocsp_asn.c,v 1.8 2015/07/25 14:52:47 jsing Exp $ */
+/* $OpenBSD: ocsp_asn.c,v 1.9 2016/11/04 18:35:30 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -333,7 +333,6 @@ const ASN1_ITEM OCSP_REQUEST_it = {
.sname = "OCSP_REQUEST",
};
-
OCSP_REQUEST *
d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len)
{
@@ -348,6 +347,18 @@ i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out)
}
OCSP_REQUEST *
+d2i_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST **a)
+{
+ return ASN1_item_d2i_bio(&OCSP_REQUEST_it, bp, a);
+}
+
+int
+i2d_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST *a)
+{
+ return ASN1_item_i2d_bio(&OCSP_REQUEST_it, bp, a);
+}
+
+OCSP_REQUEST *
OCSP_REQUEST_new(void)
{
return (OCSP_REQUEST *)ASN1_item_new(&OCSP_REQUEST_it);
@@ -456,6 +467,18 @@ i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out)
}
OCSP_RESPONSE *
+d2i_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE **a)
+{
+ return ASN1_item_d2i_bio(&OCSP_RESPONSE_it, bp, a);
+}
+
+int
+i2d_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE *a)
+{
+ return ASN1_item_i2d_bio(&OCSP_RESPONSE_it, bp, a);
+}
+
+OCSP_RESPONSE *
OCSP_RESPONSE_new(void)
{
return (OCSP_RESPONSE *)ASN1_item_new(&OCSP_RESPONSE_it);
diff --git a/lib/libcrypto/ts/ts_asn1.c b/lib/libcrypto/ts/ts_asn1.c
index 13864832472..49232d8073b 100644
--- a/lib/libcrypto/ts/ts_asn1.c
+++ b/lib/libcrypto/ts/ts_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ts_asn1.c,v 1.9 2015/07/24 15:25:44 jsing Exp $ */
+/* $OpenBSD: ts_asn1.c,v 1.10 2016/11/04 18:35:30 jsing Exp $ */
/* Written by Nils Larsch for the OpenSSL project 2004.
*/
/* ====================================================================
@@ -124,28 +124,26 @@ TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *x)
TS_MSG_IMPRINT *
d2i_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT **a)
{
- return ASN1_d2i_bio_of(TS_MSG_IMPRINT, TS_MSG_IMPRINT_new,
- d2i_TS_MSG_IMPRINT, bp, a);
+ return ASN1_item_d2i_bio(&TS_MSG_IMPRINT_it, bp, a);
}
int
i2d_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT *a)
{
- return ASN1_i2d_bio_of_const(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, bp, a);
+ return ASN1_item_i2d_bio(&TS_MSG_IMPRINT_it, bp, a);
}
#endif
TS_MSG_IMPRINT *
d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a)
{
- return ASN1_d2i_fp_of(TS_MSG_IMPRINT, TS_MSG_IMPRINT_new,
- d2i_TS_MSG_IMPRINT, fp, a);
+ return ASN1_item_d2i_fp(&TS_MSG_IMPRINT_it, fp, a);
}
int
i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a)
{
- return ASN1_i2d_fp_of_const(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, fp, a);
+ return ASN1_item_i2d_fp(&TS_MSG_IMPRINT_it, fp, a);
}
static const ASN1_TEMPLATE TS_REQ_seq_tt[] = {
@@ -239,26 +237,26 @@ TS_REQ_dup(TS_REQ *x)
TS_REQ *
d2i_TS_REQ_bio(BIO *bp, TS_REQ **a)
{
- return ASN1_d2i_bio_of(TS_REQ, TS_REQ_new, d2i_TS_REQ, bp, a);
+ return ASN1_item_d2i_bio(&TS_REQ_it, bp, a);
}
int
i2d_TS_REQ_bio(BIO *bp, TS_REQ *a)
{
- return ASN1_i2d_bio_of_const(TS_REQ, i2d_TS_REQ, bp, a);
+ return ASN1_item_i2d_bio(&TS_REQ_it, bp, a);
}
#endif
TS_REQ *
d2i_TS_REQ_fp(FILE *fp, TS_REQ **a)
{
- return ASN1_d2i_fp_of(TS_REQ, TS_REQ_new, d2i_TS_REQ, fp, a);
+ return ASN1_item_d2i_fp(&TS_REQ_it, fp, a);
}
int
i2d_TS_REQ_fp(FILE *fp, TS_REQ *a)
{
- return ASN1_i2d_fp_of_const(TS_REQ, i2d_TS_REQ, fp, a);
+ return ASN1_item_i2d_fp(&TS_REQ_it, fp, a);
}
static const ASN1_TEMPLATE TS_ACCURACY_seq_tt[] = {
@@ -446,28 +444,26 @@ TS_TST_INFO_dup(TS_TST_INFO *x)
TS_TST_INFO *
d2i_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO **a)
{
- return ASN1_d2i_bio_of(TS_TST_INFO, TS_TST_INFO_new, d2i_TS_TST_INFO,
- bp, a);
+ return ASN1_item_d2i_bio(&TS_TST_INFO_it, bp, a);
}
int
i2d_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO *a)
{
- return ASN1_i2d_bio_of_const(TS_TST_INFO, i2d_TS_TST_INFO, bp, a);
+ return ASN1_item_i2d_bio(&TS_TST_INFO_it, bp, a);
}
#endif
TS_TST_INFO *
d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a)
{
- return ASN1_d2i_fp_of(TS_TST_INFO, TS_TST_INFO_new, d2i_TS_TST_INFO,
- fp, a);
+ return ASN1_item_d2i_fp(&TS_TST_INFO_it, fp, a);
}
int
i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a)
{
- return ASN1_i2d_fp_of_const(TS_TST_INFO, i2d_TS_TST_INFO, fp, a);
+ return ASN1_item_i2d_fp(&TS_TST_INFO_it, fp, a);
}
static const ASN1_TEMPLATE TS_STATUS_INFO_seq_tt[] = {
@@ -652,26 +648,26 @@ TS_RESP_dup(TS_RESP *x)
TS_RESP *
d2i_TS_RESP_bio(BIO *bp, TS_RESP **a)
{
- return ASN1_d2i_bio_of(TS_RESP, TS_RESP_new, d2i_TS_RESP, bp, a);
+ return ASN1_item_d2i_bio(&TS_RESP_it, bp, a);
}
int
i2d_TS_RESP_bio(BIO *bp, TS_RESP *a)
{
- return ASN1_i2d_bio_of_const(TS_RESP, i2d_TS_RESP, bp, a);
+ return ASN1_item_i2d_bio(&TS_RESP_it, bp, a);
}
#endif
TS_RESP *
d2i_TS_RESP_fp(FILE *fp, TS_RESP **a)
{
- return ASN1_d2i_fp_of(TS_RESP, TS_RESP_new, d2i_TS_RESP, fp, a);
+ return ASN1_item_d2i_fp(&TS_RESP_it, fp, a);
}
int
i2d_TS_RESP_fp(FILE *fp, TS_RESP *a)
{
- return ASN1_i2d_fp_of_const(TS_RESP, i2d_TS_RESP, fp, a);
+ return ASN1_item_i2d_fp(&TS_RESP_it, fp, a);
}
static const ASN1_TEMPLATE ESS_ISSUER_SERIAL_seq_tt[] = {