A question about modifying the buffer under authenticated encryption
Subsystems (2)
Mikulas Patocka
maintainerHi
I'm trying to fix some problems in dm-crypt that it may report authentication failures when the user reads data with O_DIRECT and modifies the read buffer while it is being read.
I'd like to ask you:
1. If the authenticated encryption encrypts a message, reading from buffer1 and writing to buffer2 - and buffer1 changes while reading from it - is it possible that it generates invalid authentication tag?
2. If the authenticated encryption decrypts a message, reading from buffer1 and writing to buffer2 - and buffer2 changes while writing to it - is is possible that it reports authentication tag mismatch?
Mikulas
Quoted 8 lines · Mikulas Patocka
Hi
I'm trying to fix some problems in dm-crypt that it may report authentication failures when the user reads data with
O_DIRECTand modifies the read buffer while it is being read.I'd like to ask you:
Quoted 8 lines
1. If the authenticated encryption encrypts a message, reading from buffer1 and writing to buffer2 - and buffer1 changes while reading from it - is it possible that it generates invalid authentication tag?
2. If the authenticated encryption decrypts a message, reading from buffer1 and writing to buffer2 - and buffer2 changes while writing to it - is is possible that it reports authentication tag mismatch?
Yes, both scenarios are possible. But it depends on the AEAD algorithm and how it happens to be implemented, and on whether the data overlaps or not.
This is very much a "don't do that" sort of thing.
- Eric
Mikulas Patocka
maintainerQuoted 18 lines · Eric Biggers
Quoted 8 lines · Mikulas Patocka
Hi
I'm trying to fix some problems in dm-crypt that it may report authentication failures when the user reads data with
O_DIRECTand modifies the read buffer while it is being read.I'd like to ask you:
Quoted 8 lines
1. If the authenticated encryption encrypts a message, reading from buffer1 and writing to buffer2 - and buffer1 changes while reading from it - is it possible that it generates invalid authentication tag?
2. If the authenticated encryption decrypts a message, reading from buffer1 and writing to buffer2 - and buffer2 changes while writing to it - is is possible that it reports authentication tag mismatch?
Quoted 6 lines
Yes, both scenarios are possible. But it depends on the AEAD algorithm and how it happens to be implemented, and on whether the data overlaps or not.
This is very much a "don't do that" sort of thing.
- Eric
I see. So I will copy the data to a kernel buffer before encryption or decryption.
I assume that authenticated encryption or decryption using the same buffer as a source and as a destination should be ok. Right?
Mikulas
Herbert Xu
maintainerQuoted 3 lines · Mikulas Patocka
I assume that authenticated encryption or decryption using the same buffer as a source and as a destination should be ok. Right?
Yes, in-place encryption and decryption is OK.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 27 lines · Mikulas Patocka
Quoted 23 lines · Eric Biggers
Quoted 8 lines · Mikulas Patocka
Hi
I'm trying to fix some problems in dm-crypt that it may report authentication failures when the user reads data with
O_DIRECTand modifies the read buffer while it is being read.I'd like to ask you:
Quoted 8 lines
1. If the authenticated encryption encrypts a message, reading from buffer1 and writing to buffer2 - and buffer1 changes while reading from it - is it possible that it generates invalid authentication tag?
2. If the authenticated encryption decrypts a message, reading from buffer1 and writing to buffer2 - and buffer2 changes while writing to it - is is possible that it reports authentication tag mismatch?
Yes, both scenarios are possible. But it depends on the AEAD algorithm and how it happens to be implemented, and on whether the data overlaps or not.
This is very much a "don't do that" sort of thing.
Quoted 8 lines
Quoted 1 line
- Eric
I see. So I will copy the data to a kernel buffer before encryption or decryption.
I assume that authenticated encryption or decryption using the same buffer as a source and as a destination should be ok. Right?
The crypto_aead API allows the source and destination to overlap, yes.
- Eric
Herbert Xu
maintainerQuoted 2 lines · Eric Biggers
The
crypto_aeadAPI allows the source and destination to overlap, yes.
I would prefer to call it in-place rather than overlapping, because the following is certainly not supported:
encrypt(src: A, dst: A + 16, len: 160)
Just in case someone gets any funny ideas about the API :)
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt