Skip to content

Commit

Permalink
Implement signing of pre-hashed data (#3448)
Browse files Browse the repository at this point in the history
Transit backend sign and verify endpoints now support algorithm=none
  • Loading branch information
jvoorhis authored and jefferai committed Oct 11, 2017
1 parent 33e004f commit 333bd83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin/logical/transit/path_sign_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ derivation is enabled; currently only available with ed25519 keys.`,
Default: "sha2-256",
Description: `Hash algorithm to use (POST body parameter). Valid values are:
* none
* sha2-224
* sha2-256
* sha2-384
Expand Down Expand Up @@ -108,6 +109,7 @@ derivation is enabled; currently only available with ed25519 keys.`,
Default: "sha2-256",
Description: `Hash algorithm to use (POST body parameter). Valid values are:
* none
* sha2-224
* sha2-256
* sha2-384
Expand Down Expand Up @@ -166,7 +168,7 @@ func (b *backend) pathSignWrite(
}
}

if p.Type.HashSignatureInput() {
if p.Type.HashSignatureInput() && algorithm != "none" {
var hf hash.Hash
switch algorithm {
case "sha2-224":
Expand Down Expand Up @@ -259,7 +261,7 @@ func (b *backend) pathVerifyWrite(
}
}

if p.Type.HashSignatureInput() {
if p.Type.HashSignatureInput() && algorithm != "none" {
var hf hash.Hash
switch algorithm {
case "sha2-224":
Expand Down
4 changes: 4 additions & 0 deletions builtin/logical/transit/path_sign_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ func TestTransit_SignVerify_P256(t *testing.T) {
sig = signRequest(req, false, "")
verifyRequest(req, false, "", sig)

req.Data["algorithm"] = "none"
sig = signRequest(req, false, "")
verifyRequest(req, false, "", sig)

// Test 512 and save sig for later to ensure we can't validate once min
// decryption version is set
req.Data["algorithm"] = "sha2-512"
Expand Down
2 changes: 2 additions & 0 deletions website/source/api/secret/transit/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ supports signing.
own hash algorithm). This can also be specified as part of the URL.
Currently-supported algorithms are:

- `none`
- `sha2-224`
- `sha2-256`
- `sha2-384`
Expand Down Expand Up @@ -831,6 +832,7 @@ data.
- `algorithm` `(string: "sha2-256")` – Specifies the hash algorithm to use. This
can also be specified as part of the URL. Currently-supported algorithms are:

- `none`
- `sha2-224`
- `sha2-256`
- `sha2-384`
Expand Down

0 comments on commit 333bd83

Please sign in to comment.