covTestKeyDocument returns an EncryptedData document encrypted to covFuzzKey, the key the tests pass to Fuzz.
(t testing.TB, e RSA)
| 30 | // covTestKeyDocument returns an EncryptedData document encrypted to covFuzzKey, |
| 31 | // the key the tests pass to Fuzz. |
| 32 | func covTestKeyDocument(t testing.TB, e RSA) []byte { |
| 33 | t.Helper() |
| 34 | template := &x509.Certificate{ |
| 35 | SerialNumber: big.NewInt(3), |
| 36 | Subject: pkix.Name{CommonName: "fuzz.example.com"}, |
| 37 | NotBefore: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), |
| 38 | NotAfter: time.Date(2100, 1, 1, 0, 0, 0, 0, time.UTC), |
| 39 | } |
| 40 | der, err := x509.CreateCertificate(rand.Reader, template, template, &covFuzzKey().PublicKey, covFuzzKey()) |
| 41 | assert.NilError(t, err) |
| 42 | cert, err := x509.ParseCertificate(der) |
| 43 | assert.NilError(t, err) |
| 44 | |
| 45 | el, err := e.Encrypt(cert, []byte("<Assertion>fuzz</Assertion>"), nil) |
| 46 | assert.NilError(t, err) |
| 47 | doc := etree.NewDocument() |
| 48 | doc.SetRoot(el) |
| 49 | buf, err := doc.WriteToBytes() |
| 50 | assert.NilError(t, err) |
| 51 | return buf |
| 52 | } |
| 53 | |
| 54 | func TestCovFuzz(t *testing.T) { |
| 55 | assert.Check(t, decryptForFuzzing(covFuzzKey(), []byte("<unclosed")) != nil, "not XML") |
no test coverage detected