{"id":51121812,"url":"https://github.com/tegmentum/pkcs11-bridge","last_synced_at":"2026-06-25T03:30:32.348Z","repository":{"id":364080972,"uuid":"1255309770","full_name":"tegmentum/pkcs11-bridge","owner":"tegmentum","description":"Layer-3 component: bridges OpenSSL provider WIT to pkcs11:host backends. Translates EVP_DigestSign / X509_sign requests into CKM_* mechanisms with proper params.","archived":false,"fork":false,"pushed_at":"2026-06-11T14:04:01.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T16:06:58.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tegmentum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-31T17:09:41.000Z","updated_at":"2026-06-11T14:05:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tegmentum/pkcs11-bridge","commit_stats":null,"previous_names":["tegmentum/pkcs11-bridge"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tegmentum/pkcs11-bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fpkcs11-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fpkcs11-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fpkcs11-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fpkcs11-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tegmentum","download_url":"https://codeload.github.com/tegmentum/pkcs11-bridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fpkcs11-bridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34758773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-25T03:30:30.455Z","updated_at":"2026-06-25T03:30:32.343Z","avatar_url":"https://github.com/tegmentum.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"pkcs11-bridge\n=============\n\nLayer-3 backend of the openssl-provider-wit stack. Exposes a real\nPKCS#11 token through the narrow `tegmentum:key-backend` contract,\nso the same `simple-provider-adapter` that drives the stub key in\nPhase 3 can drive a SoftHSM2 / YubiHSM / Luna / CloudHSM key here.\n\n  simple-provider-adapter (Layer 2)\n    ↓ tegmentum:key-backend\n  pkcs11-bridge (this component, Layer 3)\n    ↓ pkcs11:host (slot-manager + session + object + crypto + util)\n  pkcs11-wasm-host  (Rust wasmtime adapter, ~/git/pkcs11-wasm-host)\n    ↓ libpkcs11.so  (libsofthsm2 / Yubico / Luna / ...)\n\nURI format (RFC 7512 subset)\n---------------------------\n\n  pkcs11:slot-id=0;object=my-tls-key;pin-value=1234\n\nSupported attributes: `slot-id`, `object` (CKA_LABEL), `id`\n(CKA_ID, may be percent-encoded), `pin-value`. Tolerated but\nignored: `token`, `manufacturer`, `model`, `library-version`,\n`library-manufacturer`, `library-description`, `serial`, `type`,\n`module-path`, `module-name`. The broader RFC 7512 surface\n(library version filters, `pin-source=`, etc.) lands in Phase 8\nwhen concrete deployments hit cases the simpler form misses.\n\n`slot-id` is required in Phase 4 -- token-label-only lookup needs\nan extra slot-enumeration pass that's pure boilerplate to add but\nnot yet wired.\n\nMechanism mapping\n-----------------\n\nThe adapter passes a typed `signature-mechanism` to the bridge;\nthis table translates it to a PKCS#11 `CKM_*`:\n\n  Ecdsa(Sha256)       -\u003e CKM_ECDSA_SHA256       (token hashes)\n  Ecdsa(Sha384)       -\u003e CKM_ECDSA_SHA384\n  Ecdsa(Sha512)       -\u003e CKM_ECDSA_SHA512\n  Ecdsa(Raw)          -\u003e CKM_ECDSA               (caller pre-hashed)\n  RsaPkcs1(Sha256)    -\u003e CKM_SHA256_RSA_PKCS    (token hashes)\n  RsaPkcs1(Sha384)    -\u003e CKM_SHA384_RSA_PKCS\n  RsaPkcs1(Sha512)    -\u003e CKM_SHA512_RSA_PKCS\n  RsaPkcs1(Raw)       -\u003e CKM_RSA_PKCS           (caller pre-wrapped DigestInfo)\n  RsaPss({d, m, s})   -\u003e CKM_SHA{256,384,512}_RSA_PKCS_PSS\n  Eddsa               -\u003e CKM_EDDSA\n  RsaRaw              -\u003e CKM_RSA_X_509\n\nCipher mechanisms (used for `key.decrypt`):\n\n  RsaPkcs1     -\u003e CKM_RSA_PKCS\n  RsaOaep(_)   -\u003e CKM_RSA_PKCS_OAEP             (params NOT yet marshalled)\n  RsaRaw       -\u003e CKM_RSA_X_509\n\nStatus\n------\n\n**Phase 4.5 complete (code + composition).** The bridge:\n\n  - Parses pkcs11: URIs (RFC 7512 subset).\n  - Opens a PKCS#11 session, logs in with the URI's pin-value.\n  - Resolves the URI to a private-key CK_OBJECT_HANDLE.\n  - `key.algorithm` returns Ec or Rsa derived from CKA_KEY_TYPE.\n  - `key.sign` translates the mech and calls C_SignInit + C_Sign\n    in one shot through `session.sign`.\n  - `key.public_key_info` finds the matching public-key object,\n    pulls CKA_EC_PARAMS + CKA_EC_POINT (or CKA_MODULUS +\n    CKA_PUBLIC_EXPONENT), and assembles SubjectPublicKeyInfo DER\n    by hand in src/spki.rs (no `der` / `spki` crate dep).\n  - `key.verify` / `key.decrypt` wired analogously.\n  - `key.derive` returns MechanismNotSupported (ECDH wiring is\n    Phase 8 work).\n\n  Built artifact: ~110 KB wasm. `wasm-tools validate` clean.\n\n  Composes cleanly with simple-provider-adapter (`wac plug`):\n\n    wac plug \\\n      ~/git/simple-provider-adapter/target/wasm32-wasip2/release/simple_provider_adapter.wasm \\\n      --plug target/wasm32-wasip2/release/pkcs11_bridge.wasm \\\n      -o adapter-with-pkcs11.wasm\n\n  The composed component exports the full openssl:provider-abi and\n  imports just the unsatisfied pkcs11:host interfaces (6 packages),\n  which a host like `~/git/pkcs11-wasm-host` provides through\n  `wasmtime::component::Linker::add_to_linker`.\n\n**Phase 4.6 (SoftHSM smoke) -- DEFERRED.** Requires:\n\n  - SoftHSM2 installed locally (`brew install softhsm`).\n  - An initialized token (use\n    `~/git/pkcs11-wasm-host/scripts/softhsm-setup.sh`).\n  - A wasmtime test harness that loads\n    `adapter-with-pkcs11.wasm`, satisfies the pkcs11:host imports\n    via `pkcs11-wasm-host`, calls `tegmentum:key-backend.key.sign`,\n    and verifies the returned signature against the token's known\n    SPKI via openssl-rs.\n\n  The bridge IS structurally complete -- the smoke is the\n  environment-setup-heavy verification step.\n\nPinned toolchain\n----------------\n\n`wit-bindgen 0.44`. Same caveats as `simple-provider-adapter`:\n- avoid identifiers like `sha2-256` (use `sha256`),\n- skip the `pkcs11:constants` WIT package (it uses `const`\n  declarations that 0.44 doesn't parse) -- the constants we need\n  are duplicated inline in `src/lib.rs::ck`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegmentum%2Fpkcs11-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftegmentum%2Fpkcs11-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegmentum%2Fpkcs11-bridge/lists"}