Skip to content

Commit e7570ab

Browse files
committed
Add PublicKeyUtils.isEncryptionAlgorithm()
1 parent f0cd3da commit e7570ab

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

pg/src/main/java/org/bouncycastle/bcpg/PublicKeyUtils.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ public static boolean isSigningAlgorithm(int publicKeyAlgorithm)
3030
}
3131
}
3232

33-
// /**
34-
// * Return true, if the public key algorithm that corresponds to the given ID is capable of encryption.
35-
// * @param publicKeyAlgorithm public key algorithm id
36-
// * @return true if algorithm can encrypt
37-
// */
38-
// public static boolean isEncryptionAlgorithm(int publicKeyAlgorithm)
39-
// {
40-
// switch (publicKeyAlgorithm)
41-
// {
42-
// case PublicKeyAlgorithmTags.RSA_GENERAL:
43-
// case PublicKeyAlgorithmTags.RSA_ENCRYPT:
44-
// case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT:
45-
// case PublicKeyAlgorithmTags.ECDH:
46-
// case PublicKeyAlgorithmTags.ELGAMAL_GENERAL:
47-
// case PublicKeyAlgorithmTags.DIFFIE_HELLMAN:
48-
// case PublicKeyAlgorithmTags.X25519:
49-
// case PublicKeyAlgorithmTags.X448:
50-
// return true;
51-
// default:
52-
// return false;
53-
// }
54-
// }
33+
/**
34+
* Return true, if the public key algorithm that corresponds to the given ID is capable of encryption.
35+
* @param publicKeyAlgorithm public key algorithm id
36+
* @return true if algorithm can encrypt
37+
*/
38+
public static boolean isEncryptionAlgorithm(int publicKeyAlgorithm)
39+
{
40+
switch (publicKeyAlgorithm)
41+
{
42+
case PublicKeyAlgorithmTags.RSA_GENERAL:
43+
case PublicKeyAlgorithmTags.RSA_ENCRYPT:
44+
case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT:
45+
case PublicKeyAlgorithmTags.ECDH:
46+
case PublicKeyAlgorithmTags.ELGAMAL_GENERAL:
47+
case PublicKeyAlgorithmTags.DIFFIE_HELLMAN:
48+
case PublicKeyAlgorithmTags.X25519:
49+
case PublicKeyAlgorithmTags.X448:
50+
return true;
51+
default:
52+
return false;
53+
}
54+
}
5555
}

0 commit comments

Comments
 (0)