Added secp256k1 support
This commit is contained in:
parent
2f4bdbb679
commit
8a73cfa938
|
@ -77,6 +77,20 @@ func CreateSignDataEddsaCommand(keyID uint16, data []byte) (*CommandMessage, err
|
||||||
return command, nil
|
return command, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateSignDataEcdsaCommand(keyID uint16, data []byte) (*CommandMessage, error) {
|
||||||
|
command := &CommandMessage{
|
||||||
|
CommandType: CommandTypeSignDataEcdsa,
|
||||||
|
}
|
||||||
|
|
||||||
|
payload := bytes.NewBuffer([]byte{})
|
||||||
|
binary.Write(payload, binary.BigEndian, keyID)
|
||||||
|
payload.Write(data)
|
||||||
|
|
||||||
|
command.Data = payload.Bytes()
|
||||||
|
|
||||||
|
return command, nil
|
||||||
|
}
|
||||||
|
|
||||||
func CreatePutAsymmetricKeyCommand(keyID uint16, label []byte, domains uint16, capabilities uint64, algorithm Algorithm, keyPart1 []byte, keyPart2 []byte) (*CommandMessage, error) {
|
func CreatePutAsymmetricKeyCommand(keyID uint16, label []byte, domains uint16, capabilities uint64, algorithm Algorithm, keyPart1 []byte, keyPart2 []byte) (*CommandMessage, error) {
|
||||||
if len(label) > LabelLength {
|
if len(label) > LabelLength {
|
||||||
return nil, errors.New("label is too long")
|
return nil, errors.New("label is too long")
|
||||||
|
|
|
@ -39,6 +39,10 @@ type (
|
||||||
Signature []byte
|
Signature []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SignDataEcdsaResponse struct {
|
||||||
|
Signature []byte
|
||||||
|
}
|
||||||
|
|
||||||
GetPubKeyResponse struct {
|
GetPubKeyResponse struct {
|
||||||
Algorithm Algorithm
|
Algorithm Algorithm
|
||||||
// KeyData can contain different formats depending on the algorithm according to the YubiHSM2 documentation.
|
// KeyData can contain different formats depending on the algorithm according to the YubiHSM2 documentation.
|
||||||
|
|
|
@ -78,7 +78,8 @@ const (
|
||||||
ErrorCodeCommandUnexecuted ErrorCode = 0xff
|
ErrorCodeCommandUnexecuted ErrorCode = 0xff
|
||||||
|
|
||||||
// Algorithms
|
// Algorithms
|
||||||
AlgorighmED25519 Algorithm = 46
|
AlgorithmSecp256k1 Algorithm = 15
|
||||||
|
AlgorighmED25519 Algorithm = 46
|
||||||
|
|
||||||
// Capabilities
|
// Capabilities
|
||||||
CapabilityGetOpaque uint64 = 0x0000000000000001
|
CapabilityGetOpaque uint64 = 0x0000000000000001
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package connector
|
package connector
|
||||||
|
|
||||||
import "github.com/certusone/yubihsm-go/commands"
|
import "github.com/loomnetwork/yubihsm-go/commands"
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Connector implements a simple request interface with a YubiHSM2
|
// Connector implements a simple request interface with a YubiHSM2
|
||||||
|
|
|
@ -3,10 +3,11 @@ package connector
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/certusone/yubihsm-go/commands"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/loomnetwork/yubihsm-go/commands"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
@ -3,11 +3,12 @@ package yubihsm
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/certusone/yubihsm-go/commands"
|
|
||||||
"github.com/certusone/yubihsm-go/connector"
|
|
||||||
"github.com/certusone/yubihsm-go/securechannel"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/loomnetwork/yubihsm-go/commands"
|
||||||
|
"github.com/loomnetwork/yubihsm-go/connector"
|
||||||
|
"github.com/loomnetwork/yubihsm-go/securechannel"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
@ -7,10 +7,11 @@ import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/certusone/yubihsm-go/commands"
|
|
||||||
"github.com/certusone/yubihsm-go/connector"
|
|
||||||
"github.com/enceve/crypto/cmac"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/enceve/crypto/cmac"
|
||||||
|
"github.com/loomnetwork/yubihsm-go/commands"
|
||||||
|
"github.com/loomnetwork/yubihsm-go/connector"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
Loading…
Reference in New Issue