Merge pull request #13 from terrbear/master

add sign pkcs1 command
This commit is contained in:
Hendrik Hofstadt 2021-03-31 08:41:21 +02:00 committed by GitHub
commit f66dd01301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -9,6 +9,7 @@ Currently the following commands are implemented:
* Reset
* GenerateAsymmetricKey
* SignDataEddsa
* SignDataPkcs1
* PutAsymmetricKey
* GetPubKey
* DeriveEcdh

View File

@ -94,6 +94,20 @@ func CreateSignDataEcdsaCommand(keyID uint16, data []byte) (*CommandMessage, err
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) {
if len(label) > LabelLength {
return nil, errors.New("label is too long")

View File

@ -62,6 +62,10 @@ type (
Signature []byte
}
SignDataPkcs1Response struct {
Signature []byte
}
SignDataEcdsaResponse struct {
Signature []byte
}
@ -127,6 +131,8 @@ func ParseResponse(data []byte) (Response, error) {
return parseSignDataEddsaResponse(payload)
case CommandTypeSignDataEcdsa:
return parseSignDataEcdsaResponse(payload)
case CommandTypeSignDataPkcs1:
return parseSignDataPkcs1Response(payload)
case CommandTypePutAsymmetric:
return parsePutAsymmetricKeyResponse(payload)
case CommandTypeListObjects:
@ -210,6 +216,12 @@ func parseSignDataEddsaResponse(payload []byte) (Response, error) {
}, nil
}
func parseSignDataPkcs1Response(payload []byte) (Response, error) {
return &SignDataPkcs1Response{
Signature: payload,
}, nil
}
func parseSignDataEcdsaResponse(payload []byte) (Response, error) {
return &SignDataEcdsaResponse{
Signature: payload,