]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/ocsp/ocsp_req.c
2 /* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
6 This file was originally part of ocsp.c and was transfered to Richard
7 Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included
8 in OpenSSL or released as a patch kit. */
10 /* ====================================================================
11 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
25 * 3. All advertising materials mentioning features or use of this
26 * software must display the following acknowledgment:
27 * "This product includes software developed by the OpenSSL Project
28 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
30 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31 * endorse or promote products derived from this software without
32 * prior written permission. For written permission, please contact
33 * openssl-core@openssl.org.
35 * 5. Products derived from this software may not be called "OpenSSL"
36 * nor may "OpenSSL" appear in their names without prior written
37 * permission of the OpenSSL Project.
39 * 6. Redistributions of any form whatsoever must retain the following
41 * "This product includes software developed by the OpenSSL Project
42 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
44 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
48 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 * ====================================================================
58 * This product includes cryptographic software written by Eric Young
59 * (eay@cryptsoft.com). This product includes software written by Tim
60 * Hudson (tjh@cryptsoft.com).
64 #include <openssl/bio.h>
65 #include <openssl/asn1.h>
66 #include <openssl/err.h>
67 #include <openssl/ocsp.h>
68 #include <openssl/x509v3.h>
70 int i2a_OCSP_REQINFO(BIO
*bp
,
74 if (a
->version
== NULL
) BIO_puts(bp
, "0");
75 else i2a_ASN1_INTEGER(bp
, a
->version
);
76 if (a
->requestorName
!= NULL
)
80 i2a_GENERAL_NAME(bp
, a
->requestorName
); /* does not exist */
83 if (a
->requestList
!= NULL
)
85 for (i
=0; i
<sk_OCSP_ONEREQ_num(a
->requestList
); i
++)
86 if (sk_OCSP_ONEREQ_value(a
->requestList
,i
) != NULL
)
88 sk_OCSP_ONEREQ_value(a
->requestList
,i
));
89 j
+=sk_OCSP_ONEREQ_num(a
->requestList
);
91 j
+=OCSP_extensions_print(bp
, a
->requestExtensions
,
92 "Request Extensions");
96 int i2a_OCSP_REQUEST(BIO
*bp
,
99 i2a_OCSP_REQINFO(bp
, a
->tbsRequest
);
100 i2a_OCSP_SIGNATURE(bp
, a
->optionalSignature
);
101 return a
->optionalSignature
? 2 : 1;
104 int i2a_OCSP_ONEREQ(BIO
*bp
,
107 i2a_OCSP_CERTID(bp
, a
->reqCert
);
109 /* XXX need generic extension print method or need to register
110 * ocsp extensions with existing extension handler mechanism,
111 * invoke i2a callbacks.
113 if (a
->singleRequestExtensions
!= NULL
)
115 for (i
=0; i
<sk_X509_EXTENSION_num(a
->singleRequestExtensions
); i
++)
116 if (sk_X509_EXTENSION_value(a
->singleRequestExtensions
,i
) != NULL
)
117 i2a_X509_EXTENSION(bp
,
118 sk_X509_EXTENSION_value(
119 a
->singleRequestExtensions
, i
));
120 j
+=sk_X509_EXTENSION_num(a
->singleRequestExtensions
);