commit
f66dd01301
|
@ -9,6 +9,7 @@ Currently the following commands are implemented:
|
||||||
* Reset
|
* Reset
|
||||||
* GenerateAsymmetricKey
|
* GenerateAsymmetricKey
|
||||||
* SignDataEddsa
|
* SignDataEddsa
|
||||||
|
* SignDataPkcs1
|
||||||
* PutAsymmetricKey
|
* PutAsymmetricKey
|
||||||
* GetPubKey
|
* GetPubKey
|
||||||
* DeriveEcdh
|
* DeriveEcdh
|
||||||
|
|
|
@ -94,6 +94,20 @@ func CreateSignDataEcdsaCommand(keyID uint16, data []byte) (*CommandMessage, err
|
||||||
return command, nil
|
return command, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateSignDataPkcs1Command(keyID uint16, data []byte) (*CommandMessage, error) {
|
||||||
|
command := &CommandMessage{
|
||||||
|
CommandType: CommandTypeSignDataPkcs1,
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
|
@ -62,6 +62,10 @@ type (
|
||||||
Signature []byte
|
Signature []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SignDataPkcs1Response struct {
|
||||||
|
Signature []byte
|
||||||
|
}
|
||||||
|
|
||||||
SignDataEcdsaResponse struct {
|
SignDataEcdsaResponse struct {
|
||||||
Signature []byte
|
Signature []byte
|
||||||
}
|
}
|
||||||
|
@ -127,6 +131,8 @@ func ParseResponse(data []byte) (Response, error) {
|
||||||
return parseSignDataEddsaResponse(payload)
|
return parseSignDataEddsaResponse(payload)
|
||||||
case CommandTypeSignDataEcdsa:
|
case CommandTypeSignDataEcdsa:
|
||||||
return parseSignDataEcdsaResponse(payload)
|
return parseSignDataEcdsaResponse(payload)
|
||||||
|
case CommandTypeSignDataPkcs1:
|
||||||
|
return parseSignDataPkcs1Response(payload)
|
||||||
case CommandTypePutAsymmetric:
|
case CommandTypePutAsymmetric:
|
||||||
return parsePutAsymmetricKeyResponse(payload)
|
return parsePutAsymmetricKeyResponse(payload)
|
||||||
case CommandTypeListObjects:
|
case CommandTypeListObjects:
|
||||||
|
@ -210,6 +216,12 @@ func parseSignDataEddsaResponse(payload []byte) (Response, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSignDataPkcs1Response(payload []byte) (Response, error) {
|
||||||
|
return &SignDataPkcs1Response{
|
||||||
|
Signature: payload,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func parseSignDataEcdsaResponse(payload []byte) (Response, error) {
|
func parseSignDataEcdsaResponse(payload []byte) (Response, error) {
|
||||||
return &SignDataEcdsaResponse{
|
return &SignDataEcdsaResponse{
|
||||||
Signature: payload,
|
Signature: payload,
|
||||||
|
|
Loading…
Reference in New Issue