@@ -13,7 +13,7 @@ import (
13
13
"strconv"
14
14
)
15
15
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
17
17
// first two parts.
18
18
//
19
19
// tokenWithoutSignature :≡ header-base64 '.' payload-base64
@@ -25,7 +25,7 @@ func (c *Claims) FormatWithoutSign(alg string, extraHeaders ...json.RawMessage)
25
25
return c .newToken (alg , 0 , extraHeaders )
26
26
}
27
27
28
- // ECDSASign updates the Raw field and returns a new JWT.
28
+ // ECDSASign updates the Raw fields and returns a new JWT.
29
29
// The return is an AlgError when alg is not in ECDSAAlgs.
30
30
// The caller must use the correct key for the respective algorithm (P-256 for
31
31
// 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
78
78
return token [:cap (token )], nil
79
79
}
80
80
81
- // EdDSASign updates the Raw field and returns a new JWT.
81
+ // EdDSASign updates the Raw fields and returns a new JWT.
82
82
//
83
83
// The JOSE header (content) can be extended with extraHeaders, in the form of
84
84
// 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
95
95
return token [:cap (token )], nil
96
96
}
97
97
98
- // HMACSign updates the Raw field and returns a new JWT.
98
+ // HMACSign updates the Raw fields and returns a new JWT.
99
99
// The return is an AlgError when alg is not in HMACAlgs.
100
100
//
101
101
// 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
124
124
return token [:cap (token )], nil
125
125
}
126
126
127
- // RSASign updates the Raw field and returns a new JWT.
127
+ // RSASign updates the Raw fields and returns a new JWT.
128
128
// The return is an AlgError when alg is not in RSAAlgs.
129
129
//
130
130
// 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
160
160
}
161
161
162
162
var (
163
- headerEdDSA = []byte (`{"alg":"EdDSA"}` )
164
163
headerES256 = []byte (`{"alg":"ES256"}` )
165
164
headerES384 = []byte (`{"alg":"ES384"}` )
166
165
headerES512 = []byte (`{"alg":"ES512"}` )
166
+ headerEdDSA = []byte (`{"alg":"EdDSA"}` )
167
167
headerHS256 = []byte (`{"alg":"HS256"}` )
168
168
headerHS384 = []byte (`{"alg":"HS384"}` )
169
169
headerHS512 = []byte (`{"alg":"HS512"}` )
@@ -221,9 +221,6 @@ func (c *Claims) newToken(alg string, encSigLen int, extraHeaders []json.RawMess
221
221
if len (extraHeaders ) == 0 && c .KeyID == "" {
222
222
var fixed string
223
223
switch alg {
224
- case EdDSA :
225
- fixed = "eyJhbGciOiJFZERTQSJ9."
226
- c .RawHeader = headerEdDSA
227
224
case ES256 :
228
225
fixed = "eyJhbGciOiJFUzI1NiJ9."
229
226
c .RawHeader = headerES256
@@ -233,6 +230,9 @@ func (c *Claims) newToken(alg string, encSigLen int, extraHeaders []json.RawMess
233
230
case ES512 :
234
231
fixed = "eyJhbGciOiJFUzUxMiJ9."
235
232
c .RawHeader = headerES512
233
+ case EdDSA :
234
+ fixed = "eyJhbGciOiJFZERTQSJ9."
235
+ c .RawHeader = headerEdDSA
236
236
case HS256 :
237
237
fixed = "eyJhbGciOiJIUzI1NiJ9."
238
238
c .RawHeader = headerHS256
0 commit comments