Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sign pkcs1 command #13

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Currently the following commands are implemented:
* Reset
* GenerateAsymmetricKey
* SignDataEddsa
* SignDataPkcs1
* PutAsymmetricKey
* GetPubKey
* DeriveEcdh
Expand Down
14 changes: 14 additions & 0 deletions commands/constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 12 additions & 0 deletions commands/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ type (
Signature []byte
}

SignDataPkcs1Response struct {
Signature []byte
}

SignDataEcdsaResponse struct {
Signature []byte
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down