1238384Sjkim/* asn1t.h */
2296341Sdelphij/*
3296341Sdelphij * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4296341Sdelphij * 2006.
5238384Sjkim */
6238384Sjkim/* ====================================================================
7238384Sjkim * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.
8238384Sjkim *
9238384Sjkim * Redistribution and use in source and binary forms, with or without
10238384Sjkim * modification, are permitted provided that the following conditions
11238384Sjkim * are met:
12238384Sjkim *
13238384Sjkim * 1. Redistributions of source code must retain the above copyright
14296341Sdelphij *    notice, this list of conditions and the following disclaimer.
15238384Sjkim *
16238384Sjkim * 2. Redistributions in binary form must reproduce the above copyright
17238384Sjkim *    notice, this list of conditions and the following disclaimer in
18238384Sjkim *    the documentation and/or other materials provided with the
19238384Sjkim *    distribution.
20238384Sjkim *
21238384Sjkim * 3. All advertising materials mentioning features or use of this
22238384Sjkim *    software must display the following acknowledgment:
23238384Sjkim *    "This product includes software developed by the OpenSSL Project
24238384Sjkim *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25238384Sjkim *
26238384Sjkim * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27238384Sjkim *    endorse or promote products derived from this software without
28238384Sjkim *    prior written permission. For written permission, please contact
29238384Sjkim *    licensing@OpenSSL.org.
30238384Sjkim *
31238384Sjkim * 5. Products derived from this software may not be called "OpenSSL"
32238384Sjkim *    nor may "OpenSSL" appear in their names without prior written
33238384Sjkim *    permission of the OpenSSL Project.
34238384Sjkim *
35238384Sjkim * 6. Redistributions of any form whatsoever must retain the following
36238384Sjkim *    acknowledgment:
37238384Sjkim *    "This product includes software developed by the OpenSSL Project
38238384Sjkim *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39238384Sjkim *
40238384Sjkim * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41238384Sjkim * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42238384Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43238384Sjkim * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44238384Sjkim * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45238384Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46238384Sjkim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47238384Sjkim * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48238384Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49238384Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50238384Sjkim * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51238384Sjkim * OF THE POSSIBILITY OF SUCH DAMAGE.
52238384Sjkim * ====================================================================
53238384Sjkim *
54238384Sjkim * This product includes cryptographic software written by Eric Young
55238384Sjkim * (eay@cryptsoft.com).  This product includes software written by Tim
56238384Sjkim * Hudson (tjh@cryptsoft.com).
57238384Sjkim *
58238384Sjkim */
59238384Sjkim
60238384Sjkim/* Internal ASN1 structures and functions: not for application use */
61238384Sjkim
62238384Sjkim/* ASN1 print context structure */
63238384Sjkim
64296341Sdelphijstruct asn1_pctx_st {
65296341Sdelphij    unsigned long flags;
66296341Sdelphij    unsigned long nm_flags;
67296341Sdelphij    unsigned long cert_flags;
68296341Sdelphij    unsigned long oid_flags;
69296341Sdelphij    unsigned long str_flags;
70296341Sdelphij} /* ASN1_PCTX */ ;
71238384Sjkim
72238384Sjkim/* ASN1 public key method structure */
73238384Sjkim
74296341Sdelphijstruct evp_pkey_asn1_method_st {
75296341Sdelphij    int pkey_id;
76296341Sdelphij    int pkey_base_id;
77296341Sdelphij    unsigned long pkey_flags;
78296341Sdelphij    char *pem_str;
79296341Sdelphij    char *info;
80296341Sdelphij    int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub);
81296341Sdelphij    int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk);
82296341Sdelphij    int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
83296341Sdelphij    int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent,
84296341Sdelphij                      ASN1_PCTX *pctx);
85296341Sdelphij    int (*priv_decode) (EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf);
86296341Sdelphij    int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);
87296341Sdelphij    int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent,
88296341Sdelphij                       ASN1_PCTX *pctx);
89296341Sdelphij    int (*pkey_size) (const EVP_PKEY *pk);
90296341Sdelphij    int (*pkey_bits) (const EVP_PKEY *pk);
91296341Sdelphij    int (*param_decode) (EVP_PKEY *pkey,
92296341Sdelphij                         const unsigned char **pder, int derlen);
93296341Sdelphij    int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder);
94296341Sdelphij    int (*param_missing) (const EVP_PKEY *pk);
95296341Sdelphij    int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from);
96296341Sdelphij    int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
97296341Sdelphij    int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent,
98296341Sdelphij                        ASN1_PCTX *pctx);
99296341Sdelphij    int (*sig_print) (BIO *out,
100296341Sdelphij                      const X509_ALGOR *sigalg, const ASN1_STRING *sig,
101296341Sdelphij                      int indent, ASN1_PCTX *pctx);
102296341Sdelphij    void (*pkey_free) (EVP_PKEY *pkey);
103296341Sdelphij    int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2);
104296341Sdelphij    /* Legacy functions for old PEM */
105296341Sdelphij    int (*old_priv_decode) (EVP_PKEY *pkey,
106296341Sdelphij                            const unsigned char **pder, int derlen);
107296341Sdelphij    int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder);
108296341Sdelphij    /* Custom ASN1 signature verification */
109296341Sdelphij    int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
110296341Sdelphij                        X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey);
111296341Sdelphij    int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
112296341Sdelphij                      X509_ALGOR *alg1, X509_ALGOR *alg2,
113296341Sdelphij                      ASN1_BIT_STRING *sig);
114296341Sdelphij} /* EVP_PKEY_ASN1_METHOD */ ;
115238384Sjkim
116296341Sdelphij/*
117296341Sdelphij * Method to handle CRL access. In general a CRL could be very large (several
118296341Sdelphij * Mb) and can consume large amounts of resources if stored in memory by
119296341Sdelphij * multiple processes. This method allows general CRL operations to be
120296341Sdelphij * redirected to more efficient callbacks: for example a CRL entry database.
121238384Sjkim */
122238384Sjkim
123296341Sdelphij#define X509_CRL_METHOD_DYNAMIC         1
124238384Sjkim
125296341Sdelphijstruct x509_crl_method_st {
126296341Sdelphij    int flags;
127296341Sdelphij    int (*crl_init) (X509_CRL *crl);
128296341Sdelphij    int (*crl_free) (X509_CRL *crl);
129296341Sdelphij    int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret,
130296341Sdelphij                       ASN1_INTEGER *ser, X509_NAME *issuer);
131296341Sdelphij    int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk);
132296341Sdelphij};
133