# use nonce, write data if given, encrypt plaintext if given, append ciphertext and auth to dst if given and return it.gcm.Seal(dst, nonce, plaintext, data []byte) (ciphertextPlusAuth []byte)# use nonce, write data if given, verify auth, decrypt ciphertext if given, append plaintext to dst if given and return it.gcm.Open(dst, nonce, ciphertextPlusAuth, data []byte) (plaintext []byte, err error)
# authenticate additional data and update the sum (optional)Write(data []byte)# encrypt the plaintext to ciphertext and update the sum (optional)Encrypt(ciphertext, plaintext []byte)# append the current authentication sum and return itSum(auth []byte) []byte# decrypt the ciphertext to plaintext and update the sum (optional)Decrypt(plaintext, ciphertext []byte)# verify current authentication sum matches the given oneVerify(auth []byte) err
benchmark old ns/op new ns/op deltaBenchmarkAESGCMEncrypt1K 17379 5471 -68.52%BenchmarkAESGCMDecrypt1K 17341 5466 -68.48%BenchmarkAESGCMWrite1K 14171 3115 -78.02%benchmark old MB/s new MB/s speedupBenchmarkAESGCMEncrypt1K 58.92 187.16 3.18xBenchmarkAESGCMDecrypt1K 59.05 187.32 3.17xBenchmarkAESGCMWrite1K 72.26 328.72 4.55x
benchmark old ns/op new ns/op deltaBenchmarkAESGCMEncrypt1K 17379 15613 -10.16%BenchmarkAESGCMDecrypt1K 17341 15648 -9.76%BenchmarkAESGCMWrite1K 14171 13238 -6.58%benchmark old MB/s new MB/s speedupBenchmarkAESGCMEncrypt1K 58.92 65.58 1.11xBenchmarkAESGCMDecrypt1K 59.05 65.44 1.11xBenchmarkAESGCMWrite1K 72.26 77.35 1.07x
--
---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I was not.
I guess that means making a compatibility wrapper for cipher but recommending the new package instead.
Alternatively, I could keep the old api but would have to remove streaming and variable length tag support.
I have no idea about the licensing implications. It does seem odd that Intel would publish 10+ implementations as a white paper but prohibit their usage. Let me know if we can't use this and I can re-implement, maybe even make it faster.
My views on Verify is that it's akin to never reusing the same key/IV pair. It's stated as requirement in the documentation and examples but is never enforced for the sake of compatibility (?). Failing to use Verify downgrades GCM to CTR, but may be worth the risk to provide a better API in other areas. Failing to use a unique key/iv pair, on the other hand, completely breaks security...
The GCM spec says the tag length is variable, while TLS forces it to be 16 bytes. GCM is used outside of TLS and variable length tags are useful when bytes matter.
My biggest gripe with the current API is the way the authentication tag is appended to the ciphertext. It's not part of the spec, so for compatibility you have to append or slice the last 16 bytes. The API uses append so it will make a full copy unless dst has the capacity for these extra 16 bytes, which is often not true if you're trying to reuse a buffer. And of course it prevents variable length tags. Nothing is a deal breaker, it's just particularly cumbersome and shouldn't be the official API.
An alternate solution could be to make the tag a separate argument and not use append:
Seal(ciphertextDst, nonce, plaintext, data []byte) (auth []byte)
Open(plaintextDst, nonce, ciphertext, auth, data []byte) (error err)
But it's still a C API, and not something you'd expect to see in Go.
And thanks so much AGL for the original implementation. I went into this with just the intention of improving performance, but maybe got a little carried away trying to improve everything.