Class BCUtil

    • 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 array
        supplied - second array
        Returns:
        true if arrays equal, false otherwise.