|
@@ -54,17 +54,18 @@
|
|
|
|
|
|
- (BOOL)generatePushNotificationsKeyPair:(NSString *)account
|
|
|
{
|
|
|
- EVP_PKEY *pkey;
|
|
|
- NSError *keyError;
|
|
|
- pkey = [[NCEndToEndEncryption sharedManager] generateRSAKey:&keyError];
|
|
|
- if (keyError) {
|
|
|
- return NO;
|
|
|
- }
|
|
|
-
|
|
|
- // Extract publicKey, privateKey
|
|
|
int len;
|
|
|
char *keyBytes;
|
|
|
|
|
|
+ EVP_PKEY *pkey = EVP_PKEY_new();
|
|
|
+ BIGNUM *bigNumber = BN_new();
|
|
|
+ int exponent = RSA_F4;
|
|
|
+ RSA *rsa = RSA_new();
|
|
|
+
|
|
|
+ BN_set_word(bigNumber, exponent);
|
|
|
+ RSA_generate_key_ex(rsa, 2048, bigNumber, NULL);
|
|
|
+ EVP_PKEY_set1_RSA(pkey, rsa);
|
|
|
+
|
|
|
// PublicKey
|
|
|
BIO *publicKeyBIO = BIO_new(BIO_s_mem());
|
|
|
PEM_write_bio_PUBKEY(publicKeyBIO, pkey);
|
|
@@ -88,6 +89,8 @@
|
|
|
NSData *ncPNPrivateKey = [NSData dataWithBytes:keyBytes length:len];
|
|
|
[CCUtility setPushNotificationPrivateKey:account data:ncPNPrivateKey];
|
|
|
|
|
|
+ RSA_free(rsa);
|
|
|
+ BN_free(bigNumber);
|
|
|
EVP_PKEY_free(pkey);
|
|
|
|
|
|
return YES;
|