I am inspecting the behavior of our java application with respect to jsse tls encryption and decryption with a connected openssl client.
First I observed that when I call unwrap for client data, it always unwraps consuming 37 bytes and producing 0. The next unwrap consumes some bytes and produces some.
At first I thought the client would wrap an empty array first. But then I discovered that the jsse code does the same, except it produces 1 byte instead of 0.
So every call to a wrap
consumes X bytes and produces Y bytes but requires TWO unwrap
s while the first one consumes 37 bytes and produces 1 byte and the second one consumes Y-37 bytes and produces X-1 bytes.
While openssl and jsse are doing nearly the same, I expect that to be correct. However I would like to know, why that happens. I don't see a reason for that and it takes additional resources...?