KEYS: Merge the type-specific data with the payload data
[linux-2.6-block.git] / crypto / asymmetric_keys / x509_parser.h
CommitLineData
c26fd69f
DH
1/* X.509 certificate parser internal definitions
2 *
3 * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
57be4a78 12#include <linux/time.h>
c26fd69f 13#include <crypto/public_key.h>
146aa8b1 14#include <keys/asymmetric-type.h>
c26fd69f
DH
15
16struct x509_certificate {
17 struct x509_certificate *next;
84aabd46 18 struct x509_certificate *signer; /* Certificate that signed this one */
c26fd69f 19 struct public_key *pub; /* Public key details */
84aabd46 20 struct public_key_signature sig; /* Signature parameters */
c26fd69f
DH
21 char *issuer; /* Name of certificate issuer */
22 char *subject; /* Name of certificate subject */
b92e6570 23 struct asymmetric_key_id *id; /* Issuer + Serial number */
8dd60980 24 struct asymmetric_key_id *skid; /* Subject + subjectKeyId (optional) */
b92e6570
DH
25 struct asymmetric_key_id *akid_id; /* CA AuthKeyId matching ->id (optional) */
26 struct asymmetric_key_id *akid_skid; /* CA AuthKeyId matching ->skid (optional) */
fd19a3d1
DH
27 time64_t valid_from;
28 time64_t valid_to;
c26fd69f 29 const void *tbs; /* Signed data */
b426beb6
DH
30 unsigned tbs_size; /* Size of signed data */
31 unsigned raw_sig_size; /* Size of sigature */
32 const void *raw_sig; /* Signature data */
84aabd46
DH
33 const void *raw_serial; /* Raw serial number in ASN.1 */
34 unsigned raw_serial_size;
35 unsigned raw_issuer_size;
36 const void *raw_issuer; /* Raw issuer name in ASN.1 */
37 const void *raw_subject; /* Raw subject name in ASN.1 */
38 unsigned raw_subject_size;
dd2f6c44
DH
39 unsigned raw_skid_size;
40 const void *raw_skid; /* Raw subjectKeyId in ASN.1 */
84aabd46
DH
41 unsigned index;
42 bool seen; /* Infinite recursion prevention */
43 bool verified;
44 bool trusted;
41559420 45 bool unsupported_crypto; /* T if can't be verified due to missing crypto */
c26fd69f
DH
46};
47
48/*
49 * x509_cert_parser.c
50 */
51extern void x509_free_certificate(struct x509_certificate *cert);
52extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
fd19a3d1
DH
53extern int x509_decode_time(time64_t *_t, size_t hdrlen,
54 unsigned char tag,
55 const unsigned char *value, size_t vlen);
b426beb6
DH
56
57/*
58 * x509_public_key.c
59 */
60extern int x509_get_sig_params(struct x509_certificate *cert);
61extern int x509_check_signature(const struct public_key *pub,
62 struct x509_certificate *cert);