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