RSA/NONE/PKCS1Padding giving error as java.security.NoSuchAlgorithmException
16,120
Try "RSA/ECB/PKCS1Padding"
instead if you are running in an Oracle or Open JDK. It does not make too much sense to use a block cipher mode of encryption with RSA, but not all algorithm names are logical within the Java SE providers.
The Bouncy Castle Libraries support "RSA/None/PKCS1Padding"
though. So maybe the code was written for Bouncy or Android.
Author by
artofabhishek
Updated on June 26, 2022Comments
-
artofabhishek almost 2 years
I am using "RSA/None/PKCS1Padding" as :
Cipher RSACipher = Cipher.getInstance("RSA/None/PKCS1Padding");
This gives me exception as :
java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/None/PKCS1Padding
Thanks for help.
-
brady over 10 yearsIt isn't too sensible, but "RSA/ECB/PKCS1Padding" is the name specified by the Java Standard Algorithm Name documentation. It doesn't handle the v. 1.5 versus 2 padding ambiguity either.
-
Maarten Bodewes over 10 years@erickson Even worse, it does not accept data of over keysize - 88 bits either. So what ECB mode would that be?
-
artofabhishek over 10 yearsThanks Folks. after reading few more documentation here is what it solved.
Cipher RSACipher = Cipher.getInstance("RSA/None/PKCS1Padding"); // this should be PKCS1PADDING
OR just RSA asCipher RSACipher = Cipher.getInstance("RSA");
// default for "RSA/None/PKCS1PADDING" mentioned here : javadoc.iaik.tugraz.at/iaik_jce/current/iaik/pkcs/pkcs1/… -
Maarten Bodewes over 10 yearsThe Security architecture is case insensitive for algorithm names. Furthermore, you should always specify the mode and padding otherwise the provider may choose it's own defaults - and the defaults may differ for each provider. So what you wrote above is very dangerous.
-
artofabhishek over 10 yearsThanks, I'll provide provider name.