Thomas Gleixner | b4d0d23 | 2019-05-20 19:08:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 2 | /* X.509 certificate parser internal definitions |
| 3 | * |
| 4 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. |
| 5 | * Written by David Howells (dhowells@redhat.com) |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
David Howells | 57be4a7 | 2013-08-30 16:16:34 +0100 | [diff] [blame] | 8 | #include <linux/time.h> |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 9 | #include <crypto/public_key.h> |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 10 | #include <keys/asymmetric-type.h> |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 11 | |
| 12 | struct x509_certificate { |
| 13 | struct x509_certificate *next; |
David Howells | 84aabd4 | 2014-07-01 16:40:19 +0100 | [diff] [blame] | 14 | struct x509_certificate *signer; /* Certificate that signed this one */ |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 15 | struct public_key *pub; /* Public key details */ |
David Howells | 77d0910 | 2016-04-06 16:13:33 +0100 | [diff] [blame] | 16 | struct public_key_signature *sig; /* Signature parameters */ |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 17 | char *issuer; /* Name of certificate issuer */ |
| 18 | char *subject; /* Name of certificate subject */ |
David Howells | b92e657 | 2015-07-20 21:16:26 +0100 | [diff] [blame] | 19 | struct asymmetric_key_id *id; /* Issuer + Serial number */ |
Dmitry Kasatkin | 8dd6098 | 2014-10-06 16:52:12 +0100 | [diff] [blame] | 20 | struct asymmetric_key_id *skid; /* Subject + subjectKeyId (optional) */ |
David Howells | fd19a3d | 2015-07-29 16:58:32 +0100 | [diff] [blame] | 21 | time64_t valid_from; |
| 22 | time64_t valid_to; |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 23 | const void *tbs; /* Signed data */ |
David Howells | b426beb | 2013-08-30 16:18:02 +0100 | [diff] [blame] | 24 | unsigned tbs_size; /* Size of signed data */ |
| 25 | unsigned raw_sig_size; /* Size of sigature */ |
| 26 | const void *raw_sig; /* Signature data */ |
David Howells | 84aabd4 | 2014-07-01 16:40:19 +0100 | [diff] [blame] | 27 | const void *raw_serial; /* Raw serial number in ASN.1 */ |
| 28 | unsigned raw_serial_size; |
| 29 | unsigned raw_issuer_size; |
| 30 | const void *raw_issuer; /* Raw issuer name in ASN.1 */ |
| 31 | const void *raw_subject; /* Raw subject name in ASN.1 */ |
| 32 | unsigned raw_subject_size; |
David Howells | dd2f6c4 | 2014-10-03 16:17:02 +0100 | [diff] [blame] | 33 | unsigned raw_skid_size; |
| 34 | const void *raw_skid; /* Raw subjectKeyId in ASN.1 */ |
David Howells | 84aabd4 | 2014-07-01 16:40:19 +0100 | [diff] [blame] | 35 | unsigned index; |
| 36 | bool seen; /* Infinite recursion prevention */ |
| 37 | bool verified; |
David Howells | 6c2dc5a | 2016-04-06 16:13:34 +0100 | [diff] [blame] | 38 | bool self_signed; /* T if self-signed (check unsupported_sig too) */ |
| 39 | bool unsupported_key; /* T if key uses unsupported crypto */ |
| 40 | bool unsupported_sig; /* T if signature uses unsupported crypto */ |
David Howells | 4365295 | 2017-04-03 16:07:25 +0100 | [diff] [blame] | 41 | bool blacklisted; |
David Howells | c26fd69 | 2012-09-24 17:11:48 +0100 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | /* |
| 45 | * x509_cert_parser.c |
| 46 | */ |
| 47 | extern void x509_free_certificate(struct x509_certificate *cert); |
| 48 | extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen); |
David Howells | fd19a3d | 2015-07-29 16:58:32 +0100 | [diff] [blame] | 49 | extern int x509_decode_time(time64_t *_t, size_t hdrlen, |
| 50 | unsigned char tag, |
| 51 | const unsigned char *value, size_t vlen); |
David Howells | b426beb | 2013-08-30 16:18:02 +0100 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * x509_public_key.c |
| 55 | */ |
| 56 | extern int x509_get_sig_params(struct x509_certificate *cert); |
David Howells | 6c2dc5a | 2016-04-06 16:13:34 +0100 | [diff] [blame] | 57 | extern int x509_check_for_self_signed(struct x509_certificate *cert); |