56 lines
1.5 KiB
Objective-C
56 lines
1.5 KiB
Objective-C
#import <Foundation/Foundation.h>
|
|
|
|
#import <Ably/ARTTypes.h>
|
|
#import <Ably/ARTStatus.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@protocol ARTCipherKeyCompatible <NSObject>
|
|
- (NSData *)toData;
|
|
@end
|
|
|
|
@interface NSString (ARTCipherKeyCompatible) <ARTCipherKeyCompatible>
|
|
- (NSData *)toData;
|
|
@end
|
|
|
|
@interface NSData (ARTCipherKeyCompatible) <ARTCipherKeyCompatible>
|
|
- (NSData *)toData;
|
|
@end
|
|
|
|
@class ARTCipherParams;
|
|
|
|
@protocol ARTCipherParamsCompatible <NSObject>
|
|
- (ARTCipherParams *)toCipherParams;
|
|
@end
|
|
|
|
@interface NSDictionary (ARTCipherParamsCompatible) <ARTCipherParamsCompatible>
|
|
- (ARTCipherParams *)toCipherParams;
|
|
@end
|
|
|
|
/**
|
|
ARTCipherParams contains configuration options for a channel cipher, including algorithm, mode, key length and key.
|
|
Ably client libraries currently support AES with CBC, PKCS#7 with a default key length of 256 bits. All implementations also support AES128.
|
|
*/
|
|
@interface ARTCipherParams : NSObject <ARTCipherParamsCompatible>
|
|
@property (readonly, strong, nonatomic) NSString *algorithm;
|
|
@property (readonly, strong, nonatomic) NSData *key;
|
|
@property (readonly, nonatomic) NSUInteger keyLength;
|
|
@property (readonly, getter=getMode) NSString *mode;
|
|
|
|
- (instancetype)init UNAVAILABLE_ATTRIBUTE;
|
|
- (instancetype)initWithAlgorithm:(NSString *)algorithm key:(id<ARTCipherKeyCompatible>)key;
|
|
|
|
- (ARTCipherParams *)toCipherParams;
|
|
|
|
@end
|
|
|
|
@interface ARTCrypto : NSObject
|
|
|
|
+ (ARTCipherParams *)getDefaultParams:(NSDictionary *)values;
|
|
+ (NSData *)generateRandomKey;
|
|
+ (NSData *)generateRandomKey:(NSUInteger)length;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|