ios - Objective-C with OpenSSL - Cannot set RSA Key -


i trying use add rsa encryption app using openssl, cannot certificate load. in app, public key certificate distributed server , need take key , use decrypt content encrypted barcodes app scan.

the reason why choosing openssl on security library require ecdsa validation, unsupported natively.

i have tried numerous methods key load. openssl pem_read_rsa_pubkey method requires file pointer. when run code below, crashes exc_bad_access attempt access key.

nsstring * path = [[nsbundle mainbundle] pathforresource:  @"public" oftype: @"pem"]; file *f = fopen([path cstringusingencoding:1],"r"); if (f == null)     nslog(@"%@", [path stringbyappendingstring:@" not found"]);  rsa *rsa = pem_read_rsa_pubkey(f,null,null,null);  fclose(f);  nslog (@"%d keycheck", rsa_check_key(rsa)); 

i have included following headers openssl library

#include <openssl/opensslv.h> #include <openssl/crypto.h> #include <openssl/rsa.h> #include <openssl/pem.h> 

i have other openssl methods such md5, base64 encode/decode, sha1 , ecdsa code working ok, it's passing in rsa certificate has got me stumped!

the public.pem key file contains key:

-----begin public key----- migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqc+ynz7evj0f+iogmlme/j/mph4 7bxriudtjcos99j82il3ww9ubm28yomhypdi23wpdhr80ugabwanmquzwvykjqd4 z4d0sj0nvw3ddgz4gs57zfqlvggdvhzavimfs7qdxij1o8gmuxwsezv2zpmijdnf zbol5zztqnfk89rnnqidaqab -----end public key----- 

your program read rsa public key fine.

problem with

rsa_check_key 

please read rsa_check_key here.

it not work on public key. need private key function. why crashing since have private key. sorry inconvenience due previous answers.

http://www.openssl.org/docs/crypto/rsa_check_key.html


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -