diff options
author | Rutger Broekhoff | 2024-01-02 18:56:31 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2024-01-02 18:56:31 +0100 |
commit | 8db41da676ac8368ef7c2549d56239a5ff5eedde (patch) | |
tree | 09c427fd66de2ec1ebffc8342f5fdbb84b0701b5 /vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go | |
parent | d4f75fb6db22e57577867445a022227e70958931 (diff) | |
download | gitolfs3-8db41da676ac8368ef7c2549d56239a5ff5eedde.tar.gz gitolfs3-8db41da676ac8368ef7c2549d56239a5ff5eedde.zip |
Delete vendor directory
Diffstat (limited to 'vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go')
-rw-r--r-- | vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go b/vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go deleted file mode 100644 index 5700636..0000000 --- a/vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | package jwt | ||
2 | |||
3 | import ( | ||
4 | "crypto/ecdsa" | ||
5 | "crypto/x509" | ||
6 | "encoding/pem" | ||
7 | "errors" | ||
8 | ) | ||
9 | |||
10 | var ( | ||
11 | ErrNotECPublicKey = errors.New("key is not a valid ECDSA public key") | ||
12 | ErrNotECPrivateKey = errors.New("key is not a valid ECDSA private key") | ||
13 | ) | ||
14 | |||
15 | // ParseECPrivateKeyFromPEM parses a PEM encoded Elliptic Curve Private Key Structure | ||
16 | func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { | ||
17 | var err error | ||
18 | |||
19 | // Parse PEM block | ||
20 | var block *pem.Block | ||
21 | if block, _ = pem.Decode(key); block == nil { | ||
22 | return nil, ErrKeyMustBePEMEncoded | ||
23 | } | ||
24 | |||
25 | // Parse the key | ||
26 | var parsedKey interface{} | ||
27 | if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { | ||
28 | if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { | ||
29 | return nil, err | ||
30 | } | ||
31 | } | ||
32 | |||
33 | var pkey *ecdsa.PrivateKey | ||
34 | var ok bool | ||
35 | if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok { | ||
36 | return nil, ErrNotECPrivateKey | ||
37 | } | ||
38 | |||
39 | return pkey, nil | ||
40 | } | ||
41 | |||
42 | // ParseECPublicKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 public key | ||
43 | func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) { | ||
44 | var err error | ||
45 | |||
46 | // Parse PEM block | ||
47 | var block *pem.Block | ||
48 | if block, _ = pem.Decode(key); block == nil { | ||
49 | return nil, ErrKeyMustBePEMEncoded | ||
50 | } | ||
51 | |||
52 | // Parse the key | ||
53 | var parsedKey interface{} | ||
54 | if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { | ||
55 | if cert, err := x509.ParseCertificate(block.Bytes); err == nil { | ||
56 | parsedKey = cert.PublicKey | ||
57 | } else { | ||
58 | return nil, err | ||
59 | } | ||
60 | } | ||
61 | |||
62 | var pkey *ecdsa.PublicKey | ||
63 | var ok bool | ||
64 | if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok { | ||
65 | return nil, ErrNotECPublicKey | ||
66 | } | ||
67 | |||
68 | return pkey, nil | ||
69 | } | ||