-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Arthur Gautier <[email protected]>
- Loading branch information
Showing
7 changed files
with
88 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,54 @@ | ||
// Copyright 2023 Contributors to the Parsec project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use cryptoki::{ | ||
error::Result, | ||
mechanism::Mechanism, | ||
object::{Attribute, AttributeType, ObjectHandle}, | ||
session::Session, | ||
}; | ||
|
||
pub mod ecdsa; | ||
pub mod rsa; | ||
|
||
pub trait SessionLike { | ||
fn find_objects(&self, template: &[Attribute]) -> Result<Vec<ObjectHandle>>; | ||
fn get_attributes( | ||
&self, | ||
object: ObjectHandle, | ||
attributes: &[AttributeType], | ||
) -> Result<Vec<Attribute>>; | ||
fn sign(&self, mechanism: &Mechanism, key: ObjectHandle, data: &[u8]) -> Result<Vec<u8>>; | ||
} | ||
|
||
impl SessionLike for Session { | ||
fn find_objects(&self, template: &[Attribute]) -> Result<Vec<ObjectHandle>> { | ||
Session::find_objects(self, template) | ||
} | ||
fn get_attributes( | ||
&self, | ||
object: ObjectHandle, | ||
attributes: &[AttributeType], | ||
) -> Result<Vec<Attribute>> { | ||
Session::get_attributes(self, object, attributes) | ||
} | ||
fn sign(&self, mechanism: &Mechanism, key: ObjectHandle, data: &[u8]) -> Result<Vec<u8>> { | ||
Session::sign(self, mechanism, key, data) | ||
} | ||
} | ||
|
||
impl<'s> SessionLike for &'s Session { | ||
fn find_objects(&self, template: &[Attribute]) -> Result<Vec<ObjectHandle>> { | ||
Session::find_objects(self, template) | ||
} | ||
fn get_attributes( | ||
&self, | ||
object: ObjectHandle, | ||
attributes: &[AttributeType], | ||
) -> Result<Vec<Attribute>> { | ||
Session::get_attributes(self, object, attributes) | ||
} | ||
fn sign(&self, mechanism: &Mechanism, key: ObjectHandle, data: &[u8]) -> Result<Vec<u8>> { | ||
Session::sign(self, mechanism, key, data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters