Skip to content

Commit 3d95742

Browse files
committed
Minor vanities.
1 parent 3ed5bc4 commit 3d95742

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

check.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ParseWithoutCheck(token []byte) (*Claims, error) {
3030

3131
// ECDSACheck parses a JWT if, and only if, the signature checks out.
3232
// The return is an AlgError when the algorithm is not in ECDSAAlgs.
33-
// See Valid to complete the verification.
33+
// Use Valid to complete the verification.
3434
func ECDSACheck(token []byte, key *ecdsa.PublicKey) (*Claims, error) {
3535
var c Claims
3636
firstDot, lastDot, sig, alg, err := c.scan(token)
@@ -55,7 +55,7 @@ func ECDSACheck(token []byte, key *ecdsa.PublicKey) (*Claims, error) {
5555
}
5656

5757
// EdDSACheck parses a JWT if, and only if, the signature checks out.
58-
// See Valid to complete the verification.
58+
// Use Valid to complete the verification.
5959
func EdDSACheck(token []byte, key ed25519.PublicKey) (*Claims, error) {
6060
var c Claims
6161
firstDot, lastDot, sig, alg, err := c.scan(token)
@@ -76,7 +76,7 @@ func EdDSACheck(token []byte, key ed25519.PublicKey) (*Claims, error) {
7676

7777
// HMACCheck parses a JWT if, and only if, the signature checks out.
7878
// The return is an AlgError when the algorithm is not in HMACAlgs.
79-
// See Valid to complete the verification.
79+
// Use Valid to complete the verification.
8080
func HMACCheck(token, secret []byte) (*Claims, error) {
8181
if len(secret) == 0 {
8282
return nil, errNoSecret
@@ -104,7 +104,7 @@ func HMACCheck(token, secret []byte) (*Claims, error) {
104104

105105
// RSACheck parses a JWT if, and only if, the signature checks out.
106106
// The return is an AlgError when the algorithm is not in RSAAlgs.
107-
// See Valid to complete the verification.
107+
// Use Valid to complete the verification.
108108
func RSACheck(token []byte, key *rsa.PublicKey) (*Claims, error) {
109109
var c Claims
110110
firstDot, lastDot, sig, alg, err := c.scan(token)

examples_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func init() {
4747
}
4848

4949
// Issue and validate a token with extra JOSE heading and non-standard claims.
50-
// Note how the token is flawed due to absense of a purpose classification. The
50+
// Note how the token is flawed due to absence of a purpose classification. The
5151
// bare minimum should include time constraints.
5252
func Example() {
5353
// Approval is a custom (a.k.a. private) claim element.

fuzz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func FuzzCheck(data []byte) int {
2525
}
2626

2727
var keys KeyRegister
28-
keys.Secrets = [][]byte{[]byte{'s', 'e', 'c', 'r', 'e', 't'}}
28+
keys.Secrets = [][]byte{{'s', 'e', 'c', 'r', 'e', 't'}}
2929
_, err := keys.LoadPEM([]byte(`-----BEGIN PUBLIC KEY-----
3030
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEc5/E+krowgL6Q1Xv6g1Hrh74kccf
3131
QdmMuEk/xPJQZD22ITRYiaCRaKFWaoDBcIv21JfJo2F4whHnOCFX0Y/ALg==

register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type KeyRegister struct {
3131
}
3232

3333
// Check parses a JWT if, and only if, the signature checks out.
34-
// See Claims.Valid to complete the verification.
34+
// Use Claims.Valid to complete the verification.
3535
func (keys *KeyRegister) Check(token []byte) (*Claims, error) {
3636
var c Claims
3737
firstDot, lastDot, sig, alg, err := c.scan(token)

sign.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"strconv"
1414
)
1515

16-
// FormatWithoutSign updates the Raw field and returns a new JWT, with only the
16+
// FormatWithoutSign updates the Raw fields and returns a new JWT, with only the
1717
// first two parts.
1818
//
1919
// tokenWithoutSignature :≡ header-base64 '.' payload-base64
@@ -25,7 +25,7 @@ func (c *Claims) FormatWithoutSign(alg string, extraHeaders ...json.RawMessage)
2525
return c.newToken(alg, 0, extraHeaders)
2626
}
2727

28-
// ECDSASign updates the Raw field and returns a new JWT.
28+
// ECDSASign updates the Raw fields and returns a new JWT.
2929
// The return is an AlgError when alg is not in ECDSAAlgs.
3030
// The caller must use the correct key for the respective algorithm (P-256 for
3131
// ES256, P-384 for ES384 and P-521 for ES512) or risk malformed token production.
@@ -78,7 +78,7 @@ func (c *Claims) ECDSASign(alg string, key *ecdsa.PrivateKey, extraHeaders ...js
7878
return token[:cap(token)], nil
7979
}
8080

81-
// EdDSASign updates the Raw field and returns a new JWT.
81+
// EdDSASign updates the Raw fields and returns a new JWT.
8282
//
8383
// The JOSE header (content) can be extended with extraHeaders, in the form of
8484
// JSON objects. Redundant and/or duplicate keys are applied as provided.
@@ -95,7 +95,7 @@ func (c *Claims) EdDSASign(key ed25519.PrivateKey, extraHeaders ...json.RawMessa
9595
return token[:cap(token)], nil
9696
}
9797

98-
// HMACSign updates the Raw field and returns a new JWT.
98+
// HMACSign updates the Raw fields and returns a new JWT.
9999
// The return is an AlgError when alg is not in HMACAlgs.
100100
//
101101
// The JOSE header (content) can be extended with extraHeaders, in the form of
@@ -124,7 +124,7 @@ func (c *Claims) HMACSign(alg string, secret []byte, extraHeaders ...json.RawMes
124124
return token[:cap(token)], nil
125125
}
126126

127-
// RSASign updates the Raw field and returns a new JWT.
127+
// RSASign updates the Raw fields and returns a new JWT.
128128
// The return is an AlgError when alg is not in RSAAlgs.
129129
//
130130
// The JOSE header (content) can be extended with extraHeaders, in the form of
@@ -160,10 +160,10 @@ func (c *Claims) RSASign(alg string, key *rsa.PrivateKey, extraHeaders ...json.R
160160
}
161161

162162
var (
163-
headerEdDSA = []byte(`{"alg":"EdDSA"}`)
164163
headerES256 = []byte(`{"alg":"ES256"}`)
165164
headerES384 = []byte(`{"alg":"ES384"}`)
166165
headerES512 = []byte(`{"alg":"ES512"}`)
166+
headerEdDSA = []byte(`{"alg":"EdDSA"}`)
167167
headerHS256 = []byte(`{"alg":"HS256"}`)
168168
headerHS384 = []byte(`{"alg":"HS384"}`)
169169
headerHS512 = []byte(`{"alg":"HS512"}`)
@@ -221,9 +221,6 @@ func (c *Claims) newToken(alg string, encSigLen int, extraHeaders []json.RawMess
221221
if len(extraHeaders) == 0 && c.KeyID == "" {
222222
var fixed string
223223
switch alg {
224-
case EdDSA:
225-
fixed = "eyJhbGciOiJFZERTQSJ9."
226-
c.RawHeader = headerEdDSA
227224
case ES256:
228225
fixed = "eyJhbGciOiJFUzI1NiJ9."
229226
c.RawHeader = headerES256
@@ -233,6 +230,9 @@ func (c *Claims) newToken(alg string, encSigLen int, extraHeaders []json.RawMess
233230
case ES512:
234231
fixed = "eyJhbGciOiJFUzUxMiJ9."
235232
c.RawHeader = headerES512
233+
case EdDSA:
234+
fixed = "eyJhbGciOiJFZERTQSJ9."
235+
c.RawHeader = headerEdDSA
236236
case HS256:
237237
fixed = "eyJhbGciOiJIUzI1NiJ9."
238238
c.RawHeader = headerHS256

0 commit comments

Comments
 (0)