{"id":20238471,"url":"https://github.com/smallstep/pkcs11-key-wrap","last_synced_at":"2025-06-19T03:34:50.876Z","repository":{"id":57707159,"uuid":"434025810","full_name":"smallstep/pkcs11-key-wrap","owner":"smallstep","description":"🔐 Wrap keys from HSM using CKM_RSA_AES_KEY_WRAP step by step","archived":false,"fork":false,"pushed_at":"2021-12-10T09:41:00.000Z","size":32,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-10T19:57:12.455Z","etag":null,"topics":["cloudhsm","hsm","pkcs11","wrap"],"latest_commit_sha":null,"homepage":"","language":"Go","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/smallstep.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}},"created_at":"2021-12-02T00:06:21.000Z","updated_at":"2024-06-17T10:13:08.000Z","dependencies_parsed_at":"2022-09-26T21:20:38.435Z","dependency_job_id":null,"html_url":"https://github.com/smallstep/pkcs11-key-wrap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/smallstep/pkcs11-key-wrap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallstep%2Fpkcs11-key-wrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallstep%2Fpkcs11-key-wrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallstep%2Fpkcs11-key-wrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallstep%2Fpkcs11-key-wrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallstep","download_url":"https://codeload.github.com/smallstep/pkcs11-key-wrap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallstep%2Fpkcs11-key-wrap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260681005,"owners_count":23045827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cloudhsm","hsm","pkcs11","wrap"],"created_at":"2024-11-14T08:34:18.972Z","updated_at":"2025-06-19T03:34:45.862Z","avatar_url":"https://github.com/smallstep.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔐 pkcs11-key-wrap\n\nWrap keys from HSM using CKM_RSA_AES_KEY_WRAP step by step.\n\nThis tool can be used for example for exporting keys from Amazon's CloudHSM and\nimporting it to Google's KMS or Microsoft Azure's Key Vault.\n\n## Install\n\ngo install github.com/smallstep/pkcs11-key-wrap\n\n## Usage\n\nFirst we need to create an RSA public wrapping key, in our example this is going\nto be `rsa.pub`. Then we need to get the object id or the label of the key that\nwe want to wrap, `1000` or `my-key` in the following example. Finally run the\nwrapping tool like:\n\n```sh\npkcs11-key-wrap --pin xxxx --id 1000 --wrapping-key rsa.pub \u003e wrapped.key\n# OR\npkcs11-key-wrap --pin xxxx --label my-key --wrapping-key rsa.pub \u003e wrapped.key\n```\n\nWithout the `--module` flag will try to load the softhsm2 module, from\n`/usr/lib/softhsm/libsofthsm2.so` in a Linux environment and from\n`/usr/local/lib/softhsm/libsofthsm2.so` in macOS.\n\nIf Amazon CloudHSM is used the flag `--cloudhsm` is required because the\nstandard `CKM_AES_KEY_WRAP_PAD` mechanism should be replaced by the custom\n`CKM_CLOUDHSM_AES_KEY_WRAP_ZERO_PAD`. The usage in this case will be like:\n\n```sh\npkcs11-key-wrap --module /opt/cloudhsm/lib/libcloudhsm_pkcs11.so --cloudhsm \\\n    --pin user:password --id 1000 --wrapping-key rsa.pub \u003e wrapped.key\n# OR\npkcs11-key-wrap --module /opt/cloudhsm/lib/libcloudhsm_pkcs11.so --cloudhsm \\\n    --pin user:password --label my-key --wrapping-key rsa.pub \u003e wrapped.key\n```\n\n## CloudHSM troubleshooting\n\nIf you get an error running pkcs11-key-wrap on CloudHSM, the best way to know\nwhat is going is to look at their logs. To retrieve them just run:\n\n```sh\n/opt/cloudhsm/bin/pkcs11_info\n```\n\nThat command with place a file named `pkcs11-data.tar.gz` on `/tmp`. To look at\nthe actual logs run:\n\n```sh\ncd /tmp\ntar xzvf pkcs11-data.tar.gz\nless pkcs11-data/cloudhsm-pkcs11.log.*\n```\n\nA common error if you have just one CloudHSM is to get this error:\n\n```\nKey \u003chandle#\u003e does not meet the availability requirements - The key must be available on at least 2 HSMs before being used.\n```\n\nTo remove that requirement we can run:\n\n```sh\nsudo /opt/cloudhsm/bin/configure-pkcs11 --disable-key-availability-check\n```\n\nBut the keys might be re-created or imported, Amazon's `key_mgmt_util` might be\nuseful for these situations as they can wrap a key using `wrapKey` or\n`exportPrivateKey` commands.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallstep%2Fpkcs11-key-wrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallstep%2Fpkcs11-key-wrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallstep%2Fpkcs11-key-wrap/lists"}