File: components.rs

package info (click to toggle)
rust-dsa 0.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 657 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use dsa::Components;
use pkcs8::{
    der::{Decode, Encode},
    Document,
};

const OPENSSL_PEM_COMPONENTS: &str = include_str!("pems/params.pem");

#[test]
fn decode_encode_openssl_components() {
    let (_, document) =
        Document::from_pem(OPENSSL_PEM_COMPONENTS).expect("Failed to parse components PEM");
    let raw_components = document.as_bytes();

    let components =
        Components::from_der(raw_components).expect("Failed to parse DER into component structure");

    let reencoded_components = components
        .to_der()
        .expect("Failed to encode components to DER");

    assert_eq!(raw_components, reencoded_components);
}