You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/yeaops/gopkcs11

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/yeaops/gopkcs11

v0.0.2
Source
Go
Version published
Created
Source

gopkcs11

A Go wrapper for PKCS#11 (Cryptoki) operations with HSM (Hardware Security Module) support.

Installation

go get github.com/yeaops/gopkcs11

Configuration Options

Slot Identification Methods

// By Slot ID (most common)
config := gopkcs11.NewConfigWithSlotID("/path/to/lib.so", 0, "pin")

// By Slot Index
config := gopkcs11.NewConfigWithSlotIndex("/path/to/lib.so", 0, "pin")

// By Token Label
config := gopkcs11.NewConfigWithTokenLabel("/path/to/lib.so", "MyToken", "pin")

// By Token Serial Number
config := gopkcs11.NewConfigWithTokenSerial("/path/to/lib.so", "123456", "pin")

Error Handling

if gopkcs11.IsKeyNotFoundError(err) {
    // Handle key not found
}
if gopkcs11.IsAuthenticationError(err) {
    // Handle authentication failure
}
if gopkcs11.IsSessionError(err) {
    // Handle session-related errors
}

Security Considerations

  • Private keys are marked as non-extractable and sensitive
  • All cryptographic operations are performed within the HSM
  • Session management includes proper cleanup and logout procedures
  • Error messages avoid leaking sensitive information

Testing

go test ./...

License

This project is licensed under the MIT License.

FAQs

Package last updated on 17 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts