Skip to content

Commit b70137e

Browse files
committed
pg: say in the javadoc of OpenPGPKeyGenerator.build(char[]) that it zeroizes the array it is passed, the one place in the API that clears a caller's.
1 parent 2a003fa commit b70137e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKeyGenerator.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,13 @@ public OpenPGPKey build()
707707
/**
708708
* Build the {@link PGPSecretKeyRing OpenPGP key} using a single passphrase used to protect all subkeys.
709709
* The passphrase will override whichever key protectors were specified in previous builder steps.
710+
* <p>
711+
* The array passed in is zeroized once the key has been generated, so a caller that needs to keep
712+
* the passphrase - to generate a second key with it, say - must pass a clone. This is the one place
713+
* in the API that clears a caller's array; a {@code KeyPassphraseProvider} keeps ownership of what
714+
* it hands out (see {@link KeyPassphraseProvider#getKeyPassword}).
710715
*
711-
* @param passphrase nullable passphrase
716+
* @param passphrase nullable passphrase, zeroized before this method returns
712717
* @return OpenPGP key
713718
* @throws PGPException if the key cannot be generated
714719
*/

0 commit comments

Comments
 (0)