On Wed, Feb 05, 2020 at 04:48:16PM +0200, Gilad Ben-Yossef wrote: > Probably another issue with my driver, but just in case - > include/crypot/aead.h says: > > * The scatter list pointing to the input data must contain: > * > * * for RFC4106 ciphers, the concatenation of > * associated authentication data || IV || plaintext or ciphertext. Note, the > * same IV (buffer) is also set with the aead_request_set_crypt call. Note, > * the API call of aead_request_set_ad must provide the length of the AAD and > * the IV. The API call of aead_request_set_crypt only points to the size of > * the input plaintext or ciphertext. > > I seem to be missing the place where this is handled in > generate_random_aead_testvec() > and generate_aead_message() > > We seem to be generating a random IV for providing as the parameter to > aead_request_set_crypt() > but than have other random bytes set in aead_request_set_ad() - or am > I'm missing something again? Yes, for rfc4106 the tests don't pass the same IV in both places. This is because I wrote the tests from the perspective of a generic AEAD that doesn't have this weird IV quirk, and then I added the minimum quirks to get the weird algorithms like rfc4106 passing. Since the actual behavior of the generic implementation of rfc4106 is that the last 8 bytes of the AAD are ignored, that means that currently the tests just avoid mutating these bytes when generating inauthentic input tests. They don't know that they're (apparently) meant to be another copy of the IV. So it seems we need to clearly define the behavior when the two IV copies don't match. Should one or the other be used, should an error be returned, or should the behavior be unspecified (in which case the tests would need to be updated)? Unspecified behavior is bad, but it would be easiest for software to use req->iv, while hardware might want to use the IV in the scatterlist... Herbert and Stephan, any idea what was intended here? - Eric