/* SPDX-License-Identifier: GPL-2.0 OR MIT * * Copyright (C) 2015-2018 Jason A. Donenfeld . All Rights Reserved. */ #ifdef DEBUG struct chacha20_testvec { const u8 *input, *output, *key; u64 nonce; size_t ilen; }; /* * #!/usr/bin/env python3 * * import chacha20 * import os * import struct * * def encode_blob(blob): * a = "" * x = 0 * for i in blob: * a += ('0x%02x' % i) + "," * x += 1 * if x % 8 == 0: * a += "\n\t\t " * else: * a += " " * if x % 8 == 0: * return a[:len(a) - 8] * return a[:len(a) - 2] * * enc = [ ] * dec = [ ] * * def make_vector(plen): * key = os.urandom(32) * nonce = os.urandom(8) * p = os.urandom(plen) * c = chacha20.chacha20_encrypt(p, key, nonce) * * out = "{\n" * out += "\t.key\t= { " + encode_blob(key) + " },\n" * out += "\t.nonce\t= " + hex(struct.unpack("