android icon indicating copy to clipboard operation
android copied to clipboard

How is the key zeroed out with JVM?

Open dorakas opened this issue 7 years ago • 2 comments

I would buy the Android app. But I would like to know how you kick the password out of ram. You have to wait that the garbage collector kicks in. Is the password stored as string or char[]

dorakas avatar Feb 22 '19 07:02 dorakas

We do our best to use char[] whenever possible (and of course wipe the data as soon as possible), however there are certain places where the use of a String is inevitable, mainly due to cryptomator/cryptomator#521, as passwords need to be normalized to produce a reliable input for the KDF.

To do so, we use the Normalizer, which accept any CharSequence (which can be a CharBuffer wrapped around a char[]) but produces a String:

Normalizer.normalize(passphrase, Form.NFC)

The produced string is immutable and therefore can not be wiped manually. I.e. it will remain in volatile memory until the JVM decides otherwise.

overheadhunter avatar Feb 22 '19 08:02 overheadhunter

Thx for the fast response

dorakas avatar Feb 22 '19 09:02 dorakas