Skip to content

Commit

Permalink
Provide support for shared library
Browse files Browse the repository at this point in the history
This commit adds the required wrapper to the static library to
enable dynamic loading of the provider. The build now
generates a shared library "libparsec_openssl_provider_shared.so"
which has the required symbols that enables openssl to
dynamically load the provider.

Signed-off-by: Gowtham Suresh Kumar <[email protected]>
  • Loading branch information
gowthamsk-arm committed Jan 16, 2024
1 parent 9d20d57 commit 2aec6a4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions parsec-openssl-provider-shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "parsec-openssl-provider-shared"
version = "0.1.0"
authors = ["Parsec Project Contributors"]
description = "A parsec openssl provider dynamic library"
license = "Apache-2.0"
readme = "README.md"
keywords = ["security", "service"]
categories = ["cryptography", "hardware-support"]
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
openssl-sys = "0.9.98"
openssl-sys2 = { path = "../openssl-sys2" }
parsec-openssl-provider = { path ="../parsec-openssl-provider" }
19 changes: 19 additions & 0 deletions parsec-openssl-provider-shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2023 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0

use parsec_openssl_provider;

#[allow(non_upper_case_globals)]
#[allow(non_snake_case)]
#[allow(dead_code)]
#[no_mangle]
// The function name needs to be unique for dynamic libraries as the openssl core
// looks for OSSL_provider_init symbol while loading the provider.
extern "C" fn OSSL_provider_init(
handle: *const openssl_sys2::OSSL_CORE_HANDLE,
in_: *const openssl_sys2::OSSL_DISPATCH,
out: *mut *const openssl_sys2::OSSL_DISPATCH,
provctx: *mut *mut std::os::raw::c_void,
) -> ::std::os::raw::c_int {
parsec_openssl_provider::parsec_provider_provider_init(handle, in_, out, provctx)
}

0 comments on commit 2aec6a4

Please sign in to comment.