aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go')
-rw-r--r--vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go b/vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go
deleted file mode 100644
index cdb5e68..0000000
--- a/vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go
+++ /dev/null
@@ -1,64 +0,0 @@
1package jwt
2
3import (
4 "crypto"
5 "crypto/ed25519"
6 "crypto/x509"
7 "encoding/pem"
8 "errors"
9)
10
11var (
12 ErrNotEdPrivateKey = errors.New("key is not a valid Ed25519 private key")
13 ErrNotEdPublicKey = errors.New("key is not a valid Ed25519 public key")
14)
15
16// ParseEdPrivateKeyFromPEM parses a PEM-encoded Edwards curve private key
17func ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error) {
18 var err error
19
20 // Parse PEM block
21 var block *pem.Block
22 if block, _ = pem.Decode(key); block == nil {
23 return nil, ErrKeyMustBePEMEncoded
24 }
25
26 // Parse the key
27 var parsedKey interface{}
28 if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
29 return nil, err
30 }
31
32 var pkey ed25519.PrivateKey
33 var ok bool
34 if pkey, ok = parsedKey.(ed25519.PrivateKey); !ok {
35 return nil, ErrNotEdPrivateKey
36 }
37
38 return pkey, nil
39}
40
41// ParseEdPublicKeyFromPEM parses a PEM-encoded Edwards curve public key
42func ParseEdPublicKeyFromPEM(key []byte) (crypto.PublicKey, error) {
43 var err error
44
45 // Parse PEM block
46 var block *pem.Block
47 if block, _ = pem.Decode(key); block == nil {
48 return nil, ErrKeyMustBePEMEncoded
49 }
50
51 // Parse the key
52 var parsedKey interface{}
53 if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
54 return nil, err
55 }
56
57 var pkey ed25519.PublicKey
58 var ok bool
59 if pkey, ok = parsedKey.(ed25519.PublicKey); !ok {
60 return nil, ErrNotEdPublicKey
61 }
62
63 return pkey, nil
64}