chacha20poly1305: add some more XChaCha20-Poly1305 test vectors.

These vectors were generated with libsodium to ensure that Go is
compatible with that library:

  #include <stdio.h>
  #include <sodium.h>
  #include <stdlib.h>

  static void hexdump(const uint8_t *in, size_t in_len) {
  	printf("\t\t\"");
  	for (size_t i = 0; i < in_len; i++) {
  		printf("%02x", in[i]);
  	}
  	printf("\",\n");
  }

  int main() {
  	uint8_t nonce[24];
  	uint8_t key[32];
  	uint8_t m[64], c[64+16];
  	uint8_t ad[16];

  	for (size_t ad_len = 0; ad_len < sizeof(ad); ad_len += 4) {
  		for (size_t m_len = 0; m_len < sizeof(m); m_len += 5) {
  			randombytes(nonce, sizeof(nonce));
  			randombytes(key, sizeof(key));
  			randombytes(m, m_len);
  			randombytes(ad, ad_len);

  			unsigned long long c_len = sizeof(c);
  			if (crypto_aead_xchacha20poly1305_ietf_encrypt(c, &c_len, m, m_len, ad, ad_len, NULL, nonce, key)) {
  				abort();
  			}

  			printf("\t{\n");
  			hexdump(m, m_len);
  			hexdump(ad, ad_len);
  			hexdump(key, sizeof(key));
  			hexdump(nonce, sizeof(nonce));
  			hexdump(c, c_len);
  			printf("\t},\n");
  		}
  	}

  	return 0;
  }

Change-Id: I4e9e4dc26e0e842c82319829599dbe48c331726f
Reviewed-on: https://go-review.googlesource.com/128615
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
1 file changed
tree: 81cb3ffba606ecc1d12fcb077993d31af92a4106
  1. acme/
  2. argon2/
  3. bcrypt/
  4. blake2b/
  5. blake2s/
  6. blowfish/
  7. bn256/
  8. cast5/
  9. chacha20poly1305/
  10. cryptobyte/
  11. curve25519/
  12. ed25519/
  13. hkdf/
  14. internal/
  15. md4/
  16. nacl/
  17. ocsp/
  18. openpgp/
  19. otr/
  20. pbkdf2/
  21. pkcs12/
  22. poly1305/
  23. ripemd160/
  24. salsa20/
  25. scrypt/
  26. sha3/
  27. ssh/
  28. tea/
  29. twofish/
  30. xtea/
  31. xts/
  32. .gitattributes
  33. .gitignore
  34. AUTHORS
  35. codereview.cfg
  36. CONTRIBUTING.md
  37. CONTRIBUTORS
  38. LICENSE
  39. PATENTS
  40. README.md
README.md

Go Cryptography

This repository holds supplementary Go cryptography libraries.

Download/Install

The easiest way to install is to run go get -u golang.org/x/crypto/.... You can also manually git clone the repository to $GOPATH/src/golang.org/x/crypto.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the crypto repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/crypto:” in the subject line, so it is easy to find.

Note that contributions to the cryptography package receive additional scrutiny due to their sensitive nature. Patches may take longer than normal to receive feedback.