Skip to content

Commit 1470a7b

Browse files
committed
Setup a NULL provider
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> # libparsec_openssl_provider_shared # name: Parsec OpenSSL Provider # version: 0.1.0 # status: active
1 parent da1917d commit 1470a7b

File tree

12 files changed

+386
-0
lines changed

12 files changed

+386
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target
2+
Cargo.lock
3+
.vscode
4+
*/Cargo.lock
5+
*/target

ci.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 Contributors to the Parsec project.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
set -ex
7+
8+
openssl version
9+
openssl list -providers -provider-path ./parsec-openssl-provider-shared/target/debug/ -provider libparsec_openssl_provider_shared

openssl-sys2/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "openssl-sys2"
3+
version = "0.1.0"
4+
license = "Apache-2.0"
5+
authors = ["Parsec maintainers"]
6+
edition = "2021"
7+

openssl-sys2/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2023 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#![allow(non_camel_case_types)]
5+
6+
mod types;
7+
pub use types::*;

openssl-sys2/src/types.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2023 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
pub const OSSL_PROV_PARAM_NAME: &[u8; 5] = b"name\0";
5+
pub const OSSL_PROV_PARAM_VERSION: &[u8; 8] = b"version\0";
6+
pub const OSSL_PROV_PARAM_BUILDINFO: &[u8; 10] = b"buildinfo\0";
7+
pub const OSSL_PROV_PARAM_STATUS: &[u8; 7] = b"status\0";
8+
pub const OSSL_PARAM_UTF8_PTR: u32 = 6;
9+
pub const OSSL_PARAM_INTEGER: u32 = 1;
10+
11+
pub const OSSL_FUNC_PROVIDER_TEARDOWN: i32 = 1024;
12+
pub const OSSL_FUNC_PROVIDER_GETTABLE_PARAMS: i32 = 1025;
13+
pub const OSSL_FUNC_PROVIDER_GET_PARAMS: i32 = 1026;
14+
pub const OSSL_FUNC_PROVIDER_QUERY_OPERATION: i32 = 1027;
15+
pub const OSSL_FUNC_PROVIDER_UNQUERY_OPERATION: i32 = 1028;
16+
pub const OSSL_FUNC_PROVIDER_GET_REASON_STRINGS: i32 = 1029;
17+
pub const OSSL_FUNC_PROVIDER_GET_CAPABILITIES: i32 = 1030;
18+
19+
#[repr(C)]
20+
#[derive(Debug, Copy, Clone)]
21+
pub struct ossl_core_handle_st {
22+
_unused: [u8; 0],
23+
}
24+
pub type OSSL_CORE_HANDLE = ossl_core_handle_st;
25+
26+
#[repr(C)]
27+
#[derive(Debug, Copy, Clone)]
28+
pub struct ossl_dispatch_st {
29+
pub function_id: ::std::os::raw::c_int,
30+
pub function: ::std::option::Option<fn()>,
31+
}
32+
33+
pub type OSSL_DISPATCH = ossl_dispatch_st;
34+
35+
#[repr(C)]
36+
#[derive(Debug, Copy, Clone)]
37+
pub struct ossl_param_st {
38+
pub key: *const ::std::os::raw::c_char,
39+
pub data_type: ::std::os::raw::c_uint,
40+
pub data: *mut ::std::os::raw::c_void,
41+
pub data_size: usize,
42+
pub return_size: usize,
43+
}
44+
45+
pub type OSSL_PARAM = ossl_param_st;
46+
47+
#[repr(C)]
48+
#[derive(Debug, Copy, Clone)]
49+
pub struct ossl_algorithm_st {
50+
pub algorithm_names: *const ::std::os::raw::c_char,
51+
pub property_definition: *const ::std::os::raw::c_char,
52+
pub implementation: *const OSSL_DISPATCH,
53+
pub algorithm_description: *const ::std::os::raw::c_char,
54+
}
55+
56+
pub type OSSL_ALGORITHM = ossl_algorithm_st;
57+
58+
extern "C" {
59+
pub fn OSSL_PARAM_locate(
60+
p: *mut OSSL_PARAM,
61+
key: *const ::std::os::raw::c_char,
62+
) -> *mut OSSL_PARAM;
63+
64+
pub fn OSSL_PARAM_set_utf8_ptr(
65+
p: *mut OSSL_PARAM,
66+
val: *const ::std::os::raw::c_char,
67+
) -> ::std::os::raw::c_int;
68+
69+
pub fn OSSL_PARAM_set_int(
70+
p: *mut OSSL_PARAM,
71+
val: ::std::os::raw::c_int,
72+
) -> ::std::os::raw::c_int;
73+
}

openssl2/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "openssl2"
3+
version = "0.1.0"
4+
license = "Apache-2.0"
5+
authors = ["Parsec maintainers"]
6+
edition = "2021"

openssl2/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2023 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
pub fn openssl_returns_0(result: std::os::raw::c_int) -> bool {
5+
if result == 0 {
6+
true
7+
} else {
8+
false
9+
}
10+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "parsec-openssl-provider-shared"
3+
version = "0.1.0"
4+
authors = ["Parsec Project Contributors"]
5+
description = "A parsec openssl provider dynamic library"
6+
license = "Apache-2.0"
7+
readme = "README.md"
8+
keywords = ["security", "service"]
9+
categories = ["cryptography", "hardware-support"]
10+
edition = "2021"
11+
12+
[lib]
13+
crate-type = ["cdylib"]
14+
15+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
16+
17+
[dependencies]
18+
openssl-sys = "0.9.98"
19+
openssl-sys2 = { path = "../openssl-sys2" }
20+
parsec-openssl-provider = { path ="../parsec-openssl-provider" }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2023 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use parsec_openssl_provider;
5+
6+
#[allow(non_upper_case_globals)]
7+
#[allow(non_snake_case)]
8+
#[allow(dead_code)]
9+
#[no_mangle]
10+
extern "C" fn OSSL_provider_init(
11+
handle: *const openssl_sys2::OSSL_CORE_HANDLE,
12+
in_: *const openssl_sys2::OSSL_DISPATCH,
13+
out: *mut *const openssl_sys2::OSSL_DISPATCH,
14+
provctx: *mut *mut std::os::raw::c_void,
15+
) -> ::std::os::raw::c_int {
16+
parsec_openssl_provider::parsec_provider_provider_init(handle, in_, out, provctx)
17+
}

parsec-openssl-provider/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "parsec-openssl-provider"
3+
version = "0.1.0"
4+
authors = ["Parsec Project Contributors"]
5+
description = "A parsec openssl provider static library"
6+
license = "Apache-2.0"
7+
readme = "README.md"
8+
keywords = ["security", "service"]
9+
categories = ["cryptography", "hardware-support"]
10+
edition = "2021"
11+
12+
[dependencies]
13+
openssl-sys = "0.9.98"
14+
openssl-sys2 = { path = "../openssl-sys2" }
15+
openssl2 = { path = "../openssl2" }

0 commit comments

Comments
 (0)