Merge tag 'mvebu-fixes-4.3-2' of git://git.infradead.org/linux-mvebu into fixes
[linux-drm-fsl-dcu.git] / crypto / asymmetric_keys / x509_parser.h
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
12 #include <linux/time.h>
13 #include <crypto/public_key.h>
14
15 struct x509_certificate {
16         struct x509_certificate *next;
17         struct x509_certificate *signer;        /* Certificate that signed this one */
18         struct public_key *pub;                 /* Public key details */
19         struct public_key_signature sig;        /* Signature parameters */
20         char            *issuer;                /* Name of certificate issuer */
21         char            *subject;               /* Name of certificate subject */
22         struct asymmetric_key_id *id;           /* Issuer + Serial number */
23         struct asymmetric_key_id *skid;         /* Subject + subjectKeyId (optional) */
24         struct asymmetric_key_id *akid_id;      /* CA AuthKeyId matching ->id (optional) */
25         struct asymmetric_key_id *akid_skid;    /* CA AuthKeyId matching ->skid (optional) */
26         time64_t        valid_from;
27         time64_t        valid_to;
28         const void      *tbs;                   /* Signed data */
29         unsigned        tbs_size;               /* Size of signed data */
30         unsigned        raw_sig_size;           /* Size of sigature */
31         const void      *raw_sig;               /* Signature data */
32         const void      *raw_serial;            /* Raw serial number in ASN.1 */
33         unsigned        raw_serial_size;
34         unsigned        raw_issuer_size;
35         const void      *raw_issuer;            /* Raw issuer name in ASN.1 */
36         const void      *raw_subject;           /* Raw subject name in ASN.1 */
37         unsigned        raw_subject_size;
38         unsigned        raw_skid_size;
39         const void      *raw_skid;              /* Raw subjectKeyId in ASN.1 */
40         unsigned        index;
41         bool            seen;                   /* Infinite recursion prevention */
42         bool            verified;
43         bool            trusted;
44         bool            unsupported_crypto;     /* T if can't be verified due to missing crypto */
45 };
46
47 /*
48  * x509_cert_parser.c
49  */
50 extern void x509_free_certificate(struct x509_certificate *cert);
51 extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
52 extern int x509_decode_time(time64_t *_t,  size_t hdrlen,
53                             unsigned char tag,
54                             const unsigned char *value, size_t vlen);
55
56 /*
57  * x509_public_key.c
58  */
59 extern int x509_get_sig_params(struct x509_certificate *cert);
60 extern int x509_check_signature(const struct public_key *pub,
61                                 struct x509_certificate *cert);