1
// SPDX-License-Identifier: BSD-2-Clause
2
/*
3
 * dtls_rpk_client_server_test.rs - Tests for DTLS RPK clients+servers.
4
 * This file is part of the libcoap-rs crate, see the README and LICENSE files for
5
 * more information and terms of use.
6
 * Copyright © 2021-2024 The NAMIB Project Developers, all rights reserved.
7
 * See the README as well as the LICENSE file for more information.
8
 */
9

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

            
12
use crate::common::dtls::dtls_client_server_request_common;
13
use libcoap_rs::crypto::pki_rpk::{NonCertVerifying, PkiRpkContextBuilder};
14
use libcoap_rs::crypto::pki_rpk::{Rpk, RpkKeyDef};
15

            
16
mod common;
17

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

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