| 1 | package jwxtestscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/" |
| 5 | "contextscip-go gomod github.com/golang/go/src go1.24.0 context/" |
| 6 | "crypto/ecdhscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdh`/" |
| 7 | "crypto/ecdsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/" |
| 8 | "crypto/ed25519scip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/" |
| 9 | "crypto/randscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/" |
| 10 | "crypto/rsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/" |
| 11 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/" |
| 12 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 13 | "ioscip-go gomod github.com/golang/go/src go1.24.0 io/" |
| 14 | "osscip-go gomod github.com/golang/go/src go1.24.0 os/" |
| 15 | "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/" |
| 16 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 17 | |
| 18 | "github.com/lestrrat-go/jwx/v3/internal/tokensscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/tokens`/" |
| 19 | "github.com/lestrrat-go/jwx/v3/jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/" |
| 20 | "github.com/lestrrat-go/jwx/v3/jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/" |
| 21 | "github.com/lestrrat-go/jwx/v3/jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/" |
| 22 | ourecdsascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/ "github.com/lestrrat-go/jwx/v3/jwk/ecdsascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/" |
| 23 | "github.com/lestrrat-go/jwx/v3/jwsscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/" |
| 24 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 25 | ) |
| 26 | |
| 27 | func GenerateRsaKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateRsaKey().() (*rsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/PrivateKey#, error) { |
| 28 | return rsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/.GenerateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/GenerateKey().(randscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/Reader., 2048) |
| 29 | } |
| 30 | |
| 31 | func GenerateRsaJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateRsaJwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 32 | key, err := GenerateRsaKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateRsaKey().() |
| 33 | if err != nil { |
| 34 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate RSA private key: %w`, err) |
| 35 | } |
| 36 | |
| 37 | k, err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Importscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Import().(key) |
| 38 | if err != nil { |
| 39 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.RSAPrivateKey: %w`, err) |
| 40 | } |
| 41 | |
| 42 | return k, nil |
| 43 | } |
| 44 | |
| 45 | func GenerateRsaPublicJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateRsaPublicJwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 46 | key, err := GenerateRsaJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateRsaJwk().() |
| 47 | if err != nil { |
| 48 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.RSAPrivateKey: %w`, err) |
| 49 | } |
| 50 | |
| 51 | return jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.PublicKeyOfscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/PublicKeyOf().(key) |
| 52 | } |
| 53 | |
| 54 | func GenerateEcdsaKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEcdsaKey().(alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#) (*ecdsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/PrivateKey#, error) { |
| 55 | crv, err := ourecdsascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/.CurveFromAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/CurveFromAlgorithm().(alg) |
| 56 | if err != nil { |
| 57 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`unknown elliptic curve algorithm: %w`, err) |
| 58 | } |
| 59 | |
| 60 | return ecdsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/.GenerateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/GenerateKey().(crv, randscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/Reader.) |
| 61 | } |
| 62 | |
| 63 | func GenerateEcdsaJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEcdsaJwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 64 | key, err := GenerateEcdsaKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEcdsaKey().(jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.P521scip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/P521().()) |
| 65 | if err != nil { |
| 66 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate ECDSA private key: %w`, err) |
| 67 | } |
| 68 | |
| 69 | k, err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Importscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Import().(key) |
| 70 | if err != nil { |
| 71 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.ECDSAPrivateKey: %w`, err) |
| 72 | } |
| 73 | |
| 74 | return k, nil |
| 75 | } |
| 76 | |
| 77 | func GenerateEcdsaPublicJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEcdsaPublicJwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 78 | key, err := GenerateEcdsaJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEcdsaJwk().() |
| 79 | if err != nil { |
| 80 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.ECDSAPrivateKey: %w`, err) |
| 81 | } |
| 82 | |
| 83 | return jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.PublicKeyOfscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/PublicKeyOf().(key) |
| 84 | } |
| 85 | |
| 86 | func GenerateSymmetricKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateSymmetricKey().() []byte { |
| 87 | sharedKey := make([]byte, 64) |
| 88 | randscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/.Readscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/Read().(sharedKey) |
| 89 | return sharedKey |
| 90 | } |
| 91 | |
| 92 | func GenerateSymmetricJwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateSymmetricJwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 93 | key, err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Importscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Import().(GenerateSymmetricKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateSymmetricKey().()) |
| 94 | if err != nil { |
| 95 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.SymmetricKey: %w`, err) |
| 96 | } |
| 97 | |
| 98 | return key, nil |
| 99 | } |
| 100 | |
| 101 | func GenerateEd25519Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEd25519Key().() (ed25519scip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/PrivateKey#, error) { |
| 102 | _, priv, err := ed25519scip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/.GenerateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/GenerateKey().(randscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/Reader.) |
| 103 | return priv, err |
| 104 | } |
| 105 | |
| 106 | func GenerateEd25519Jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEd25519Jwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 107 | key, err := GenerateEd25519Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateEd25519Key().() |
| 108 | if err != nil { |
| 109 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate Ed25519 private key: %w`, err) |
| 110 | } |
| 111 | |
| 112 | k, err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Importscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Import().(key) |
| 113 | if err != nil { |
| 114 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.OKPPrivateKey: %w`, err) |
| 115 | } |
| 116 | |
| 117 | return k, nil |
| 118 | } |
| 119 | |
| 120 | func GenerateX25519Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateX25519Key().() (*ecdhscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdh`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdh`/PrivateKey#, error) { |
| 121 | priv, err := ecdhscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdh`/.X25519scip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdh`/X25519().().GenerateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdh`/Curve#GenerateKey().(randscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rand`/Reader.) |
| 122 | return priv, err |
| 123 | } |
| 124 | |
| 125 | func GenerateX25519Jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateX25519Jwk().() (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 126 | key, err := GenerateX25519Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/GenerateX25519Key().() |
| 127 | if err != nil { |
| 128 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate X25519 private key: %w`, err) |
| 129 | } |
| 130 | |
| 131 | k, err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Importscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Import().(key) |
| 132 | if err != nil { |
| 133 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to generate jwk.OKPPrivateKey: %w`, err) |
| 134 | } |
| 135 | |
| 136 | return k, nil |
| 137 | } |
| 138 | |
| 139 | func WriteFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/WriteFile().(dir, template string, src ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Readerscip-go gomod github.com/golang/go/src go1.24.0 io/Reader#) (string, func(), error) { |
| 140 | file, cleanup, err := CreateTempFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/CreateTempFile().(dir, template) |
| 141 | if err != nil { |
| 142 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to create temporary file: %w`, err) |
| 143 | } |
| 144 | |
| 145 | if _, err := ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Copyscip-go gomod github.com/golang/go/src go1.24.0 io/Copy().(file, src); err != nil { |
| 146 | defer cleanup() |
| 147 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to copy content to temporary file: %w`, err) |
| 148 | } |
| 149 | |
| 150 | if err := file.Syncscip-go gomod github.com/golang/go/src go1.24.0 os/File#Sync().(); err != nil { |
| 151 | defer cleanup() |
| 152 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to sync file: %w`, err) |
| 153 | } |
| 154 | return file.Namescip-go gomod github.com/golang/go/src go1.24.0 os/File#Name().(), cleanup, nil |
| 155 | } |
| 156 | |
| 157 | func WriteJSONFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/WriteJSONFile().(dir, template string, v any) (string, func(), error) { |
| 158 | var buf bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer# |
| 159 | |
| 160 | enc := jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/.NewEncoderscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/NewEncoder().(&buf) |
| 161 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/Encoder#Encode().(v); err != nil { |
| 162 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to encode object to JSON: %w`, err) |
| 163 | } |
| 164 | return WriteFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/WriteFile().(dir, template, &buf) |
| 165 | } |
| 166 | |
| 167 | func DumpFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/DumpFile().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#, file string) { |
| 168 | buf, err := osscip-go gomod github.com/golang/go/src go1.24.0 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.0 os/ReadFile().(file) |
| 169 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err, `failed to read file %s for debugging`, file) |
| 170 | |
| 171 | if isHash, isArray := bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.ContainsRunescip-go gomod github.com/golang/go/src go1.24.0 bytes/ContainsRune().(buf, tokensscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/tokens`/.OpenCurlyBracketscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/tokens`/OpenCurlyBracket.), bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.ContainsRunescip-go gomod github.com/golang/go/src go1.24.0 bytes/ContainsRune().(buf, tokensscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/tokens`/.OpenSquareBracketscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/tokens`/OpenSquareBracket.); isHash || isArray { |
| 172 | // Looks like a JSON-like thing. Dump that in a formatted manner, and |
| 173 | // be done with it |
| 174 | |
| 175 | var v any |
| 176 | if isHash { |
| 177 | v = map[string]any{} |
| 178 | } else { |
| 179 | v = []any{} |
| 180 | } |
| 181 | |
| 182 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/Unmarshal().(buf, &v), `failed to parse contents as JSON`) |
| 183 | |
| 184 | buf, _ = jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/.MarshalIndentscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/MarshalIndent().(v, "", " ") |
| 185 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("=== BEGIN %s (formatted JSON) ===", file) |
| 186 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("%s", buf) |
| 187 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("=== END %s (formatted JSON) ===", file) |
| 188 | return |
| 189 | } |
| 190 | |
| 191 | // If the contents do not look like JSON, then we attempt to parse each content |
| 192 | // based on heuristics (from its file name) and do our best |
| 193 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("=== BEGIN %s (raw) ===", file) |
| 194 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("%s", buf) |
| 195 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("=== END %s (raw) ===", file) |
| 196 | |
| 197 | if stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.24.0 strings/HasSuffix().(file, ".jwe") { |
| 198 | // cross our fingers our jwe implementation works |
| 199 | m, err := jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.Parsescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/Parse().(buf) |
| 200 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err, `failed to parse JWE encrypted message`) |
| 201 | |
| 202 | buf, _ = jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/.MarshalIndentscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/MarshalIndent().(m, "", " ") |
| 203 | } |
| 204 | |
| 205 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("=== BEGIN %s (formatted JSON) ===", file) |
| 206 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("%s", buf) |
| 207 | t.Logfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Logf().("=== END %s (formatted JSON) ===", file) |
| 208 | } |
| 209 | |
| 210 | func CreateTempFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/CreateTempFile().(dir, template string) (*osscip-go gomod github.com/golang/go/src go1.24.0 os/.Filescip-go gomod github.com/golang/go/src go1.24.0 os/File#, func(), error) { |
| 211 | file, err := osscip-go gomod github.com/golang/go/src go1.24.0 os/.CreateTempscip-go gomod github.com/golang/go/src go1.24.0 os/CreateTemp().(dir, template) |
| 212 | if err != nil { |
| 213 | return nil, nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to create temporary file: %w`, err) |
| 214 | } |
| 215 | |
| 216 | cleanup := func() { |
| 217 | file.Closescip-go gomod github.com/golang/go/src go1.24.0 os/File#Close().() |
| 218 | osscip-go gomod github.com/golang/go/src go1.24.0 os/.Removescip-go gomod github.com/golang/go/src go1.24.0 os/Remove().(file.Namescip-go gomod github.com/golang/go/src go1.24.0 os/File#Name().()) |
| 219 | } |
| 220 | |
| 221 | return file, cleanup, nil |
| 222 | } |
| 223 | |
| 224 | func ReadFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ReadFile().(file string) ([]byte, error) { |
| 225 | f, err := osscip-go gomod github.com/golang/go/src go1.24.0 os/.Openscip-go gomod github.com/golang/go/src go1.24.0 os/Open().(file) |
| 226 | if err != nil { |
| 227 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to open file %s: %w`, file, err) |
| 228 | } |
| 229 | defer f.Closescip-go gomod github.com/golang/go/src go1.24.0 os/File#Close().() |
| 230 | |
| 231 | buf, err := ioscip-go gomod github.com/golang/go/src go1.24.0 io/.ReadAllscip-go gomod github.com/golang/go/src go1.24.0 io/ReadAll().(f) |
| 232 | if err != nil { |
| 233 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to read from key file %s: %w`, file, err) |
| 234 | } |
| 235 | |
| 236 | return buf, nil |
| 237 | } |
| 238 | |
| 239 | func ParseJwkFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ParseJwkFile().(_ contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, file string) (jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Keyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Key#, error) { |
| 240 | buf, err := ReadFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ReadFile().(file) |
| 241 | if err != nil { |
| 242 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to read from key file %s: %w`, file, err) |
| 243 | } |
| 244 | |
| 245 | key, err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.ParseKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/ParseKey().(buf) |
| 246 | if err != nil { |
| 247 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`filed to parse JWK in key file %s: %w`, file, err) |
| 248 | } |
| 249 | |
| 250 | return key, nil |
| 251 | } |
| 252 | |
| 253 | func DecryptJweFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/DecryptJweFile().(ctx contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, file string, alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.KeyEncryptionAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/KeyEncryptionAlgorithm#, jwkfile string) ([]byte, error) { |
| 254 | key, err := ParseJwkFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ParseJwkFile().(ctx, jwkfile) |
| 255 | if err != nil { |
| 256 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to parse keyfile %s: %w`, file, err) |
| 257 | } |
| 258 | |
| 259 | buf, err := ReadFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ReadFile().(file) |
| 260 | if err != nil { |
| 261 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to read from encrypted file %s: %w`, file, err) |
| 262 | } |
| 263 | |
| 264 | var rawkey any |
| 265 | if err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Exportscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Export().(key, &rawkey); err != nil { |
| 266 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to obtain raw key from JWK: %w`, err) |
| 267 | } |
| 268 | |
| 269 | return jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.Decryptscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/Decrypt().(buf, jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.WithKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/WithKey().(alg, rawkey)) |
| 270 | } |
| 271 | |
| 272 | func EncryptJweFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/EncryptJweFile().(ctx contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, dir string, payload []byte, keyalg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.KeyEncryptionAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/KeyEncryptionAlgorithm#, keyfile string, contentalg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.ContentEncryptionAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/ContentEncryptionAlgorithm#, compressalg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.CompressionAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/CompressionAlgorithm#) (string, func(), error) { |
| 273 | key, err := ParseJwkFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ParseJwkFile().(ctx, keyfile) |
| 274 | if err != nil { |
| 275 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to parse keyfile %s: %w`, keyfile, err) |
| 276 | } |
| 277 | |
| 278 | var keyif any |
| 279 | |
| 280 | switch keyalg { |
| 281 | case jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.RSA1_5scip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/RSA1_5().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.RSA_OAEPscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/RSA_OAEP().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.RSA_OAEP_256scip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/RSA_OAEP_256().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.RSA_OAEP_384scip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/RSA_OAEP_384().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.RSA_OAEP_512scip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/RSA_OAEP_512().(): |
| 282 | var rawkey rsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/PrivateKey# |
| 283 | if err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Exportscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Export().(key, &rawkey); err != nil { |
| 284 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to obtain raw key: %w`, err) |
| 285 | } |
| 286 | keyif = rawkey.PublicKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/PrivateKey#PublicKey. |
| 287 | case jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.ECDH_ESscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/ECDH_ES().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.ECDH_ES_A128KWscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/ECDH_ES_A128KW().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.ECDH_ES_A192KWscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/ECDH_ES_A192KW().(), jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.ECDH_ES_A256KWscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/ECDH_ES_A256KW().(): |
| 288 | var rawkey ecdsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/PrivateKey# |
| 289 | if err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Exportscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Export().(key, &rawkey); err != nil { |
| 290 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to obtain raw key: %w`, err) |
| 291 | } |
| 292 | keyif = rawkey.PublicKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/PrivateKey#PublicKey. |
| 293 | default: |
| 294 | var rawkey []byte |
| 295 | if err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Exportscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Export().(key, &rawkey); err != nil { |
| 296 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to obtain raw key: %w`, err) |
| 297 | } |
| 298 | keyif = rawkey |
| 299 | } |
| 300 | |
| 301 | buf, err := jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.Encryptscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/Encrypt().(payload, jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.WithKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/WithKey().(keyalg, keyif), jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.WithContentEncryptionscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/WithContentEncryption().(contentalg), jwescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/.WithCompressscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe`/WithCompress().(compressalg)) |
| 302 | if err != nil { |
| 303 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to encrypt payload: %w`, err) |
| 304 | } |
| 305 | |
| 306 | return WriteFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/WriteFile().(dir, "jwx-test-*.jwe", bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewReader().(buf)) |
| 307 | } |
| 308 | |
| 309 | func VerifyJwsFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/VerifyJwsFile().(ctx contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, file string, alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.SignatureAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/SignatureAlgorithm#, jwkfile string) ([]byte, error) { |
| 310 | key, err := ParseJwkFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ParseJwkFile().(ctx, jwkfile) |
| 311 | if err != nil { |
| 312 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to parse keyfile %s: %w`, file, err) |
| 313 | } |
| 314 | |
| 315 | buf, err := ReadFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ReadFile().(file) |
| 316 | if err != nil { |
| 317 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to read from encrypted file %s: %w`, file, err) |
| 318 | } |
| 319 | |
| 320 | var rawkey, pubkey any |
| 321 | if err := jwkscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/.Exportscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk`/Export().(key, &rawkey); err != nil { |
| 322 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to obtain raw key from JWK: %w`, err) |
| 323 | } |
| 324 | pubkey = rawkey |
| 325 | switch tkey := rawkey.(type) { |
| 326 | case *ecdsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/PrivateKey#: |
| 327 | pubkey = tkey.PublicKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ecdsa`/PrivateKey#PublicKey. |
| 328 | case *rsascip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/PrivateKey#: |
| 329 | pubkey = tkey.PublicKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/rsa`/PrivateKey#PublicKey. |
| 330 | case *ed25519scip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/.PrivateKeyscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/PrivateKey#: |
| 331 | pubkey = tkey.Publicscip-go gomod github.com/golang/go/src go1.24.0 `crypto/ed25519`/PrivateKey#Public().() |
| 332 | } |
| 333 | |
| 334 | return jwsscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/.Verifyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/Verify().(buf, jwsscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/.WithKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/WithKey().(alg, pubkey)) |
| 335 | } |
| 336 | |
| 337 | func SignJwsFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/SignJwsFile().(ctx contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, dir string, payload []byte, alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.SignatureAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/SignatureAlgorithm#, keyfile string) (string, func(), error) { |
| 338 | key, err := ParseJwkFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/ParseJwkFile().(ctx, keyfile) |
| 339 | if err != nil { |
| 340 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to parse keyfile %s: %w`, keyfile, err) |
| 341 | } |
| 342 | |
| 343 | buf, err := jwsscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/.Signscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/Sign().(payload, jwsscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/.WithKeyscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jws`/WithKey().(alg, key)) |
| 344 | if err != nil { |
| 345 | return "", nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`failed to sign payload: %w`, err) |
| 346 | } |
| 347 | |
| 348 | return WriteFilescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/internal/jwxtest`/WriteFile().(dir, "jwx-test-*.jws", bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewReader().(buf)) |
| 349 | } |