Skip to content

Commit 4778ce7

Browse files
committed
x509-ext: add AuthorityKeyIdentifier
Signed-off-by: Nathaniel McCallum <[email protected]>
1 parent 85599ae commit 4778ce7

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

x509-ext/src/pkix/authkeyid.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use super::name::GeneralNames;
2+
use crate::Typed;
3+
4+
use der::asn1::{ObjectIdentifier, UIntBytes};
5+
use der::Sequence;
6+
7+
/// Authority key identifier extension as defined in [RFC 5280 Section 4.2.1.1].
8+
///
9+
/// ```text
10+
/// AuthorityKeyIdentifier ::= SEQUENCE {
11+
/// keyIdentifier [0] KeyIdentifier OPTIONAL,
12+
/// authorityCertIssuer [1] GeneralNames OPTIONAL,
13+
/// authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL
14+
/// }
15+
///
16+
/// KeyIdentifier ::= OCTET STRING
17+
/// ```
18+
///
19+
/// [RFC 5280 Section 4.2.1.1]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.1
20+
#[derive(Clone, Debug, Eq, PartialEq, Sequence)]
21+
pub struct AuthorityKeyIdentifier<'a> {
22+
/// keyIdentifier
23+
#[asn1(
24+
context_specific = "0",
25+
optional = "true",
26+
tag_mode = "IMPLICIT",
27+
type = "OCTET STRING"
28+
)]
29+
pub key_identifier: Option<&'a [u8]>,
30+
31+
/// authorityCertIssuer
32+
#[asn1(context_specific = "1", optional = "true", tag_mode = "IMPLICIT")]
33+
pub authority_cert_issuer: Option<GeneralNames<'a>>,
34+
35+
/// authorityCertSerialNumber
36+
#[asn1(context_specific = "2", optional = "true", tag_mode = "IMPLICIT")]
37+
pub authority_cert_serial_number: Option<UIntBytes<'a>>,
38+
}
39+
40+
impl Typed for AuthorityKeyIdentifier<'_> {
41+
const OID: ObjectIdentifier = ObjectIdentifier::new("2.5.29.35");
42+
}

x509-ext/src/pkix/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
//!
55
//! [RFC 5280]: https://datatracker.ietf.org/doc/html/rfc5280
66
7+
mod authkeyid;
8+
79
pub mod name;
10+
11+
pub use authkeyid::AuthorityKeyIdentifier;

0 commit comments

Comments
 (0)