Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hsmtool] generate cryptoki bindings are part of bazel build #26190

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 94 additions & 5 deletions sw/host/hsmtool/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,86 @@ load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc", "rust_library", "r

package(default_visibility = ["//visibility:public"])

alias(
name = "binding_srcs",
actual = "@crate_index//:cryptoki-sys-binding-srcs",
)

py_binary(
name = "pkcs11_consts",
srcs = ["scripts/pkcs11_consts.py"],
)

genrule(
name = "object_class",
srcs = [":binding_srcs"],
outs = ["object_class.rs"],
cmd = """
$(execpath :pkcs11_consts) \
--binding $(locations :binding_srcs) \
--serde --strum --conv_data CKO cryptoki::object::ObjectClass > $@
""",
tools = [
":pkcs11_consts",
],
)

genrule(
name = "key_type",
srcs = [":binding_srcs"],
outs = ["key_type.rs"],
cmd = """
$(execpath :pkcs11_consts) \
--binding $(locations :binding_srcs) \
--serde --strum --conv_data CKK cryptoki::object::KeyType > $@
""",
tools = [
":pkcs11_consts",
],
)

genrule(
name = "certificate_type",
srcs = [":binding_srcs"],
outs = ["certificate_type.rs"],
cmd = """
$(execpath :pkcs11_consts) \
--binding $(locations :binding_srcs) \
--serde --strum --conv_data CKC cryptoki::object::CertificateType > $@
""",
tools = [
":pkcs11_consts",
],
)

genrule(
name = "mechanism_type",
srcs = [":binding_srcs"],
outs = ["mechanism_type.rs"],
cmd = """
$(execpath :pkcs11_consts) \
--binding $(locations :binding_srcs) \
--serde --strum --conv_data CKM cryptoki::mechanism::MechanismType > $@
""",
tools = [
":pkcs11_consts",
],
)

genrule(
name = "attribute_type",
srcs = [":binding_srcs"],
outs = ["attribute_type.rs"],
cmd = """
$(execpath :pkcs11_consts) \
--binding $(locations :binding_srcs) \
--serde --strum CKA cryptoki::object::AttributeType > $@
""",
tools = [
":pkcs11_consts",
],
)

rust_library(
name = "hsmlib",
srcs = [
Expand Down Expand Up @@ -46,15 +126,10 @@ rust_library(
"src/profile.rs",
"src/spxef/mod.rs",
"src/util/attribute/attr.rs",
"src/util/attribute/attribute_type.rs",
"src/util/attribute/certificate_type.rs",
"src/util/attribute/data.rs",
"src/util/attribute/date.rs",
"src/util/attribute/error.rs",
"src/util/attribute/key_type.rs",
"src/util/attribute/mechanism_type.rs",
"src/util/attribute/mod.rs",
"src/util/attribute/object_class.rs",
"src/util/ef.rs",
"src/util/escape.rs",
"src/util/helper.rs",
Expand All @@ -64,7 +139,21 @@ rust_library(
"src/util/mod.rs",
"src/util/signing.rs",
],
compile_data = [
":attribute_type",
":certificate_type",
":key_type",
":mechanism_type",
":object_class",
],
crate_name = "hsmtool",
rustc_env = {
"ATTRIBUTE_TYPE": "$(location :attribute_type)",
"CERTIFICATE_TYPE": "$(location :certificate_type)",
"KEY_TYPE": "$(location :key_type)",
"MECHANISM_TYPE": "$(location :mechanism_type)",
"OBJECT_CLASS": "$(location :object_class)",
},
deps = [
"//sw/host/hsmtool/acorn",
"//sw/host/sphincsplus",
Expand Down
117 changes: 0 additions & 117 deletions sw/host/hsmtool/scripts/BUILD

This file was deleted.

Loading
Loading