asn1_locl.h revision 290207
1279377Simp/* asn1t.h */
2279377Simp/*
3279377Simp * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4279377Simp * 2006.
5279377Simp */
6279377Simp/* ====================================================================
7279377Simp * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.
8279377Simp *
9279377Simp * Redistribution and use in source and binary forms, with or without
10279377Simp * modification, are permitted provided that the following conditions
11279377Simp * are met:
12279377Simp *
13279377Simp * 1. Redistributions of source code must retain the above copyright
14279377Simp *    notice, this list of conditions and the following disclaimer.
15279377Simp *
16279377Simp * 2. Redistributions in binary form must reproduce the above copyright
17279377Simp *    notice, this list of conditions and the following disclaimer in
18279377Simp *    the documentation and/or other materials provided with the
19279377Simp *    distribution.
20279377Simp *
21279377Simp * 3. All advertising materials mentioning features or use of this
22279377Simp *    software must display the following acknowledgment:
23279377Simp *    "This product includes software developed by the OpenSSL Project
24279377Simp *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25279377Simp *
26279377Simp * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27279377Simp *    endorse or promote products derived from this software without
28279377Simp *    prior written permission. For written permission, please contact
29279377Simp *    licensing@OpenSSL.org.
30279377Simp *
31279377Simp * 5. Products derived from this software may not be called "OpenSSL"
32279377Simp *    nor may "OpenSSL" appear in their names without prior written
33279377Simp *    permission of the OpenSSL Project.
34279377Simp *
35279377Simp * 6. Redistributions of any form whatsoever must retain the following
36279377Simp *    acknowledgment:
37279377Simp *    "This product includes software developed by the OpenSSL Project
38279377Simp *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39279377Simp *
40279377Simp * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41279377Simp * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42279377Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43279377Simp * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44279377Simp * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45279377Simp * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46279377Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47279377Simp * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48279377Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49279377Simp * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50279377Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51279377Simp * OF THE POSSIBILITY OF SUCH DAMAGE.
52279377Simp * ====================================================================
53279377Simp *
54279377Simp * This product includes cryptographic software written by Eric Young
55279377Simp * (eay@cryptsoft.com).  This product includes software written by Tim
56279377Simp * Hudson (tjh@cryptsoft.com).
57279377Simp *
58279377Simp */
59279377Simp
60279377Simp/* Internal ASN1 structures and functions: not for application use */
61279377Simp
62279377Simpint asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
63279377Simpint asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
64279377Simp
65279377Simp/* ASN1 print context structure */
66279377Simp
67279377Simpstruct asn1_pctx_st {
68279377Simp    unsigned long flags;
69279377Simp    unsigned long nm_flags;
70279377Simp    unsigned long cert_flags;
71279377Simp    unsigned long oid_flags;
72279377Simp    unsigned long str_flags;
73279377Simp} /* ASN1_PCTX */ ;
74279377Simp
75279377Simp/* ASN1 public key method structure */
76279377Simp
77279377Simpstruct evp_pkey_asn1_method_st {
78279377Simp    int pkey_id;
79279377Simp    int pkey_base_id;
80279377Simp    unsigned long pkey_flags;
81279377Simp    char *pem_str;
82279377Simp    char *info;
83279377Simp    int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub);
84279377Simp    int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk);
85279377Simp    int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
86279377Simp    int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent,
87279377Simp                      ASN1_PCTX *pctx);
88279377Simp    int (*priv_decode) (EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf);
89279377Simp    int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);
90279377Simp    int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent,
91279377Simp                       ASN1_PCTX *pctx);
92279377Simp    int (*pkey_size) (const EVP_PKEY *pk);
93279377Simp    int (*pkey_bits) (const EVP_PKEY *pk);
94279377Simp    int (*param_decode) (EVP_PKEY *pkey,
95279377Simp                         const unsigned char **pder, int derlen);
96279377Simp    int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder);
97279377Simp    int (*param_missing) (const EVP_PKEY *pk);
98279377Simp    int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from);
99279377Simp    int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
100279377Simp    int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent,
101279377Simp                        ASN1_PCTX *pctx);
102279377Simp    int (*sig_print) (BIO *out,
103279377Simp                      const X509_ALGOR *sigalg, const ASN1_STRING *sig,
104279377Simp                      int indent, ASN1_PCTX *pctx);
105279377Simp    void (*pkey_free) (EVP_PKEY *pkey);
106279377Simp    int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2);
107279377Simp    /* Legacy functions for old PEM */
108279377Simp    int (*old_priv_decode) (EVP_PKEY *pkey,
109279377Simp                            const unsigned char **pder, int derlen);
110279377Simp    int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder);
111279377Simp    /* Custom ASN1 signature verification */
112279377Simp    int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
113279377Simp                        X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey);
114279377Simp    int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
115279377Simp                      X509_ALGOR *alg1, X509_ALGOR *alg2,
116279377Simp                      ASN1_BIT_STRING *sig);
117279377Simp} /* EVP_PKEY_ASN1_METHOD */ ;
118279377Simp
119279377Simp/*
120279377Simp * Method to handle CRL access. In general a CRL could be very large (several
121279377Simp * Mb) and can consume large amounts of resources if stored in memory by
122279377Simp * multiple processes. This method allows general CRL operations to be
123279377Simp * redirected to more efficient callbacks: for example a CRL entry database.
124279377Simp */
125279377Simp
126279377Simp#define X509_CRL_METHOD_DYNAMIC         1
127279377Simp
128279377Simpstruct x509_crl_method_st {
129279377Simp    int flags;
130279377Simp    int (*crl_init) (X509_CRL *crl);
131279377Simp    int (*crl_free) (X509_CRL *crl);
132279377Simp    int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret,
133279377Simp                       ASN1_INTEGER *ser, X509_NAME *issuer);
134279377Simp    int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk);
135279377Simp};
136279377Simp