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
47
48
49
/* Copyright (c) Fortanix, Inc.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#![recursion_limit="256"]

pub extern crate yasna;
pub extern crate num_bigint;
extern crate bitflags;
extern crate b64_ct;
extern crate num_integer;
pub extern crate bit_vec;
#[macro_use]
extern crate lazy_static;
extern crate chrono;

#[macro_use]
pub mod derives;
pub mod algorithms;
pub mod cms;
pub mod oid;
pub mod types;
pub mod x509;
pub mod pkcs10;
pub mod pem;
pub mod cmpv2;
pub mod crmf;
pub mod rfc3281;
mod serialize;
mod deserialize;

pub use serialize::{DerWrite, ToDer};
pub use deserialize::{FromDer, FromBer};

pub use yasna::{ASN1Error, ASN1Result};

#[cfg(test)]
pub(crate) mod test {
    use super::*;
    use yasna::BERDecodable;
    use std::fmt::Debug;

    pub fn test_encode_decode<T: DerWrite + BERDecodable + Debug + PartialEq>(value: &T, expected_der: &[u8]) {
        assert_eq!(yasna::construct_der(|w| value.write(w)), expected_der);
        assert_eq!(&yasna::parse_der(expected_der, |r| T::decode_ber(r)).unwrap(), value);
    }
}