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.

Share:
16,120
artofabhishek
Author by

artofabhishek

Updated on June 26, 2022

Comments

  • artofabhishek
    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
    brady over 10 years
    It 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
    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
    artofabhishek over 10 years
    Thanks 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 as Cipher RSACipher = Cipher.getInstance("RSA"); // default for "RSA/None/PKCS1PADDING" mentioned here : javadoc.iaik.tugraz.at/iaik_jce/current/iaik/pkcs/pkcs1/…
  • Maarten Bodewes
    Maarten Bodewes over 10 years
    The 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
    artofabhishek over 10 years
    Thanks, I'll provide provider name.