-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…rotection Implement SDL-0207 RPC Message Protection
- Loading branch information
Showing
53 changed files
with
1,300 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// SDLEncryptionConfiguration.h | ||
// SmartDeviceLink | ||
// | ||
// Created by standa1 on 6/17/19. | ||
// Copyright © 2019 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "SDLServiceEncryptionDelegate.h" | ||
|
||
@protocol SDLSecurityType; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SDLEncryptionConfiguration : NSObject <NSCopying> | ||
|
||
/** | ||
* A set of security managers used to encrypt traffic data. Each OEM has their own proprietary security manager. | ||
*/ | ||
@property (copy, nonatomic, nullable) NSArray<Class<SDLSecurityType>> *securityManagers; | ||
|
||
/** | ||
* A delegate callback that will tell you when an acknowledgement has occurred for starting as secure service. | ||
*/ | ||
@property (copy, nonatomic, nullable) id<SDLServiceEncryptionDelegate> delegate; | ||
|
||
/** | ||
* Creates a default encryption configuration. | ||
* | ||
* @return A default configuration that may be customized. | ||
*/ | ||
+ (instancetype)defaultConfiguration; | ||
|
||
/** | ||
Creates a secure configuration for each of the security managers provided. | ||
@param securityManagers The security managers to be used. | ||
@param delegate The delegate callback. | ||
@return The configuration | ||
*/ | ||
- (instancetype)initWithSecurityManagers:(nullable NSArray<Class<SDLSecurityType>> *)securityManagers delegate:(nullable id<SDLServiceEncryptionDelegate>)delegate; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// SDLEncryptionConfiguration.m | ||
// SmartDeviceLink | ||
// | ||
// Created by standa1 on 6/17/19. | ||
// Copyright © 2019 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import "SDLEncryptionConfiguration.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation SDLEncryptionConfiguration | ||
|
||
+ (instancetype)defaultConfiguration { | ||
return [[self.class alloc] initWithSecurityManagers:nil delegate:nil]; | ||
} | ||
|
||
- (instancetype)initWithSecurityManagers:(nullable NSArray<Class<SDLSecurityType>> *)securityManagers delegate:(nullable id<SDLServiceEncryptionDelegate>)delegate { | ||
self = [super init]; | ||
if (!self) { | ||
return nil; | ||
} | ||
|
||
_securityManagers = securityManagers; | ||
_delegate = delegate; | ||
|
||
return self; | ||
} | ||
|
||
#pragma mark - NSCopying | ||
|
||
- (id)copyWithZone:(nullable NSZone *)zone { | ||
SDLEncryptionConfiguration *newConfig = [[self.class allocWithZone:zone] init]; | ||
|
||
newConfig.securityManagers = self.securityManagers; | ||
newConfig.delegate = self.delegate; | ||
|
||
return newConfig; | ||
} | ||
|
||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// SDLEncryptionLifecycleManager.h | ||
// SmartDeviceLink | ||
// | ||
// Created by standa1 on 6/27/19. | ||
// Copyright © 2019 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "SDLConnectionManagerType.h" | ||
#import "SDLProtocolListener.h" | ||
|
||
@class SDLEncryptionConfiguration; | ||
@class SDLProtocol; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SDLEncryptionLifecycleManager : NSObject <SDLProtocolListener> | ||
|
||
/** | ||
* Whether or not the encryption session is connected. | ||
*/ | ||
@property (assign, nonatomic, readonly, getter=isEncryptionReady) BOOL encryptionReady; | ||
|
||
|
||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
/** | ||
Create a new encryption lifecycle manager for apps that need encryption. | ||
@param connectionManager The pass-through for RPCs | ||
@param configuration This session's configuration | ||
@return A new encryption lifecycle manager | ||
*/ | ||
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager configuration:(SDLEncryptionConfiguration *)configuration; | ||
|
||
/** | ||
* Start the manager. This is used internally to get notified of the ACK message. | ||
*/ | ||
- (void)startWithProtocol:(SDLProtocol *)protocol; | ||
|
||
/** | ||
* Stop the manager. This method is used internally. | ||
*/ | ||
- (void)stop; | ||
|
||
/** | ||
* Check whether or not an RPC needs encryption. | ||
*/ | ||
- (BOOL)rpcRequiresEncryption:(__kindof SDLRPCMessage *)rpc; | ||
|
||
/** | ||
* Attempt to manually start a secure service. | ||
*/ | ||
- (void)startEncryptionService; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.