RSA Encryption in Objective-C (Mac)

I am hacking things that require RSA encryption, and I have code that looks like this:

- (NSData *)RSAEncryptData:(NSData *)data {

    NSMutableData * encrypted = [NSMutableData dataWithLength:256];

    RSA * rsa = RSA_new();
    rsa->n = BN_bin2bn(modulus.bytes, modulus.length, NULL);
    rsa->e = BN_bin2bn(exponent.bytes, exponent.length, NULL);

    RSA_public_encrypt(data.length, data.bytes, encrypted.mutableBytes, rsa, RSA_PKCS1_OAEP_PADDING);
    RSA_free(rsa);
    return encrypted;

}

Where the module and exhibitors are objects NSData.

This works great, except for all RSA methods, to make the compiler whine at me about how old they were in Mac OS 10.7.

Is there a more modern way that I have to do this? I worked at Googling several times and could only find iOS stuff that is not available on Mac ( SecKeyEncryptetc.).

To be absolutely clear, I'm not looking for an iOS solution, I'm looking for Mac OS.

+5
source share
3 answers

Per WWDC 2011, OpenSSL Mac OS X 10.7 , OpenSSL .

RSA OpenSSL. . , , ; . , , , libcrypto RSA.

+6

this? , , , , , , .

+1

You can check it out if that helps.

https://github.com/skomik/RSAUtility

0
source

All Articles