marinofaggiana 5 years ago
parent
commit
e54830dd3c

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -3128,7 +3128,7 @@
         
         if (jsongParsed && jsongParsed.allKeys > 0) {
             
-            BOOL wipe = [jsongParsed valueForKey:@"wipe"];
+            BOOL wipe = (BOOL)[jsongParsed valueForKey:@"wipe"];
             successRequest(response, wipe, request.redirectedServer);
             
         } else {

+ 0 - 1
iOSClient/Security/NCEndToEndEncryption.h

@@ -43,7 +43,6 @@
 - (BOOL)encryptFileName:(NSString *)fileName fileNameIdentifier:(NSString *)fileNameIdentifier directory:(NSString *)directory key:(NSString **)key initializationVector:(NSString **)initializationVector authenticationTag:(NSString **)authenticationTag;
 - (BOOL)decryptFileName:(NSString *)fileName fileNameView:(NSString *)fileNameView ocId:(NSString *)ocId key:(NSString *)key initializationVector:(NSString *)initializationVector authenticationTag:(NSString *)authenticationTag;
 
-- (EVP_PKEY *)generateRSAKey:(NSError **)error;
 - (NSData *)generateKey:(int)length;
 - (NSString *)createSHA512:(NSString *)string;
 

+ 4 - 2
iOSClient/Security/NCEndToEndEncryption.m

@@ -95,8 +95,10 @@
     
     ASN1_INTEGER_set(X509_get_serialNumber(x509), 1);
     
-    X509_gmtime_adj(X509_get_notBefore(x509), 0);
-    X509_gmtime_adj(X509_get_notAfter(x509), 31536000000L);
+    long notBefore = [[NSDate date] timeIntervalSinceDate:[NSDate date]];
+    long notAfter = [[[NSDate date] dateByAddingTimeInterval:60*60*24*365*10] timeIntervalSinceDate:[NSDate date]]; // 10 year
+    X509_gmtime_adj(X509_get_notBefore(x509), notBefore);
+    X509_gmtime_adj(X509_get_notAfter(x509), notAfter);
     
     X509_set_pubkey(x509, pkey);
     

+ 11 - 8
iOSClient/Security/NCPushNotificationEncryption.m

@@ -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;