Skip to content

Add PKCS11 token support with tests and documentation #780

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

Conversation

rajanarahul93
Copy link

Add PKCS11 Token Support

Description

This PR adds support for PKCS11 tokens (HSMs) with secp256k1 curve support to HWI. The implementation allows users to use PKCS11-compliant hardware security modules as Bitcoin hardware wallets.

Changes Made

  1. Added PKCS11 client implementation in hwilib/devices/pkcs11.py
  2. Created comprehensive test suite in test/test_pkcs11.py
  3. Updated test runner in test/run_tests.py to include PKCS11 tests
  4. Added documentation in README.md
  5. Added Windows-specific prerequisites and installation instructions

Features

  • Support for PKCS11 tokens with secp256k1 curve
  • Cross-platform support (Windows, Linux, macOS)
  • Full test coverage
  • Integration with existing test framework
  • Documentation and usage examples

Testing

To run the tests:

python test/run_tests.py

Usage

  1. Set environment variables:
# Windows
$env:PKCS11_LIB_PATH = "C:\path\to\your\pkcs11\library.dll"
$env:PKCS11_TOKEN_LABEL = "YourTokenLabel"

# Unix-like
export PKCS11_LIB_PATH=/path/to/your/pkcs11/library.so
export PKCS11_TOKEN_LABEL=YourTokenLabel
  1. Use with HWI:
hwi --device-type pkcs11 --path /path/to/library.so getmasterxpub

Dependencies

  • python-pkcs11>=0.7.0
  • OpenSSL development libraries
  • Visual Studio Build Tools (Windows)

Related Issues

Closes #774

@rajanarahul93 rajanarahul93 closed this by deleting the head repository May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkcs11 token support
1 participant