summaryrefslogtreecommitdiff
path: root/src/rust/cryptography-x509/src/ocsp_req.rs
blob: 1e096e71f1dab646f9c5f6ef3e9f6c65de6b7c15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// This file is dual licensed under the terms of the Apache License, Version
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
// for complete details.

use crate::{common, extensions, name};

#[derive(asn1::Asn1Read, asn1::Asn1Write)]
pub struct TBSRequest<'a> {
    #[explicit(0)]
    #[default(0)]
    pub version: u8,
    #[explicit(1)]
    pub requestor_name: Option<name::GeneralName<'a>>,
    pub request_list: common::Asn1ReadableOrWritable<
        'a,
        asn1::SequenceOf<'a, Request<'a>>,
        asn1::SequenceOfWriter<'a, Request<'a>>,
    >,
    #[explicit(2)]
    pub request_extensions: Option<extensions::Extensions<'a>>,
}

#[derive(asn1::Asn1Read, asn1::Asn1Write)]
pub struct Request<'a> {
    pub req_cert: CertID<'a>,
    #[explicit(0)]
    pub single_request_extensions: Option<extensions::Extensions<'a>>,
}

#[derive(asn1::Asn1Read, asn1::Asn1Write)]
pub struct CertID<'a> {
    pub hash_algorithm: common::AlgorithmIdentifier<'a>,
    pub issuer_name_hash: &'a [u8],
    pub issuer_key_hash: &'a [u8],
    pub serial_number: asn1::BigInt<'a>,
}

#[derive(asn1::Asn1Read, asn1::Asn1Write)]
pub struct OCSPRequest<'a> {
    pub tbs_request: TBSRequest<'a>,
    // Parsing out the full structure, which includes the entirety of a
    // certificate is more trouble than it's worth, since it's not in the
    // Python API.
    #[explicit(0)]
    pub optional_signature: Option<asn1::Sequence<'a>>,
}