Hi Jim,

I copied your code into a project and pulled in the latest As3Crypto
source.  Your project compiled and worked as expected.  I was unable
to replicate the error, and would assume it's an environment issue.

-Nick Matelli

--- In flexcoders@yahoogroups.com, "Jim Boone" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> I posted this on the As3Crypto discussion list but there is very
> little activity there.  Maybe someone in this group has encrypted
> something using an RSA public key that they might share.
> 
> I am trying to read a RSA public key so I can encrypt data in my
> application. I assembled a test app just to learn how the library
> works. Unfortunately, I didn't get very far. I get the message "I DONT
> KNOW HOW TO HANDLE DER stuff of TYPE 1" when I try to run the
> following code. I have downloaded the latest source from trunk but I
> still get the error. I generated the private and public keys using
> openssl as shown below:
> 
> openssl genrsa -out private.pem 1024
> openssl rsa -in private.pem -pubout -out public.pem
> 
> Any clue what is happening here?
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute" creationComplete="init()">
> 
>         <mx:Script>
>                 <![CDATA[
>                         import com.hurlant.util.Hex;
>                         import com.hurlant.util.der.PEM;
>                         import com.hurlant.crypto.rsa.RSAKey;
> 
>                         private var publicKey:String = "-----BEGIN
> PUBLIC KEY-----"+
>                        
> "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq63UvOM+wA3FYLl7X5v5US1bd"+
>                        
> "BP43wScM3boptegIIIO0ghhzhtmCUv7/278Jow9xI/za0CTf8DL9pSDu8+T+RY7U"+
>                        
> "WOMaX/IK9D9tqxztDdPu29qSJFenun1O9OL+HaUYaNWSTLirHMZN67/aITtuyV6+"+
>                         "ikAJfa9EOKAnT/CLIQIDAQAB"+
>                         "-----END PUBLIC KEY-----";
> 
>                         private function init():void
>                         {
>                                 var rsaPublicKey:RSAKey =
> PEM.readRSAPublicKey(publicKey);
> 
>                                 var message:ByteArray =
> Hex.toArray("now listen to this");
>                                 var encryptedMessage:ByteArray = new
> ByteArray;
>                                
> rsaPublicKey.encrypt(message,encryptedMessage,message.length);
> 
>                                 trace(Hex.fromArray(encryptedMessage));
>                         }
>                 ]]>
>         </mx:Script>
> </mx:Application>
> 
> ~~~~~~~ Error ~~~~~~~~~~~~~~
> 
> I DONT KNOW HOW TO HANDLE DER stuff of TYPE 1
> Error: Error #2030: End of file was encountered.
>         at flash.utils::ByteArray/readBytes()
>         at
> com.hurlant.util.der::DER$/parse()[C:\flex\crypto_1.3\com\hurlant
> \util\der\DER.as:134]
>         at com.hurlant.util.der::PEM$/readRSAPublicKey()[C:\flex
> \crypto_1.3\com\hurlant\util\der\PEM.as:84]
>         at
> Test/init()[C:\flex\workspaces\smtoolsPrototype\Test\src\Test.mxml:
> 28]
> 
> ~Jim
>


Reply via email to