justinludwig / jpgpj

Java Pretty Good Privacy Jig
MIT License
74 stars 20 forks source link

Allow passphrases to be supplied as char arrays #20

Closed justinludwig closed 5 years ago

justinludwig commented 5 years ago

and to be zeroed after use; for #19

dtitov commented 5 years ago

Looks good to me! The only question is whether the char[] passphrase should be copied or set as is. As I see, currently it's set as is, which means that upon clearing we will clear the original array as well. That might be a bit unexpected if the user still needs this array for some reason in some other place... On the other hand, it's documented in the JavaDocs, so it should be an expected behavior. I'm a bit unsure what behavior would be better in this case...

justinludwig commented 5 years ago

Thanks for the feedback -- that's a good point about whether to copy the char[] or not -- I can definitely see an argument either way. I'm thinking it's probably better to err on the side of clearing too much rather than too little, though, and make users explicitly create a copy of the char[] themselves if they want to keep the passphrase around for use later.

I'll go ahead and merge this in and build a new release with it (call it 0.5) in a couple of days.