rakuten / as3crypto

Automatically exported from code.google.com/p/as3crypto
0 stars 1 forks source link

PKCS#1 unpad: i=0, expected b[i]==2, got b[i]=3b Error: Decrypt error - padding function returned null! #64

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Step encrypt
   var rsa:RSAKey = RSAKey.generate(256, "10001");
   // same lame smoke test here.
   var txt:String = "hello";
   var src:ByteArray = Hex.toArray(Hex.fromString(txt));
   var dst:ByteArray = new ByteArray;
   var dst2:ByteArray = new ByteArray;
   rsa.encrypt(src, dst, src.length);
   var txt1:String = Hex.toString(Hex.fromArray(dst));
   trace(":::::::::::::::::::::: txt1:" + txt1);

2. Step decrypt from txt1, convert txt1 to ByteArray
   var src2:ByteArray = Hex.toArray(Hex.fromString(txt1)); 
   trace(":::::::::::::::::::::: src2:" + src2);  

   rsa.decrypt(src2, dst2, src2.length);
   var txt2:String = Hex.toString(Hex.fromArray(dst2));
   trace(":::::::::::::::::::::: txt2:" + txt2);

3. Output unwanted!!!
:::::::::::::::::::::: txt1:;ÏÐFóON_¼j’ãXƒ
¶àù ;ÿÐ+³¸ Ç
:::::::::::::::::::::: src2:;ÏÐFóON_¼j’ãXƒ
¶àù ;ÿÐ+³¸ Ç
PKCS#1 unpad: i=0, expected b[i]==2, got b[i]=3b
Error: Decrypt error - padding function returned null!
    at com.hurlant.crypto.rsa::RSAKey/_decrypt()
    at com.hurlant.crypto.rsa::RSAKey/decrypt()
    at Form::MainForm/testGenerate()
    at Form::MainForm/initialize()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

- What is the expected output? 
   :::::::::::::::::::::: txt2:hello

- What version of the product are you using?  Update from SVN: svn checkout 
http://as3crypto.googlecode.com/svn/trunk/ as3crypto-read-only

- On what operating system? 
   Windown 7
*******************************************************************
Please help me!!! I find that many such cases, but do not have a fix.
Thank you for advance!!!

Original issue reported on code.google.com by c0508...@gmail.com on 7 Jul 2011 at 2:49

GoogleCodeExporter commented 9 years ago
I do not know how the process:
- Send keyPublic/keyPrivate ,send the encrypted string between Client/Server 
(Java). All the tests were conducted at the Client (AS3) but when working with 
Server, I do not know.
Hope to receive examples of this!!!
Thank you for advance!!!

Original comment by c0508...@gmail.com on 7 Jul 2011 at 4:32