Skip to content

Commit db438bf

Browse files
committed
Released iOS SDK Version 5.7.0
1 parent 296ac54 commit db438bf

8 files changed

Lines changed: 365 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
5.7.0 Release notes (2022-12-27)
2+
=============================================================
3+
4+
### Enhancements
5+
* Added Secure Enclave in the LoginRadius SDK to encrypt/decrypt sensitive data. For detailed information on Secure Enclave, please refer to the following document : https://support.apple.com/en-in/guide/security/sec59b0b31ff/web
6+
7+
18
5.6.2 Release notes (2022-08-29)
29
=============================================================
310

LoginRadiusSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'LoginRadiusSDK'
4-
s.version = '5.6.2'
4+
s.version = '5.7.0'
55
s.summary = 'Official LoginRadius SDK for iOS to integrate User Registration Service or Social Login in your app.'
66

77
s.description = <<-DESC

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ target 'TargetName' do
4848
4949
#Comment the next line if you don't want to use dynamic frameworks
5050
use_frameworks!
51-
pod 'LoginRadiusSDK', '~> 5.6.2'
51+
pod 'LoginRadiusSDK', '~> 5.7.0'
5252
end
5353
5454
```

Sources/LoginRadiusSDK.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#import "LoginRadiusSocialLoginManager.h"
99
#import "LRTouchIDAuth.h"
1010
#import "LRSession.h"
11+
#import "LoginRadiusEncryptor.h"
12+
1113

1214
static NSString * const LoginRadiusPlistFileName = @"LoginRadius";
1315
static NSString * const LoginRadiusAPIKey = @"apiKey";
@@ -17,6 +19,8 @@
1719
static NSString * const LoginRadiusVerificationUrl = @"verificationUrl";
1820
static NSString * const LoginRadiusKeychain = @"useKeychain";
1921
static NSString * const LoginRadiusCustomDomain = @"customDomain";
22+
static NSString * const LoginRadiusSetEncryption = @"setEncryption";
23+
2024

2125

2226
@interface LoginRadiusSDK ()
@@ -35,6 +39,10 @@ - (instancetype)init {
3539
NSString *siteName = values[LoginRadiusSiteName];
3640
NSString *verificationUrl = values[LoginRadiusVerificationUrl] ? values[LoginRadiusVerificationUrl] : @"https://auth.lrcontent.com/mobile/verification/index.html";
3741
BOOL useKeychain = values[LoginRadiusKeychain] ? [values[LoginRadiusKeychain] boolValue] : NO; // if nil set to false
42+
43+
BOOL setEncryption = values[LoginRadiusSetEncryption] ? [values[LoginRadiusSetEncryption] boolValue] : NO; // if nil set to false
44+
45+
3846
NSString *customDomain = values[LoginRadiusCustomDomain] ? values[LoginRadiusCustomDomain] : @"";
3947

4048
if([apiKey isEqualToString:@"<Your LoginRadius ApiKey>"] || [apiKey isEqualToString:@""]){
@@ -45,6 +53,16 @@ - (instancetype)init {
4553
NSAssert(apiKey, @"apiKey cannot be null in LoginRadius.plist");
4654
NSAssert(siteName, @"siteName cannot be null in LoginRadius.plist");
4755

56+
//apiKey is stored in secure enclave if setEncryption set to true in LoginRadius.plist .
57+
if(setEncryption == true){
58+
59+
NSData *key = [apiKey dataUsingEncoding:NSUTF8StringEncoding];
60+
NSData *decr = [[LoginRadiusEncryptor sharedInstance]EncryptDecryptText:key];
61+
62+
NSString *myString;
63+
myString = [[NSString alloc] initWithData:decr encoding:NSASCIIStringEncoding];
64+
}
65+
4866
if(!registrationSource){
4967
registrationSource = @"iOS";
5068
}
@@ -62,6 +80,7 @@ - (instancetype)init {
6280
_socialLoginManager = [[LoginRadiusSocialLoginManager alloc] init];
6381
_touchIDManager = [[LRTouchIDAuth alloc] init];
6482
_customHeaders = customHeaders;
83+
_setEncryption = setEncryption;
6584
}
6685

6786
return self;
@@ -82,6 +101,7 @@ + (instancetype)instance {
82101
return [[LoginRadiusSDK alloc] init];
83102
}
84103

104+
85105
+ (BOOL) logout {
86106

87107
BOOL is = [(LRSession *)[[self sharedInstance] session] logout];
@@ -115,16 +135,23 @@ + (NSString*) customDomain {
115135
+ (BOOL) useKeychain {
116136
return [LoginRadiusSDK sharedInstance].useKeychain;
117137
}
138+
139+
140+
118141
+ (NSDictionary*) customHeaders {
119142
return [LoginRadiusSDK sharedInstance].customHeaders;
120143
}
121144

145+
+ (BOOL) setEncryption {
146+
return [LoginRadiusSDK sharedInstance].setEncryption;
147+
}
122148

123149
#pragma mark Application Delegate methods
124150

125151
- (void)applicationLaunchedWithOptions:(NSDictionary *)launchOptions {
126152
[self.socialLoginManager applicationLaunchedWithOptions:launchOptions];
127153

154+
128155
}
129156

130157
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
@@ -135,4 +162,5 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
135162
- (void)applicationDidBecomeActive:(UIApplication *)application {
136163
}
137164

165+
138166
@end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// LoginRadiusEncryptor.h
3+
// Pods
4+
//
5+
// Created by Megha Agarwal on 01/12/22.
6+
//
7+
8+
9+
#import <Foundation/Foundation.h>
10+
#import "SecEnclaveWrapper.h"
11+
12+
@interface LoginRadiusEncryptor : NSObject
13+
14+
#pragma mark - LoginRadiusEncryptor Initilizers
15+
16+
+ (instancetype)sharedInstance;
17+
/**
18+
* Initializer
19+
* @return singleton instance
20+
*/
21+
-(NSData *_Nonnull)EncryptDecryptText:(NSData *_Nonnull)data ;
22+
23+
@end
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// LoginRadiusEncrcyptor.m
3+
// Pods
4+
//
5+
// Created by Megha Agarwal on 01/12/22.
6+
//
7+
8+
//
9+
// LoginRadiusEncryptor.m
10+
11+
#import "LoginRadiusEncryptor.h"
12+
#import "LoginRadiusSDK.h"
13+
14+
@implementation LoginRadiusEncryptor
15+
16+
+ (instancetype)sharedInstance {
17+
static dispatch_once_t onceToken;
18+
static LoginRadiusEncryptor *instance;
19+
20+
dispatch_once(&onceToken, ^{
21+
instance = [[LoginRadiusEncryptor alloc] init];
22+
});
23+
24+
return instance;
25+
}
26+
27+
- (NSData *)EncryptDecryptText:(NSData *)data {
28+
29+
//Encrypt the string.
30+
NSString *apikey = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
31+
32+
33+
34+
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
35+
NSString *strGroupID = [NSString stringWithFormat:@"group.%@",bundleIdentifier];
36+
37+
SecEnclaveWrapper *keychainItem = [[SecEnclaveWrapper alloc] init];
38+
39+
NSData *encrypted = [keychainItem encryptData:[apikey dataUsingEncoding:NSUTF8StringEncoding]];
40+
41+
NSString *strEncrypted = [[NSString alloc] initWithData:encrypted encoding:NSASCIIStringEncoding];
42+
43+
44+
45+
//Decrypt the string.
46+
NSData *decrypted =[keychainItem decryptData:encrypted];
47+
NSString *strDecrypted = [[NSString alloc] initWithData:decrypted encoding:NSUTF8StringEncoding];
48+
49+
NSData *stringData = [strDecrypted dataUsingEncoding:NSUTF8StringEncoding];
50+
return stringData;
51+
52+
}
53+
54+
@end
55+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// SecEnclaveWrapper.h
3+
// Pods
4+
//
5+
// Created by Megha Agarwal on 01/12/22.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
10+
11+
/**
12+
The SecEnclaveWrapper class is using SecureEnclave to generate keys and use them to encrypt/decrypt sensitive data.
13+
It is an abstraction layer for the iPhone Keychain communication and Secure Enclave.
14+
The SecureEnclave support is only available for iOS 10+.
15+
16+
*/
17+
18+
@interface SecEnclaveWrapper : NSObject
19+
//Return encrypted form of data
20+
- (NSData *_Nonnull)encryptData:(NSData *_Nonnull)data ;
21+
//Return decryrpted value of encrypted data
22+
- (NSData *_Nonnull)decryptData:(NSData *_Nonnull)data ;
23+
24+
25+
// @return an initialised instance.
26+
27+
- (instancetype _Nonnull )init;
28+
29+
/**
30+
Delete public key in the Keychain
31+
*/
32+
- (void) deletePubKey ;
33+
/**
34+
Delete prrivate key in the SecureEnclave
35+
*/
36+
- (void) deletePrivateKey ;
37+
38+
@end
39+

0 commit comments

Comments
 (0)