Skip to content

Commit

Permalink
Add Parsec Basic Client
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás González <[email protected]>
  • Loading branch information
tgonzalezorlandoarm committed Feb 14, 2024
1 parent 9809d8d commit a52f51c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion parsec-openssl-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ categories = ["cryptography", "hardware-support"]
edition = "2021"

[dependencies]
lazy_static = "1.4.0"
log = "0.4"
parsec-client = { git = "https://github.com/parallaxsecond/parsec-client-rust", tag="0.16.0" }
parsec-openssl2 = { path = "../parsec-openssl2" }
openssl-errors = "0.2.0"
log = "0.4"
20 changes: 15 additions & 5 deletions parsec-openssl-provider/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
// Copyright 2023 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
use std::mem;
use std::sync::Mutex;

pub use parsec_openssl2::*;
pub use openssl_errors::*;
pub use parsec_openssl2::*;

mod provider;
use provider::*;

mod catch;
use catch::r#catch;

// The init function populates the dispatch table and returns a NULL pointer
// to the provider context. This needs to be changed when key management and
// crypto support is added to the provider.
use parsec_client::error::Result as ClientResult;
use parsec_client::BasicClient;

const PROJECT_NAME: &str = env!("CARGO_PKG_NAME");

lazy_static::lazy_static! {
static ref PARSEC_PROVIDER_CTX: Mutex<ClientResult<BasicClient>> = Mutex::new(BasicClient::new(Some(PROJECT_NAME.to_string())));
}

// The init function populates the dispatch table and returns a void pointer
// to the provider context (which contains the parsec basic client).
pub unsafe fn parsec_provider_provider_init(
_handle: *const OSSL_CORE_HANDLE,
_in_: *const OSSL_DISPATCH,
Expand Down Expand Up @@ -49,7 +58,8 @@ pub unsafe fn parsec_provider_provider_init(
});

*out = DISPATCH_TABLE.as_ptr();
*provctx = std::ptr::null_mut();
let ptr: *const Mutex<ClientResult<BasicClient>> = &*PARSEC_PROVIDER_CTX;
*provctx = ptr as VOID_PTR;

Ok(())
}
Expand Down

0 comments on commit a52f51c

Please sign in to comment.