Skip to content

Commit 2d9ecc4

Browse files
committed
minor
1 parent 23a36ad commit 2d9ecc4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kid_keys.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package jwt
22

33
import (
4+
"encoding/hex"
45
"errors"
56
"fmt"
67
"strconv"
@@ -93,6 +94,8 @@ type (
9394
// Encryption using the Galois Counter mode of operation with
9495
// AES cipher symmetric-key cryptographic.
9596
//
97+
// It should be HEX-encoded string value.
98+
//
9699
// The value should be the AES key,
97100
// either 16, 24, or 32 bytes to select
98101
// AES-128, AES-192, or AES-256.
@@ -160,7 +163,11 @@ func (c KeysConfiguration) Load() (Keys, error) {
160163
}
161164

162165
if entry.EncryptionKey != "" {
163-
encrypt, decrypt, err := GCM([]byte(entry.EncryptionKey), nil)
166+
encryptionKey, err := hex.DecodeString(entry.EncryptionKey)
167+
if err != nil {
168+
return nil, fmt.Errorf("jwt: load keys: decode encryption key (hex): %w", err)
169+
}
170+
encrypt, decrypt, err := GCM([]byte(encryptionKey), nil)
164171
if err != nil {
165172
return nil, fmt.Errorf("jwt: load keys: build encryption: %w", err)
166173
}

0 commit comments

Comments
 (0)