Skip to content

Commit

Permalink
Rename constants and globals following the Go naming convention
Browse files Browse the repository at this point in the history
instead of WebCrypto's
  • Loading branch information
oleiade committed Apr 14, 2023
1 parent c8c80aa commit 0253be6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions webcrypto/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ const (
type HashAlgorithmIdentifier = AlgorithmIdentifier

const (
// Sha1 represents the SHA-1 algorithm.
Sha1 HashAlgorithmIdentifier = "SHA-1"
// SHA1 represents the SHA-1 algorithm.
SHA1 HashAlgorithmIdentifier = "SHA-1"

// Sha256 represents the SHA-256 algorithm.
Sha256 = "SHA-256"
// SHA256 represents the SHA-256 algorithm.
SHA256 = "SHA-256"

// Sha384 represents the SHA-384 algorithm.
Sha384 = "SHA-384"
// SHA384 represents the SHA-384 algorithm.
SHA384 = "SHA-384"

// Sha512 represents the SHA-512 algorithm.
Sha512 = "SHA-512"
// SHA512 represents the SHA-512 algorithm.
SHA512 = "SHA-512"
)

// OperationIdentifier represents the name of an operation.
Expand Down Expand Up @@ -185,5 +185,5 @@ func isAesAlgorithm(algorithmName string) bool {
}

func isHashAlgorithm(algorithmName string) bool {
return algorithmName == Sha1 || algorithmName == Sha256 || algorithmName == Sha384 || algorithmName == Sha512
return algorithmName == SHA1 || algorithmName == SHA256 || algorithmName == SHA384 || algorithmName == SHA512
}
8 changes: 4 additions & 4 deletions webcrypto/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
// hash.Hash instance.
func getHashFn(name string) (func() hash.Hash, bool) {
switch name {
case Sha1:
case SHA1:
return crypto.SHA1.New, true
case Sha256:
case SHA256:
return crypto.SHA256.New, true
case Sha384:
case SHA384:
return crypto.SHA384.New, true
case Sha512:
case SHA512:
return crypto.SHA512.New, true
default:
return nil, false
Expand Down
8 changes: 4 additions & 4 deletions webcrypto/hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func (hkgp *HMACKeyGenParams) GenerateKey(
// callback below could lead to a race condition.
if !hkgp.Length.Valid {
switch hkgp.Hash.Name {
case Sha1:
case SHA1:
hkgp.Length = null.IntFrom(sha1.BlockSize * 8)
case Sha256:
case SHA256:
hkgp.Length = null.IntFrom(sha256.BlockSize * 8)
case Sha384:
case SHA384:
hkgp.Length = null.IntFrom(sha512.BlockSize * 8)
case Sha512:
case SHA512:
hkgp.Length = null.IntFrom(sha512.BlockSize * 8)
default:
// This case should never happen, as the normalization algorithm
Expand Down

0 comments on commit 0253be6

Please sign in to comment.