Package org.pgpainless.util
Class BCUtil
- java.lang.Object
-
- org.pgpainless.util.BCUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
constantTimeAreEqual(char[] expected, char[] supplied)
A constant time equals comparison - does not terminate early if test will fail.static int
getBitStrength(org.bouncycastle.openpgp.PGPPublicKey key)
Utility method to get the bit strength of OpenPGP keys.
-
-
-
Method Detail
-
getBitStrength
public static int getBitStrength(org.bouncycastle.openpgp.PGPPublicKey key) throws NoSuchAlgorithmException
Utility method to get the bit strength of OpenPGP keys. Bouncycastle is lacking support for some keys (eg. EdDSA, X25519), so this method manually derives the bit strength from the keys curves OID.- Parameters:
key
- key- Returns:
- bit strength
- Throws:
NoSuchAlgorithmException
-
constantTimeAreEqual
public static boolean constantTimeAreEqual(char[] expected, char[] supplied)
A constant time equals comparison - does not terminate early if test will fail. For best results always pass the expected value as the first parameter.- Parameters:
expected
- first arraysupplied
- second array- Returns:
- true if arrays equal, false otherwise.
-
-