summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-07-24 08:16:47 +0000
committertb <>2022-07-24 08:16:47 +0000
commitc6dd71252b6c9201b8a8d7cf63bdace12547b030 (patch)
treed4b5a641a1e684361d921596482872ed4f79e586
parent180a8f0f93ad83bf01f8c87a002ea920ac0d0429 (diff)
downloadopenbsd-c6dd71252b6c9201b8a8d7cf63bdace12547b030.tar.gz
openbsd-c6dd71252b6c9201b8a8d7cf63bdace12547b030.tar.bz2
openbsd-c6dd71252b6c9201b8a8d7cf63bdace12547b030.zip
Start making ts opaque
Move the not yet exposed EssCertIDv2 struct internals to ts_local.h and move the ASN.1 function prototypes that we don't want to expose with them. Include ts_local.h where necessary or where it will be needed soon. ok jsing
-rw-r--r--src/lib/libcrypto/Makefile3
-rw-r--r--src/lib/libcrypto/ts/ts.h45
-rw-r--r--src/lib/libcrypto/ts/ts_asn1.c4
-rw-r--r--src/lib/libcrypto/ts/ts_local.h110
-rw-r--r--src/lib/libcrypto/ts/ts_req_utils.c4
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_print.c4
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_sign.c3
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_utils.c4
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_verify.c3
-rw-r--r--src/lib/libcrypto/ts/ts_verify_ctx.c4
10 files changed, 134 insertions, 50 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile
index 81755cc369..423fba5f58 100644
--- a/src/lib/libcrypto/Makefile
+++ b/src/lib/libcrypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.76 2022/07/13 06:32:54 tb Exp $ 1# $OpenBSD: Makefile,v 1.77 2022/07/24 08:16:47 tb Exp $
2 2
3LIB= crypto 3LIB= crypto
4LIBREBUILD=y 4LIBREBUILD=y
@@ -44,6 +44,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/kdf
44CFLAGS+= -I${LCRYPTO_SRC}/modes 44CFLAGS+= -I${LCRYPTO_SRC}/modes
45CFLAGS+= -I${LCRYPTO_SRC}/ocsp 45CFLAGS+= -I${LCRYPTO_SRC}/ocsp
46CFLAGS+= -I${LCRYPTO_SRC}/rsa 46CFLAGS+= -I${LCRYPTO_SRC}/rsa
47CFLAGS+= -I${LCRYPTO_SRC}/ts
47CFLAGS+= -I${LCRYPTO_SRC}/x509 48CFLAGS+= -I${LCRYPTO_SRC}/x509
48 49
49VERSION_SCRIPT= Symbols.map 50VERSION_SCRIPT= Symbols.map
diff --git a/src/lib/libcrypto/ts/ts.h b/src/lib/libcrypto/ts/ts.h
index bfcf9dfe8f..31b916983e 100644
--- a/src/lib/libcrypto/ts/ts.h
+++ b/src/lib/libcrypto/ts/ts.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts.h,v 1.14 2022/07/23 07:13:03 tb Exp $ */ 1/* $OpenBSD: ts.h,v 1.15 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL
3 * project 2002, 2003, 2004. 3 * project 2002, 2003, 2004.
4 */ 4 */
@@ -265,32 +265,10 @@ typedef struct ESS_signing_cert {
265} ESS_SIGNING_CERT; 265} ESS_SIGNING_CERT;
266 266
267#ifdef LIBRESSL_INTERNAL 267#ifdef LIBRESSL_INTERNAL
268/* 268typedef struct ESS_cert_id_v2 ESS_CERT_ID_V2;
269 * ESSCertIDv2 ::= SEQUENCE {
270 * hashAlgorithm AlgorithmIdentifier
271 * DEFAULT {algorithm id-sha256},
272 * certHash Hash,
273 * issuerSerial IssuerSerial OPTIONAL }
274 */
275
276typedef struct ESS_cert_id_v2 {
277 X509_ALGOR *hash_alg; /* Default SHA-256. */
278 ASN1_OCTET_STRING *hash;
279 ESS_ISSUER_SERIAL *issuer_serial;
280} ESS_CERT_ID_V2;
281
282DECLARE_STACK_OF(ESS_CERT_ID_V2) 269DECLARE_STACK_OF(ESS_CERT_ID_V2)
283 270
284/* 271typedef struct ESS_signing_cert_v2 ESS_SIGNING_CERT_V2;
285 * SigningCertificateV2 ::= SEQUENCE {
286 * certs SEQUENCE OF ESSCertIDv2,
287 * policies SEQUENCE OF PolicyInformation OPTIONAL }
288 */
289
290typedef struct ESS_signing_cert_v2 {
291 STACK_OF(ESS_CERT_ID_V2) *cert_ids;
292 STACK_OF(POLICYINFO) *policy_info;
293} ESS_SIGNING_CERT_V2;
294#endif /* LIBRESSL_INTERNAL */ 272#endif /* LIBRESSL_INTERNAL */
295 273
296TS_REQ *TS_REQ_new(void); 274TS_REQ *TS_REQ_new(void);
@@ -379,23 +357,6 @@ ESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,
379 const unsigned char **pp, long length); 357 const unsigned char **pp, long length);
380ESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a); 358ESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);
381 359
382#ifdef LIBRESSL_INTERNAL
383ESS_CERT_ID_V2 *ESS_CERT_ID_V2_new(void);
384void ESS_CERT_ID_V2_free(ESS_CERT_ID_V2 *a);
385int i2d_ESS_CERT_ID_V2(const ESS_CERT_ID_V2 *a, unsigned char **pp);
386ESS_CERT_ID_V2 *d2i_ESS_CERT_ID_V2(ESS_CERT_ID_V2 **a, const unsigned char **pp,
387 long length);
388ESS_CERT_ID_V2 *ESS_CERT_ID_V2_dup(ESS_CERT_ID_V2 *a);
389
390ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_new(void);
391void ESS_SIGNING_CERT_V2_free(ESS_SIGNING_CERT_V2 *a);
392int i2d_ESS_SIGNING_CERT_V2(const ESS_SIGNING_CERT_V2 *a,
393 unsigned char **pp);
394ESS_SIGNING_CERT_V2 *d2i_ESS_SIGNING_CERT_V2(ESS_SIGNING_CERT_V2 **a,
395 const unsigned char **pp, long length);
396ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_dup(ESS_SIGNING_CERT_V2 *a);
397#endif /* LIBRESSL_INTERNAL */
398
399int TS_REQ_set_version(TS_REQ *a, long version); 360int TS_REQ_set_version(TS_REQ *a, long version);
400long TS_REQ_get_version(const TS_REQ *a); 361long TS_REQ_get_version(const TS_REQ *a);
401 362
diff --git a/src/lib/libcrypto/ts/ts_asn1.c b/src/lib/libcrypto/ts/ts_asn1.c
index c4316d13f8..6537f1c85a 100644
--- a/src/lib/libcrypto/ts/ts_asn1.c
+++ b/src/lib/libcrypto/ts/ts_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_asn1.c,v 1.12 2022/07/16 18:36:36 kn Exp $ */ 1/* $OpenBSD: ts_asn1.c,v 1.13 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Nils Larsch for the OpenSSL project 2004. 2/* Written by Nils Larsch for the OpenSSL project 2004.
3 */ 3 */
4/* ==================================================================== 4/* ====================================================================
@@ -61,6 +61,8 @@
61#include <openssl/err.h> 61#include <openssl/err.h>
62#include <openssl/asn1t.h> 62#include <openssl/asn1t.h>
63 63
64#include "ts_local.h"
65
64static const ASN1_TEMPLATE TS_MSG_IMPRINT_seq_tt[] = { 66static const ASN1_TEMPLATE TS_MSG_IMPRINT_seq_tt[] = {
65 { 67 {
66 .flags = 0, 68 .flags = 0,
diff --git a/src/lib/libcrypto/ts/ts_local.h b/src/lib/libcrypto/ts/ts_local.h
new file mode 100644
index 0000000000..01d26de127
--- /dev/null
+++ b/src/lib/libcrypto/ts/ts_local.h
@@ -0,0 +1,110 @@
1/* $OpenBSD: ts_local.h,v 1.1 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL
3 * project 2002, 2003, 2004.
4 */
5/* ====================================================================
6 * Copyright (c) 2006 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#ifndef HEADER_TS_LOCAL_H
60#define HEADER_TS_LOCAL_H
61
62__BEGIN_HIDDEN_DECLS
63
64/*
65 * ESSCertIDv2 ::= SEQUENCE {
66 * hashAlgorithm AlgorithmIdentifier
67 * DEFAULT {algorithm id-sha256},
68 * certHash Hash,
69 * issuerSerial IssuerSerial OPTIONAL }
70 */
71
72struct ESS_cert_id_v2 {
73 X509_ALGOR *hash_alg; /* Default SHA-256. */
74 ASN1_OCTET_STRING *hash;
75 ESS_ISSUER_SERIAL *issuer_serial;
76};
77
78/*
79 * SigningCertificateV2 ::= SEQUENCE {
80 * certs SEQUENCE OF ESSCertIDv2,
81 * policies SEQUENCE OF PolicyInformation OPTIONAL }
82 */
83
84struct ESS_signing_cert_v2 {
85 STACK_OF(ESS_CERT_ID_V2) *cert_ids;
86 STACK_OF(POLICYINFO) *policy_info;
87};
88
89/*
90 * Public OpenSSL API that we do not currently want to expose.
91 */
92
93ESS_CERT_ID_V2 *ESS_CERT_ID_V2_new(void);
94void ESS_CERT_ID_V2_free(ESS_CERT_ID_V2 *a);
95int i2d_ESS_CERT_ID_V2(const ESS_CERT_ID_V2 *a, unsigned char **pp);
96ESS_CERT_ID_V2 *d2i_ESS_CERT_ID_V2(ESS_CERT_ID_V2 **a, const unsigned char **pp,
97 long length);
98ESS_CERT_ID_V2 *ESS_CERT_ID_V2_dup(ESS_CERT_ID_V2 *a);
99
100ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_new(void);
101void ESS_SIGNING_CERT_V2_free(ESS_SIGNING_CERT_V2 *a);
102int i2d_ESS_SIGNING_CERT_V2(const ESS_SIGNING_CERT_V2 *a,
103 unsigned char **pp);
104ESS_SIGNING_CERT_V2 *d2i_ESS_SIGNING_CERT_V2(ESS_SIGNING_CERT_V2 **a,
105 const unsigned char **pp, long length);
106ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_dup(ESS_SIGNING_CERT_V2 *a);
107
108__END_HIDDEN_DECLS
109
110#endif /* HEADER_TS_LOCAL_H */
diff --git a/src/lib/libcrypto/ts/ts_req_utils.c b/src/lib/libcrypto/ts/ts_req_utils.c
index 6b9c13f39b..8d9d6f3e61 100644
--- a/src/lib/libcrypto/ts/ts_req_utils.c
+++ b/src/lib/libcrypto/ts/ts_req_utils.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_req_utils.c,v 1.6 2018/05/13 15:04:05 tb Exp $ */ 1/* $OpenBSD: ts_req_utils.c,v 1.7 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -63,6 +63,8 @@
63#include <openssl/ts.h> 63#include <openssl/ts.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66#include "ts_local.h"
67
66int 68int
67TS_REQ_set_version(TS_REQ *a, long version) 69TS_REQ_set_version(TS_REQ *a, long version)
68{ 70{
diff --git a/src/lib/libcrypto/ts/ts_rsp_print.c b/src/lib/libcrypto/ts/ts_rsp_print.c
index c442b71646..cfff955cd6 100644
--- a/src/lib/libcrypto/ts/ts_rsp_print.c
+++ b/src/lib/libcrypto/ts/ts_rsp_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_print.c,v 1.5 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: ts_rsp_print.c,v 1.6 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -63,6 +63,8 @@
63#include <openssl/ts.h> 63#include <openssl/ts.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66#include "ts_local.h"
67
66struct status_map_st { 68struct status_map_st {
67 int bit; 69 int bit;
68 const char *text; 70 const char *text;
diff --git a/src/lib/libcrypto/ts/ts_rsp_sign.c b/src/lib/libcrypto/ts/ts_rsp_sign.c
index 55738875db..665dc1cec4 100644
--- a/src/lib/libcrypto/ts/ts_rsp_sign.c
+++ b/src/lib/libcrypto/ts/ts_rsp_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_sign.c,v 1.27 2022/07/16 16:42:58 kn Exp $ */ 1/* $OpenBSD: ts_rsp_sign.c,v 1.28 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -66,6 +66,7 @@
66#include <openssl/ts.h> 66#include <openssl/ts.h>
67 67
68#include "evp_locl.h" 68#include "evp_locl.h"
69#include "ts_local.h"
69#include "x509_lcl.h" 70#include "x509_lcl.h"
70 71
71/* Private function declarations. */ 72/* Private function declarations. */
diff --git a/src/lib/libcrypto/ts/ts_rsp_utils.c b/src/lib/libcrypto/ts/ts_rsp_utils.c
index 233df867ac..995dbb8035 100644
--- a/src/lib/libcrypto/ts/ts_rsp_utils.c
+++ b/src/lib/libcrypto/ts/ts_rsp_utils.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_utils.c,v 1.7 2018/05/13 15:35:46 tb Exp $ */ 1/* $OpenBSD: ts_rsp_utils.c,v 1.8 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -63,6 +63,8 @@
63#include <openssl/pkcs7.h> 63#include <openssl/pkcs7.h>
64#include <openssl/ts.h> 64#include <openssl/ts.h>
65 65
66#include "ts_local.h"
67
66/* Function definitions. */ 68/* Function definitions. */
67 69
68int 70int
diff --git a/src/lib/libcrypto/ts/ts_rsp_verify.c b/src/lib/libcrypto/ts/ts_rsp_verify.c
index 816d7000f3..a5829b35ca 100644
--- a/src/lib/libcrypto/ts/ts_rsp_verify.c
+++ b/src/lib/libcrypto/ts/ts_rsp_verify.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_verify.c,v 1.27 2022/07/17 19:40:38 kn Exp $ */ 1/* $OpenBSD: ts_rsp_verify.c,v 1.28 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -65,6 +65,7 @@
65#include <openssl/ts.h> 65#include <openssl/ts.h>
66 66
67#include "evp_locl.h" 67#include "evp_locl.h"
68#include "ts_local.h"
68#include "x509_lcl.h" 69#include "x509_lcl.h"
69 70
70/* Private function declarations. */ 71/* Private function declarations. */
diff --git a/src/lib/libcrypto/ts/ts_verify_ctx.c b/src/lib/libcrypto/ts/ts_verify_ctx.c
index 7608a7d109..83ef54a894 100644
--- a/src/lib/libcrypto/ts/ts_verify_ctx.c
+++ b/src/lib/libcrypto/ts/ts_verify_ctx.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_verify_ctx.c,v 1.9 2017/01/29 17:49:23 beck Exp $ */ 1/* $OpenBSD: ts_verify_ctx.c,v 1.10 2022/07/24 08:16:47 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2003. 3 * project 2003.
4 */ 4 */
@@ -62,6 +62,8 @@
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/ts.h> 63#include <openssl/ts.h>
64 64
65#include "ts_local.h"
66
65TS_VERIFY_CTX * 67TS_VERIFY_CTX *
66TS_VERIFY_CTX_new(void) 68TS_VERIFY_CTX_new(void)
67{ 69{