# Currently i am doing decryption for RSA encoding and i face some problem with it [closed]

I am very new to cryptography so I don’t know much about it. I have been given a very large $N$ value and $E$ value to decrypt a ciphertext which was created using a AES 128 key and a IV by using RSA encoding scheme

N =
92001629535369949668182190680140710002429961412439471184834723194899969898404162
82428855806975402440064473888135838545187330646754494062187654035542047167435016
34608863342073173012508616123265965429721791336874605919036975439595316606713189
21259313523852555003517715050369476348174980850810194157624985747443

E = 65537


First I try to brute force attack but it would work,is it because the N value is too big? I found a solution, they say using ECB and PKCS5Padding but what I know ECB is divide the large amount of plaintext into block.

So here come my questions:

• Is there any related in RSA and ECB or the padding scheme?
• Is there possible to derive my AES key from the ciphertext given?

Because the key must use to other project

http://www.technology4freshers.com/2013_07_01_archive.html

the link here is the program I found online, I edit it a bit and I mange to get my decrypted file but how to find the key value for decryption?

Thank a lot to those who are willing guide me.

-

## closed as too broad by Maarten Bodewes, e-sushi♦, Ilmari Karonen, Dmitry Khovratovich, otusAug 10 '14 at 11:20

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.

(Naked decryption problems are against the TOS.) Brute force attacking 128 bits is computational infeasible. If this is some kind of homework problem, it could be you are intended to attack the ECB based on frequency analysis or knowledge of the structure of the plaintext. If its just some random block of data you want to decrypt, it's probably impossible. –  Jeff-Inventor ChromeOS Aug 10 '14 at 3:31
$\log_2(N)\approx 1023.034$. $\;$ Usual RSA key generation algorithms for 1024-bit $N$ generate $p$ and $q$ uniformly randomly in range $[2^{1023/2}\dots2^{1024/2}]$, and thus have odds of generating a $N=p\cdot q$ that close to $2^{1023}$ rather low (like 1/5000). In an exercise, that may not be a coincidence. Perhaps this hints at some way to factor $N$. Any context, like: a recent/related lesson/text was about Fermat factoring? –  fgrieu Aug 11 '14 at 8:20

I don't think you will be able to "brute force" decrypt your data. The AES key and IV a probably chosen randomly to encrypt the actual data using some encryption mode. As there is an IV, as you state, it will not be ECB but probably CBC.

To get the AES key and IV you need to know the RSA private key D. If the the RSA key pair is chosen carefully, you are not able to calculate it, having N and the public RSA key E.

This kind of encryption, e.g. as used in PGP, works as follows. You have an RSA public key of the recipient. Choosing a random AES key/IV to encrypt the data these values are then encrypted for the recipient using his RSA public key (E and N). The recipient is then able to decrypt the randomly chosen AES Key/IV using his RSA private key.

After a quick check of the link, it seems that this code does not use RSA. It converts a string into bytes used as key (this is really bad and even hard-coded). Brute Forcing the AES encryption will probably be useless, if the AES key is really randomly chosen.

Please check the information as it does not fit (ECB - IV - Padding - RSA etc.).

Update: The Code you referred to will encrypt the data using a hardcoded string as key and applying DES-ECB encryption to the file: DO NOT USE THAT !

-
but if I change my code to ("RSA/ECB/PKCS5Padding","key_enc.txt"), it give me this Exception in thread "main" java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/ECB/PKCS5Padding –  Shinji Kagawa Aug 9 '14 at 16:48
You need to check which Cipher/Padding combinations are supported by your JDK/library. But again, it will not be that easy, as I described above. I would advise to search for Java RSA encryption and get familiar with symmetric and asymmetric encryption, and its pitfalls. To get an idea: javadigest.wordpress.com/2012/08/26/rsa-encryption-example –  Thor Aug 9 '14 at 17:11
Write a program to attack the Textbook RSA Encryption Scheme in order to decrypt the encrypted file key_enc.txt which contains the 128 bits AES secret key together with the initialisation vector (IV) for Question 2. You must explain and show how the attack is done. –  Shinji Kagawa Aug 10 '14 at 13:19
actually this the question, ihave been search for some RSA , they suggest to use PKCS5 because it have key derivation ,so how bout the difference between KeyGenerator,KeyPairGenerator and KeyPair? docjar.org/docs/api/javax/crypto/Cipher.html >>the link i found, but the link suggest to use RSA/ECB/PKCS1Padding (1024, 2048), can you give some direction of it ？ because i found many java program in google,i start confuse now –  Shinji Kagawa Aug 10 '14 at 13:24
Textbook RSA is the clue. See here: crypto.stackexchange.com/questions/1448/… –  Thor Aug 10 '14 at 18:50