Skip to content

Commit 822af1e

Browse files
jhshannon17jack-shannon-ripple
authored andcommitted
Add pub unsafe accessors for object/session handles and ObjectHandle new
Signed-off-by: Jack Shannon <[email protected]>
1 parent 3ac2766 commit 822af1e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cryptoki/src/object.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,23 @@ impl ObjectHandle {
10291029
ObjectHandle { handle }
10301030
}
10311031

1032+
/// Create a new object handle from a raw handle.
1033+
/// # Safety
1034+
/// Considered unsafe due to ability for client to arbitrarily create object handles.
1035+
pub unsafe fn new_from_raw(handle: CK_OBJECT_HANDLE) -> Self {
1036+
ObjectHandle { handle }
1037+
}
1038+
10321039
pub(crate) fn handle(&self) -> CK_OBJECT_HANDLE {
10331040
self.handle
10341041
}
1042+
1043+
/// Get the raw handle of the object.
1044+
/// # Safety
1045+
/// Considered unsafe because of pub access to the underlying handle type.
1046+
pub unsafe fn raw_handle(&self) -> CK_OBJECT_HANDLE {
1047+
self.handle
1048+
}
10351049
}
10361050

10371051
impl std::fmt::Display for ObjectHandle {

cryptoki/src/session/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ impl Session {
8080
self.handle
8181
}
8282

83+
/// Get the raw handle of the session.
84+
/// # Safety
85+
/// Considered unsafe because of pub access to the underlying handle type.
86+
pub unsafe fn raw_handle(&self) -> CK_SESSION_HANDLE {
87+
self.handle
88+
}
89+
8390
pub(crate) fn client(&self) -> &Pkcs11 {
8491
&self.client
8592
}

0 commit comments

Comments
 (0)