| 1 |
/* cert.h - Internal definitions for cert.c |
| 2 |
* Copyright (C) 2001, 2012 g10 Code GmbH |
| 3 |
* |
| 4 |
* This file is part of KSBA. |
| 5 |
* |
| 6 |
* KSBA is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of either |
| 8 |
* |
| 9 |
* - the GNU Lesser General Public License as published by the Free |
| 10 |
* Software Foundation; either version 3 of the License, or (at |
| 11 |
* your option) any later version. |
| 12 |
* |
| 13 |
* or |
| 14 |
* |
| 15 |
* - the GNU General Public License as published by the Free |
| 16 |
* Software Foundation; either version 2 of the License, or (at |
| 17 |
* your option) any later version. |
| 18 |
* |
| 19 |
* or both in parallel, as here. |
| 20 |
* |
| 21 |
* KSBA is distributed in the hope that it will be useful, but WITHOUT |
| 22 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 23 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 24 |
* License for more details. |
| 25 |
* |
| 26 |
* You should have received a copies of the GNU General Public License |
| 27 |
* and the GNU Lesser General Public License along with this program; |
| 28 |
* if not, see <http://www.gnu.org/licenses/>. |
| 29 |
*/ |
| 30 |
|
| 31 |
#ifndef CERT_H |
| 32 |
#define CERT_H 1 |
| 33 |
|
| 34 |
#include "asn1-func.h" |
| 35 |
|
| 36 |
/* An object to keep parsed information about an extension. */ |
| 37 |
struct cert_extn_info |
| 38 |
{ |
| 39 |
char *oid; |
| 40 |
int crit; |
| 41 |
int off, len; |
| 42 |
}; |
| 43 |
|
| 44 |
|
| 45 |
/* An object to store user supplied data to be associated with a |
| 46 |
certificates. This is implemented as a linked list with the |
| 47 |
constrained that a given key may only occur once. */ |
| 48 |
struct cert_user_data |
| 49 |
{ |
| 50 |
struct cert_user_data *next; /* Link to next item. */ |
| 51 |
|
| 52 |
/* The length of the data store at DATA. */ |
| 53 |
size_t datalen; |
| 54 |
|
| 55 |
/* The stored data. This is either malloced storage or points to |
| 56 |
DATABUF below. If it is NULL, no data is actually stored under |
| 57 |
the key. */ |
| 58 |
void *data; |
| 59 |
|
| 60 |
/* Often we need to store only a few bytes as data. By providing a |
| 61 |
fixed buffer we are able to avoid an extra malloc in this case. */ |
| 62 |
char databuf[sizeof (int)]; |
| 63 |
|
| 64 |
/* The key used to store the data object. Dynamically allocated at |
| 65 |
object creation time. */ |
| 66 |
char key[1]; |
| 67 |
}; |
| 68 |
|
| 69 |
|
| 70 |
/* The internal certificate object. */ |
| 71 |
struct ksba_cert_s |
| 72 |
{ |
| 73 |
/* Certificate objects often play a central role and applications |
| 74 |
might want to associate other data with the certificate to avoid |
| 75 |
wrapping the certificate object into an own object. This UDATA |
| 76 |
linked list provides the means to do that. It gets accessed by |
| 77 |
ksba_cert_set_user_data and ksba_cert_get_user_data. */ |
| 78 |
struct cert_user_data *udata; |
| 79 |
|
| 80 |
/* This object has been initialized with an actual certificate. |
| 81 |
Note that UDATA may be used even without an initialized |
| 82 |
certificate. */ |
| 83 |
int initialized; |
| 84 |
|
| 85 |
/* Because we often need to pass certificate objects to other |
| 86 |
functions, we use reference counting to keep resource overhead |
| 87 |
low. Note, that this object usually gets only read and not |
| 88 |
modified. */ |
| 89 |
int ref_count; |
| 90 |
|
| 91 |
ksba_asn_tree_t asn_tree; |
| 92 |
AsnNode root; /* Root of the tree with the values */ |
| 93 |
|
| 94 |
unsigned char *image; |
| 95 |
size_t imagelen; |
| 96 |
|
| 97 |
gpg_error_t last_error; |
| 98 |
struct { |
| 99 |
char *digest_algo; |
| 100 |
int extns_valid; |
| 101 |
int n_extns; |
| 102 |
struct cert_extn_info *extns; |
| 103 |
} cache; |
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
/*** Internal functions ***/ |
| 108 |
|
| 109 |
int _ksba_cert_cmp (ksba_cert_t a, ksba_cert_t b); |
| 110 |
|
| 111 |
gpg_error_t _ksba_cert_get_serial_ptr (ksba_cert_t cert, |
| 112 |
unsigned char const **ptr, |
| 113 |
size_t *length); |
| 114 |
gpg_error_t _ksba_cert_get_issuer_dn_ptr (ksba_cert_t cert, |
| 115 |
unsigned char const **ptr, |
| 116 |
size_t *length); |
| 117 |
gpg_error_t _ksba_cert_get_subject_dn_ptr (ksba_cert_t cert, |
| 118 |
unsigned char const **ptr, |
| 119 |
size_t *length); |
| 120 |
gpg_error_t _ksba_cert_get_public_key_ptr (ksba_cert_t cert, |
| 121 |
unsigned char const **ptr, |
| 122 |
size_t *length); |
| 123 |
|
| 124 |
|
| 125 |
#endif /*CERT_H*/ |