Just curious, DataInput.readUTF() ?

Cantor, Scott cantor.2 at osu.edu
Thu Feb 26 18:32:16 EST 2015


On 2/26/15, 6:18 PM, "Tom Zeller" <tzeller at dragonacea.biz> wrote:

>As part of figuring out IDP-616, I see that the key used to seal data
>is determined by readUTF() :
>
> final String keyAlias = inputDataStream.readUTF();
>
>For my own education, I wondered how readUTF() returns the key from
>the wrapped data, and I just don't get it.

It's more helpful to read the wrap() method. The format of the data at the 
end is:

<keyname>|<IV>|<encrypted data>

The encrypted data contains the expiration plus the plaintext, and the 
keyname is input as what's called AEAD associated data, which means it's 
part of the MAC operation built into the GCM cipher. If you tamper with 
the key name in the final blob, it's detected by the decryption step 
because the MAC fails. GCM makes the whole thing very elegant.

-- Scott



More information about the dev mailing list