blob: 1b76f207c1f3aeb3f8a5ade16979675aecd1c397 [file] [log] [blame]
David Howellsc26fd692012-09-24 17:11:48 +01001/* 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
David Howells57be4a72013-08-30 16:16:34 +010012#include <linux/time.h>
David Howellsc26fd692012-09-24 17:11:48 +010013#include <crypto/public_key.h>
14
15struct x509_certificate {
16 struct x509_certificate *next;
David Howells84aabd42014-07-01 16:40:19 +010017 struct x509_certificate *signer; /* Certificate that signed this one */
David Howellsc26fd692012-09-24 17:11:48 +010018 struct public_key *pub; /* Public key details */
David Howells84aabd42014-07-01 16:40:19 +010019 struct public_key_signature sig; /* Signature parameters */
David Howellsc26fd692012-09-24 17:11:48 +010020 char *issuer; /* Name of certificate issuer */
21 char *subject; /* Name of certificate subject */
22 char *fingerprint; /* Key fingerprint as hex */
23 char *authority; /* Authority key fingerprint as hex */
David Howellsa5752d12012-10-02 14:36:16 +010024 struct tm valid_from;
25 struct tm valid_to;
David Howellsc26fd692012-09-24 17:11:48 +010026 const void *tbs; /* Signed data */
David Howellsb426beb2013-08-30 16:18:02 +010027 unsigned tbs_size; /* Size of signed data */
28 unsigned raw_sig_size; /* Size of sigature */
29 const void *raw_sig; /* Signature data */
David Howells84aabd42014-07-01 16:40:19 +010030 const void *raw_serial; /* Raw serial number in ASN.1 */
31 unsigned raw_serial_size;
32 unsigned raw_issuer_size;
33 const void *raw_issuer; /* Raw issuer name in ASN.1 */
34 const void *raw_subject; /* Raw subject name in ASN.1 */
35 unsigned raw_subject_size;
36 unsigned index;
37 bool seen; /* Infinite recursion prevention */
38 bool verified;
39 bool trusted;
David Howellsc26fd692012-09-24 17:11:48 +010040};
41
42/*
43 * x509_cert_parser.c
44 */
45extern void x509_free_certificate(struct x509_certificate *cert);
46extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
David Howellsb426beb2013-08-30 16:18:02 +010047
48/*
49 * x509_public_key.c
50 */
51extern int x509_get_sig_params(struct x509_certificate *cert);
52extern int x509_check_signature(const struct public_key *pub,
53 struct x509_certificate *cert);