diff --git a/commands/constructors.go b/commands/constructors.go index 9716560..1d4b3d3 100644 --- a/commands/constructors.go +++ b/commands/constructors.go @@ -138,6 +138,19 @@ func CreateGetPubKeyCommand(keyID uint16) (*CommandMessage, error) { 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) { command := &CommandMessage{ CommandType: CommandTypeEcho, diff --git a/commands/response.go b/commands/response.go index f32c869..60ac2e3 100644 --- a/commands/response.go +++ b/commands/response.go @@ -86,12 +86,16 @@ func ParseResponse(data []byte) (Response, error) { return parseCreateAsymmetricKeyResponse(payload) case CommandTypeSignDataEddsa: return parseSignDataEddsaResponse(payload) + case CommandTypeSignDataEcdsa: + return parseSignDataEcdsaResponse(payload) case CommandTypePutAsymmetric: return parsePutAsymmetricKeyResponse(payload) case CommandTypeCloseSession: return nil, nil case CommandTypeGetPubKey: return parseGetPubKeyResponse(payload) + case CommandTypeDeleteObject: + return nil, nil case CommandTypeEcho: return parseEchoResponse(payload) case ErrorResponseCode: @@ -153,6 +157,12 @@ func parseSignDataEddsaResponse(payload []byte) (Response, error) { }, nil } +func parseSignDataEcdsaResponse(payload []byte) (Response, error) { + return &SignDataEcdsaResponse{ + Signature: payload, + }, nil +} + func parsePutAsymmetricKeyResponse(payload []byte) (Response, error) { if len(payload) != 2 { return nil, errors.New("invalid response payload length") diff --git a/commands/types.go b/commands/types.go index 2c3281b..d6da3e8 100644 --- a/commands/types.go +++ b/commands/types.go @@ -146,4 +146,13 @@ const ( Domain14 uint16 = 0x2000 Domain15 uint16 = 0x4000 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 )