// AES-128-GCM test vectors for DomiStream (control frames and video packets), computed with .NET's AesGcm, a // crypto implementation independent of the RustCrypto crates DomiStream uses. // // Run by gen_vectors.py (`dotnet run gcm_vectors.cs -- `), never by hand. Input lines: // // Output lines: // <name> <ciphertext hex> <tag hex> // No associated data, 16-byte tags (docs/PROTOCOL.md 3.2 and 7). Keys are fixed test-only values. using System; using System.IO; using System.Security.Cryptography; using System.Text; var input = File.ReadAllLines(args[0]); var output = new StringBuilder(); foreach (var line in input) { if (line.Trim().Length == 0) continue; var parts = line.Split(' '); var key = Convert.FromHexString(parts[1]); var nonce = Convert.FromHexString(parts[2]); var plaintext = parts[3] == "-" ? Array.Empty<byte>() : Convert.FromHexString(parts[3]); var ciphertext = new byte[plaintext.Length]; var tag = new byte[16]; using var gcm = new AesGcm(key, 16); gcm.Encrypt(nonce, plaintext, ciphertext, tag); output.Append(parts[0]).Append(' ') .Append(ciphertext.Length == 0 ? "-" : Convert.ToHexString(ciphertext)).Append(' ') .Append(Convert.ToHexString(tag)).Append('\n'); } File.WriteAllText(args[1], output.ToString());