1
// SPDX-License-Identifier: BSD-2-Clause
2
/*
3
 * Copyright © The libcoap-rs Contributors, all rights reserved.
4
 * This file is part of the libcoap-rs project, see the README file for
5
 * general information on this project and the NOTICE.md and LICENSE files
6
 * for information regarding copyright ownership and terms of use.
7
 *
8
 * tests/dtls_rpk_client_server_test.rs - Tests for DTLS RPK clients+servers.
9
 */
10

            
11
#![cfg(feature = "dtls-rpk")]
12

            
13
use libcoap_rs::crypto::pki_rpk::{NonCertVerifying, PkiRpkContextBuilder, Rpk, RpkKeyDef};
14

            
15
use crate::common::dtls::dtls_client_server_request_common;
16

            
17
mod common;
18

            
19
#[test]
20
2
pub fn dtls_pki_pem_memory_client_server_request() {
21
    // TODO Implement validator using https://docs.rs/spki/0.7.3/spki/struct.SubjectPublicKeyInfo.html#impl-Eq-for-SubjectPublicKeyInfo%3CParams,+Key%3E
22
    const PEM_CLIENT_PUBLIC_KEY: &str = include_str!("../resources/test-keys/client/client.pub.pem");
23
    const PEM_SERVER_PUBLIC_KEY: &str = include_str!("../resources/test-keys/server/server.pub.pem");
24
    const PEM_CLIENT_PRIVATE_KEY: &str = include_str!("../resources/test-keys/client/client.key.pem");
25
    const PEM_SERVER_PRIVATE_KEY: &str = include_str!("../resources/test-keys/server/server.key.pem");
26
2
    let client_key = RpkKeyDef::with_pem_memory(Vec::from(PEM_CLIENT_PUBLIC_KEY), Vec::from(PEM_CLIENT_PRIVATE_KEY));
27
2
    let server_key = RpkKeyDef::with_pem_memory(Vec::from(PEM_SERVER_PUBLIC_KEY), Vec::from(PEM_SERVER_PRIVATE_KEY));
28
2

            
29
4
    let ctx_configurator = |ctx: PkiRpkContextBuilder<'static, Rpk, NonCertVerifying>| ctx.build();
30
2
    dtls_client_server_request_common(client_key, server_key, ctx_configurator, ctx_configurator)
31
2
}