hohl / MIHCrypto

OpenSSL wrapper for Objective-C [cryptography]
MIT License
341 stars 68 forks source link

Help: I need to save the keypair somewhere to persist it #33

Closed Aleph72 closed 8 years ago

Aleph72 commented 8 years ago

Hello, I'm trying to use MIHCrypto and so far seems good for me. The only problem I'm having right now is saving the key pair somewhere. In my app I'm using an encrypted database, so my first thinking was saving there the keys. No problems with the public key, but when I try to save the private key it just does not work. I'm trying to save the 'privateKey.dataValue' to the DB but for some reasons it doesn't work. I've tried to save it as [NSKeyedArchiver archivedDataWithRootObject:privateKey] or [NSKeyedArchiver archivedDataWithRootObject:privateKey.dataValue], both with no success. the DB column type is blob. Any help would be greatly appreciated. Thanks.

hohl commented 8 years ago

[MIHRSAPrivateKey dataValue] and [MIHRSAPublicKey dataValue] just return an NSData instance which can be used to rebuild the key via [MIHRSAPrivateKey initWithData:] and [MIHRSAPublicKey initWithData:]. Everything else is up to you and without more details(/code) I can't help you any further.

Aleph72 commented 8 years ago

Never mind, I've finally been able to save it to the Keychain.

hohl commented 8 years ago

No problem. Hope you will find MIHCrypto useful.