Debian Codegraph @

age/internal/tests/hybrid_currupted_enc_mlkem.go

raw symbols SCIP
1 // Copyright 2022 The age Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build ignore
6 // +build ignore
7
8 package main
9
10 import (
11 "encoding/base64"
12
13 "c2sp.org/CCTV/age/internal/testkit"
14 "golang.org/x/crypto/curve25519"
15 )
16
17 func main() {
18 f := testkit.NewTestFile()
19 f.VersionLine("v1")
20 share, _ := curve25519.X25519(f.Rand(32), curve25519.Basepoint)
21 f.HybridRecordIdentity(testkit.TestHybridIdentity)
22 f.HybridStanza(share, f.Rand(32), testkit.TestHybridIdentity)
23 body, args := f.UnreadLine(), f.UnreadArgsLine()
24 enc, _ := base64.RawStdEncoding.DecodeString(args[1])
25 enc[0] ^= 0xff
26 f.TextLine("-> mlkem768x25519 " + base64.RawStdEncoding.EncodeToString(enc))
27 f.TextLine(body)
28 f.HMAC()
29 f.Payload("age")
30 f.ExpectNoMatch()
31 f.Comment("the ML-KEM part of enc is corrupted")
32 f.Generate()
33 }