tags:

views:

20

answers:

0

Hi All,

I am writing an iPhone Application which communicates with server for fetching some data. I need to implement Asymmetric Key Encryption in the project. In iPhone App I was able to implement the cryptographic methods both using openssl api's and apple's security framework api's. But when I get the public key from java server am unable to read it in iPhone.i.e am not able to encrypt data in iphone side using server's public key.

iPhone Code to read public key

 BIO *publicBIO = NULL;
 RSA *publicRSA = NULL;

   if(!(publicBIO = BIO_new_mem_buf((unsigned char*)[[self publicKey] bytes], [[self  publicKey] length])))
    {
        NSLog(@"BIO_new_mem_buf() failed!");
        return nil;
    }

    if(!PEM_read_bio_RSA_PUBKEY(publicBIO, &publicRSA, NULL, NULL))
    {
        NSLog(@"PEM_read_bio_RSA_PUBKEY() failed!");
        return nil;
    }

But my code fails at this line PEM_read_bio_RSA_PUBKEY

Also I tried the same with security framework At that time also am not able to get the rsa public key.

The man who did the server side says that he just created a rsa public key using kegenerator in java and encoding it using X509Encoding scheme.

So please tell me how to do this encryption stuff in iPhone with Java server or help me in correcting my code..

Thanks, Syam S NB:Sorry for my bad english..