Merge branch 'for-linus' into for-next
[linux-2.6-block.git] / crypto / asymmetric_keys / x509_parser.h
CommitLineData
b4d0d230 1/* SPDX-License-Identifier: GPL-2.0-or-later */
c26fd69f
DH
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)
c26fd69f
DH
6 */
7
57be4a78 8#include <linux/time.h>
c26fd69f 9#include <crypto/public_key.h>
146aa8b1 10#include <keys/asymmetric-type.h>
c26fd69f
DH
11
12struct x509_certificate {
13 struct x509_certificate *next;
84aabd46 14 struct x509_certificate *signer; /* Certificate that signed this one */
c26fd69f 15 struct public_key *pub; /* Public key details */
77d0910d 16 struct public_key_signature *sig; /* Signature parameters */
c26fd69f
DH
17 char *issuer; /* Name of certificate issuer */
18 char *subject; /* Name of certificate subject */
b92e6570 19 struct asymmetric_key_id *id; /* Issuer + Serial number */
8dd60980 20 struct asymmetric_key_id *skid; /* Subject + subjectKeyId (optional) */
fd19a3d1
DH
21 time64_t valid_from;
22 time64_t valid_to;
c26fd69f 23 const void *tbs; /* Signed data */
b426beb6 24 unsigned tbs_size; /* Size of signed data */
4920a4a7 25 unsigned raw_sig_size; /* Size of signature */
b426beb6 26 const void *raw_sig; /* Signature data */
84aabd46
DH
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;
dd2f6c44
DH
33 unsigned raw_skid_size;
34 const void *raw_skid; /* Raw subjectKeyId in ASN.1 */
84aabd46
DH
35 unsigned index;
36 bool seen; /* Infinite recursion prevention */
37 bool verified;
6c2dc5ae 38 bool self_signed; /* T if self-signed (check unsupported_sig too) */
6c2dc5ae 39 bool unsupported_sig; /* T if signature uses unsupported crypto */
43652956 40 bool blacklisted;
c26fd69f
DH
41};
42
3cde3174
DH
43/*
44 * selftest.c
45 */
46#ifdef CONFIG_FIPS_SIGNATURE_SELFTEST
47extern int __init fips_signature_selftest(void);
48#else
49static inline int fips_signature_selftest(void) { return 0; }
50#endif
51
c26fd69f
DH
52/*
53 * x509_cert_parser.c
54 */
55extern void x509_free_certificate(struct x509_certificate *cert);
56extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
fd19a3d1
DH
57extern int x509_decode_time(time64_t *_t, size_t hdrlen,
58 unsigned char tag,
59 const unsigned char *value, size_t vlen);
b426beb6
DH
60
61/*
62 * x509_public_key.c
63 */
64extern int x509_get_sig_params(struct x509_certificate *cert);
6c2dc5ae 65extern int x509_check_for_self_signed(struct x509_certificate *cert);