You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ezekielnewren dac1fd2bba
add more algorithm constants (#24)
5 months ago
authkey Add ChangeAuthenticationKey command 3 years ago
commands add more algorithm constants (#24) 5 months ago
connector Connector: check len(values) to avoid nil pointer dereference (#21) 5 months ago
securechannel Add commands 2 years ago
.gitignore GitIgnore 2 years ago
LICENSE Prepare for GitHub publication 5 years ago Merge pull request #19 from rmeringe/add_get_device_info_command 11 months ago
go.mod Add commands 2 years ago
go.sum Add commands 2 years ago
manager.go Don't reset ping interval as failed commands do not recreate broken sessions 4 years ago


Yubihsm-go is a minimal implementation of the securechannel and connector protocol of the YubiHSM2.

It also implements a simple SessionManager which keeps connections alive and swaps them if the maximum number of messages is depleted.

Currently the following commands are implemented:

  • DeviceInfo
  • Reset
  • GenerateAsymmetricKey
  • SignDataEddsa
  • SignDataPkcs1
  • PutAsymmetricKey
  • GetPubKey
  • DeriveEcdh
  • Echo
  • ChangeAuthenticationKey
  • PutAuthenticationKey
  • GetOpaque
  • PutOpaque
  • SignAttestationCertificate
  • Authentication & Session related commands
  • GetPseudoRandom

Implementing new commands is really easy. Please consult commands/constructors.go and commands/response.go for reference.

Please submit a PR if you have implemented new commands or extended existing constructors.

Example of usage

c := connector.NewHTTPConnector("localhost:1234")
sm, err := yubihsm.NewSessionManager(c, 1, "password", 2)
if err != nil {

echoMessage := []byte("test")

command, err := commands.CreateEchoCommand(echoMessage)
if err != nil {

resp, err := sm.SendEncryptedCommand(command)
if err != nil {

parsedResp, matched := resp.(*commands.EchoResponse)
if !matched {
	panic("invalid response type")

if bytes.Equal(parsedResp.Data, echoMessage) {
	println("successfully echoed data")
} else {
	panic(errors.New("echoed message did not equal requested message"))