-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement JWS-compatible signature marshaling (#6077)
This currently only applies to ECDSA signatures, and is a toggleable option.
- Loading branch information
Showing
6 changed files
with
232 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package keysutil | ||
|
||
import ( | ||
"crypto/sha256" | ||
"crypto/sha512" | ||
"hash" | ||
) | ||
|
||
type HashType uint32 | ||
|
||
const ( | ||
_ = iota | ||
HashTypeSHA2224 HashType = iota | ||
HashTypeSHA2256 | ||
HashTypeSHA2384 | ||
HashTypeSHA2512 | ||
) | ||
|
||
type MarshalingType uint32 | ||
|
||
const ( | ||
_ = iota | ||
MarshalingTypeASN1 MarshalingType = iota | ||
MarshalingTypeJWS | ||
) | ||
|
||
var ( | ||
HashTypeMap = map[string]HashType{ | ||
"sha2-224": HashTypeSHA2224, | ||
"sha2-256": HashTypeSHA2256, | ||
"sha2-384": HashTypeSHA2384, | ||
"sha2-512": HashTypeSHA2512, | ||
} | ||
|
||
HashFuncMap = map[HashType]func() hash.Hash{ | ||
HashTypeSHA2224: sha256.New224, | ||
HashTypeSHA2256: sha256.New, | ||
HashTypeSHA2384: sha512.New384, | ||
HashTypeSHA2512: sha512.New, | ||
} | ||
|
||
MarshalingTypeMap = map[string]MarshalingType{ | ||
"asn1": MarshalingTypeASN1, | ||
"jws": MarshalingTypeJWS, | ||
} | ||
) |
Oops, something went wrong.