| 1 | package concatkdfscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe/internal/concatkdf`/ |
| 2 | |
| 3 | import ( |
| 4 | "cryptoscip-go gomod github.com/golang/go/src go1.24.0 crypto/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 6 | |
| 7 | "github.com/lestrrat-go/jwx/v3/jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/" |
| 8 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 9 | ) |
| 10 | |
| 11 | // https://tools.ietf.org/html/rfc7518#appendix-C |
| 12 | func TestAppendixscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe/internal/concatkdf`/TestAppendix().(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#) { |
| 13 | z := []byte{158, 86, 217, 29, 129, 113, 53, 211, 114, 131, 66, 131, 191, 132, |
| 14 | 38, 156, 251, 49, 110, 163, 218, 128, 106, 72, 246, 218, 167, 121, |
| 15 | 140, 254, 144, 196} |
| 16 | alg := []byte(jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.A128GCMscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/A128GCM().().Stringscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/ContentEncryptionAlgorithm#String().()) |
| 17 | apu := []byte{65, 108, 105, 99, 101} |
| 18 | apv := []byte{66, 111, 98} |
| 19 | pub := []byte{0, 0, 0, 128} |
| 20 | priv := []byte(nil) |
| 21 | expected := []byte{86, 170, 141, 234, 248, 35, 109, 32, 92, 34, 40, 205, 113, 167, 16, 26} |
| 22 | |
| 23 | kdf := Newscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe/internal/concatkdf`/New().(cryptoscip-go gomod github.com/golang/go/src go1.24.0 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.24.0 crypto/SHA256., alg, z, apu, apv, pub, priv) |
| 24 | |
| 25 | out := make([]byte, 16) // 128bits |
| 26 | |
| 27 | n, err := kdf.Readscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe/internal/concatkdf`/KDF#Read().(out[:5]) |
| 28 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Equal().(t, 5, n, "first read bytes matches") |
| 29 | 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, "first read successful") |
| 30 | |
| 31 | n, err = kdf.Readscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwe/internal/concatkdf`/KDF#Read().(out[5:]) |
| 32 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Equal().(t, 11, n, "second read bytes matches") |
| 33 | 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, "second read successful") |
| 34 | |
| 35 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Equal().(t, expected, out, "generated value matches") |
| 36 | } |