Skip to content

Commit cbedf7a

Browse files
author
Willy Zhang
committed
build(rust): Bump cryptoki to 0.12.0
Updates the cryptoki crate to version 0.12.0 and cryptoki-sys to 0.5.0. Removes local patches that are now upstreamed and updates the library initialization code to match the new API. Signed-off-by: Willy Zhang <[email protected]>
1 parent b252d7e commit cbedf7a

File tree

6 files changed

+344
-132
lines changed

6 files changed

+344
-132
lines changed

MODULE.bazel

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,26 +145,19 @@ crate.annotation(
145145
)
146146
crate.annotation(
147147
crate = "cryptoki",
148-
patch_args = ["-p2"],
149-
patches = [
150-
"@lowrisc_opentitan//third_party/rust/patches:cryptoki-vendor-defined-mechanism-type.patch",
151-
"@lowrisc_opentitan//third_party/rust/patches:cryptoki-profile.patch",
152-
],
153148
repositories = ["crate_index"],
154149
)
155150
crate.annotation(
156151
additive_build_file_content = """
157152
filegroup(
158-
name = "binding_srcs",
159-
srcs = [
160-
"src/lib.rs",
161-
"src/bindings/x86_64-unknown-linux-gnu.rs",
162-
],
153+
name = "cryptoki-sys-binding-srcs",
154+
srcs = glob(["src/bindings/*.rs"]),
155+
visibility = ["//visibility:public"],
163156
)
164157
""",
165158
crate = "cryptoki-sys",
166159
extra_aliased_targets = {
167-
"cryptoki-sys-binding-srcs": "binding_srcs",
160+
"cryptoki-sys-binding-srcs": "cryptoki-sys-binding-srcs",
168161
},
169162
repositories = ["crate_index"],
170163
)

MODULE.bazel.lock

Lines changed: 208 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sw/host/hsmtool/scripts/pkcs11_consts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def get_names(self):
124124
raise Exception(
125125
'Expected objects to all be of uniform type',
126126
name, tp, m.group(2))
127-
names.append(name)
127+
if name not in names:
128+
names.append(name)
128129
return (names, tp)
129130

130131
@staticmethod

sw/host/hsmtool/src/module.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use anyhow::{Context, Result};
66
use cryptoki::context::CInitializeArgs;
7+
use cryptoki::context::CInitializeFlags;
78
use cryptoki::context::Pkcs11;
89
use cryptoki::session::Session;
910
use cryptoki::session::UserType;
@@ -53,7 +54,7 @@ pub struct Module {
5354
impl Module {
5455
pub fn initialize(module: &str) -> Result<Self> {
5556
let pkcs11 = Pkcs11::new(module)?;
56-
pkcs11.initialize(CInitializeArgs::OsThreads)?;
57+
pkcs11.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))?;
5758
Ok(Module {
5859
pkcs11,
5960
session: None,
@@ -99,7 +100,7 @@ impl Module {
99100
let slot = self.get_token(token)?;
100101
let session = self.pkcs11.open_rw_session(slot)?;
101102
if let Some(user) = user {
102-
let pin = pin.map(|x| AuthPin::new(x.to_owned()));
103+
let pin = pin.map(|x| AuthPin::new(x.to_owned().into()));
103104
session
104105
.login(user, pin.as_ref())
105106
.context("Failed HSM Login")?;

0 commit comments

Comments
 (0)