Added secp256k1 keygen/sign, delete
This commit is contained in:
parent
8a73cfa938
commit
0717d04d07
|
@ -138,6 +138,19 @@ func CreateGetPubKeyCommand(keyID uint16) (*CommandMessage, error) {
|
||||||
return command, nil
|
return command, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateDeleteObjectCommand(objID uint16, objType uint8) (*CommandMessage, error) {
|
||||||
|
command := &CommandMessage{
|
||||||
|
CommandType: CommandTypeDeleteObject,
|
||||||
|
}
|
||||||
|
|
||||||
|
payload := bytes.NewBuffer([]byte{})
|
||||||
|
binary.Write(payload, binary.BigEndian, objID)
|
||||||
|
binary.Write(payload, binary.BigEndian, objType)
|
||||||
|
command.Data = payload.Bytes()
|
||||||
|
|
||||||
|
return command, nil
|
||||||
|
}
|
||||||
|
|
||||||
func CreateEchoCommand(data []byte) (*CommandMessage, error) {
|
func CreateEchoCommand(data []byte) (*CommandMessage, error) {
|
||||||
command := &CommandMessage{
|
command := &CommandMessage{
|
||||||
CommandType: CommandTypeEcho,
|
CommandType: CommandTypeEcho,
|
||||||
|
|
|
@ -86,12 +86,16 @@ func ParseResponse(data []byte) (Response, error) {
|
||||||
return parseCreateAsymmetricKeyResponse(payload)
|
return parseCreateAsymmetricKeyResponse(payload)
|
||||||
case CommandTypeSignDataEddsa:
|
case CommandTypeSignDataEddsa:
|
||||||
return parseSignDataEddsaResponse(payload)
|
return parseSignDataEddsaResponse(payload)
|
||||||
|
case CommandTypeSignDataEcdsa:
|
||||||
|
return parseSignDataEcdsaResponse(payload)
|
||||||
case CommandTypePutAsymmetric:
|
case CommandTypePutAsymmetric:
|
||||||
return parsePutAsymmetricKeyResponse(payload)
|
return parsePutAsymmetricKeyResponse(payload)
|
||||||
case CommandTypeCloseSession:
|
case CommandTypeCloseSession:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case CommandTypeGetPubKey:
|
case CommandTypeGetPubKey:
|
||||||
return parseGetPubKeyResponse(payload)
|
return parseGetPubKeyResponse(payload)
|
||||||
|
case CommandTypeDeleteObject:
|
||||||
|
return nil, nil
|
||||||
case CommandTypeEcho:
|
case CommandTypeEcho:
|
||||||
return parseEchoResponse(payload)
|
return parseEchoResponse(payload)
|
||||||
case ErrorResponseCode:
|
case ErrorResponseCode:
|
||||||
|
@ -153,6 +157,12 @@ func parseSignDataEddsaResponse(payload []byte) (Response, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSignDataEcdsaResponse(payload []byte) (Response, error) {
|
||||||
|
return &SignDataEcdsaResponse{
|
||||||
|
Signature: payload,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func parsePutAsymmetricKeyResponse(payload []byte) (Response, error) {
|
func parsePutAsymmetricKeyResponse(payload []byte) (Response, error) {
|
||||||
if len(payload) != 2 {
|
if len(payload) != 2 {
|
||||||
return nil, errors.New("invalid response payload length")
|
return nil, errors.New("invalid response payload length")
|
||||||
|
|
|
@ -146,4 +146,13 @@ const (
|
||||||
Domain14 uint16 = 0x2000
|
Domain14 uint16 = 0x2000
|
||||||
Domain15 uint16 = 0x4000
|
Domain15 uint16 = 0x4000
|
||||||
Domain16 uint16 = 0x8000
|
Domain16 uint16 = 0x8000
|
||||||
|
|
||||||
|
// object types
|
||||||
|
ObjectTypeOpaque uint8 = 0x01
|
||||||
|
ObjectTypeAuthenticationKey uint8 = 0x02
|
||||||
|
ObjectTypeAsymmetricKey uint8 = 0x03
|
||||||
|
ObjectTypeWrapKey uint8 = 0x04
|
||||||
|
ObjectTypeHmacKey uint8 = 0x05
|
||||||
|
ObjectTypeTemplate uint8 = 0x06
|
||||||
|
ObjectTypeOtpAeadKey uint8 = 0x07
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue