Fix and clean up redundant nullability specifiers

This commit is contained in:
Davide De Rosa 2018-09-12 15:24:14 +02:00
parent a3fe740ad9
commit aef7daec51
12 changed files with 79 additions and 54 deletions

View File

@ -45,13 +45,13 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) int extraLength; @property (nonatomic, assign) int extraLength;
- (instancetype)initWithCipherName:(nonnull NSString *)cipherName; - (instancetype)initWithCipherName:(NSString *)cipherName;
@end @end
@interface DataPathCryptoAEAD : NSObject <DataPathEncrypter, DataPathDecrypter> @interface DataPathCryptoAEAD : NSObject <DataPathEncrypter, DataPathDecrypter>
- (instancetype)initWithCrypto:(nonnull CryptoAEAD *)crypto; - (instancetype)initWithCrypto:(CryptoAEAD *)crypto;
@end @end

View File

@ -115,7 +115,7 @@ const NSInteger CryptoAEADTagLength = 16;
[self prepareIV:self.cipherIVEnc withHMACKey:hmacKey]; [self prepareIV:self.cipherIVEnc withHMACKey:hmacKey];
} }
- (NSData *)encryptData:(NSData *)data offset:(NSInteger)offset extra:(nonnull const uint8_t *)extra error:(NSError *__autoreleasing *)error - (NSData *)encryptData:(NSData *)data offset:(NSInteger)offset extra:(const uint8_t *)extra error:(NSError *__autoreleasing *)error
{ {
NSParameterAssert(data); NSParameterAssert(data);
NSParameterAssert(extra); NSParameterAssert(extra);
@ -133,7 +133,7 @@ const NSInteger CryptoAEADTagLength = 16;
return dest; return dest;
} }
- (BOOL)encryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(nonnull const uint8_t *)extra error:(NSError *__autoreleasing *)error - (BOOL)encryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(const uint8_t *)extra error:(NSError *__autoreleasing *)error
{ {
NSParameterAssert(extra); NSParameterAssert(extra);
@ -179,7 +179,7 @@ const NSInteger CryptoAEADTagLength = 16;
[self prepareIV:self.cipherIVDec withHMACKey:hmacKey]; [self prepareIV:self.cipherIVDec withHMACKey:hmacKey];
} }
- (NSData *)decryptData:(NSData *)data offset:(NSInteger)offset extra:(nonnull const uint8_t *)extra error:(NSError *__autoreleasing *)error - (NSData *)decryptData:(NSData *)data offset:(NSInteger)offset extra:(const uint8_t *)extra error:(NSError *__autoreleasing *)error
{ {
NSParameterAssert(data); NSParameterAssert(data);
NSParameterAssert(extra); NSParameterAssert(extra);
@ -197,7 +197,7 @@ const NSInteger CryptoAEADTagLength = 16;
return dest; return dest;
} }
- (BOOL)decryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(nonnull const uint8_t *)extra error:(NSError *__autoreleasing *)error - (BOOL)decryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(const uint8_t *)extra error:(NSError *__autoreleasing *)error
{ {
NSParameterAssert(extra); NSParameterAssert(extra);

View File

@ -38,14 +38,16 @@
#import "ZeroingData.h" #import "ZeroingData.h"
NS_ASSUME_NONNULL_BEGIN
@protocol Encrypter; @protocol Encrypter;
@protocol Decrypter; @protocol Decrypter;
@interface CryptoBox : NSObject @interface CryptoBox : NSObject
+ (BOOL)preparePRNGWithSeed:(nonnull const uint8_t *)seed length:(NSInteger)length; + (BOOL)preparePRNGWithSeed:(const uint8_t *)seed length:(NSInteger)length;
- (nonnull instancetype)initWithCipherAlgorithm:(nullable NSString *)cipherAlgorithm - (instancetype)initWithCipherAlgorithm:(nullable NSString *)cipherAlgorithm
digestAlgorithm:(nullable NSString *)digestAlgorithm; digestAlgorithm:(nullable NSString *)digestAlgorithm;
- (BOOL)configureWithCipherEncKey:(nullable ZeroingData *)cipherEncKey - (BOOL)configureWithCipherEncKey:(nullable ZeroingData *)cipherEncKey
@ -55,19 +57,21 @@
error:(NSError **)error; error:(NSError **)error;
// WARNING: hmac must be able to hold HMAC result // WARNING: hmac must be able to hold HMAC result
+ (BOOL)hmacWithDigestName:(nonnull NSString *)digestName + (BOOL)hmacWithDigestName:(NSString *)digestName
secret:(nonnull const uint8_t *)secret secret:(const uint8_t *)secret
secretLength:(NSInteger)secretLength secretLength:(NSInteger)secretLength
data:(nonnull const uint8_t *)data data:(const uint8_t *)data
dataLength:(NSInteger)dataLength dataLength:(NSInteger)dataLength
hmac:(nonnull uint8_t *)hmac hmac:(uint8_t *)hmac
hmacLength:(nonnull NSInteger *)hmacLength hmacLength:(NSInteger *)hmacLength
error:(NSError **)error; error:(NSError **)error;
// encrypt/decrypt are mutually thread-safe // encrypt/decrypt are mutually thread-safe
- (nonnull id<Encrypter>)encrypter; - (id<Encrypter>)encrypter;
- (nonnull id<Decrypter>)decrypter; - (id<Decrypter>)decrypter;
- (NSInteger)digestLength; - (NSInteger)digestLength;
@end @end
NS_ASSUME_NONNULL_END

View File

@ -43,13 +43,13 @@ NS_ASSUME_NONNULL_BEGIN
@interface CryptoCBC : NSObject <Encrypter, Decrypter> @interface CryptoCBC : NSObject <Encrypter, Decrypter>
- (instancetype)initWithCipherName:(nullable NSString *)cipherName digestName:(nonnull NSString *)digestName; - (instancetype)initWithCipherName:(nullable NSString *)cipherName digestName:(NSString *)digestName;
@end @end
@interface DataPathCryptoCBC : NSObject <DataPathEncrypter, DataPathDecrypter> @interface DataPathCryptoCBC : NSObject <DataPathEncrypter, DataPathDecrypter>
- (instancetype)initWithCrypto:(nonnull CryptoCBC *)crypto; - (instancetype)initWithCrypto:(CryptoCBC *)crypto;
@end @end

View File

@ -138,7 +138,7 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
HMAC_Init_ex(self.hmacCtxEnc, hmacKey.bytes, self.hmacKeyLength, self.digest, NULL); HMAC_Init_ex(self.hmacCtxEnc, hmacKey.bytes, self.hmacKeyLength, self.digest, NULL);
} }
- (NSData *)encryptData:(NSData *)data offset:(NSInteger)offset extra:(nonnull const uint8_t *)extra error:(NSError *__autoreleasing *)error - (NSData *)encryptData:(NSData *)data offset:(NSInteger)offset extra:(const uint8_t *)extra error:(NSError *__autoreleasing *)error
{ {
NSParameterAssert(data); NSParameterAssert(data);
@ -155,7 +155,7 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
return dest; return dest;
} }
- (BOOL)encryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(nonnull const uint8_t *)extra error:(NSError *__autoreleasing *)error - (BOOL)encryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(const uint8_t *)extra error:(NSError *__autoreleasing *)error
{ {
uint8_t *outIV = dest + self.digestLength; uint8_t *outIV = dest + self.digestLength;
uint8_t *outEncrypted = dest + self.digestLength + self.cipherIVLength; uint8_t *outEncrypted = dest + self.digestLength + self.cipherIVLength;

View File

@ -36,6 +36,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol DataPathEncrypter; @protocol DataPathEncrypter;
@protocol DataPathDecrypter; @protocol DataPathDecrypter;
@ -45,14 +47,16 @@
@property (nonatomic, assign) uint32_t maxPacketId; @property (nonatomic, assign) uint32_t maxPacketId;
- (nonnull instancetype)initWithEncrypter:(nonnull id<DataPathEncrypter>)encrypter - (instancetype)initWithEncrypter:(id<DataPathEncrypter>)encrypter
decrypter:(nonnull id<DataPathDecrypter>)decrypter decrypter:(id<DataPathDecrypter>)decrypter
peerId:(uint32_t)peerId // 24-bit, discard most significant byte peerId:(uint32_t)peerId // 24-bit, discard most significant byte
compressionFraming:(CompressionFramingNative)compressionFraming compressionFraming:(CompressionFramingNative)compressionFraming
maxPackets:(NSInteger)maxPackets maxPackets:(NSInteger)maxPackets
usesReplayProtection:(BOOL)usesReplayProtection; usesReplayProtection:(BOOL)usesReplayProtection;
- (NSArray<NSData *> *)encryptPackets:(nonnull NSArray<NSData *> *)packets key:(uint8_t)key error:(NSError **)error; - (nullable NSArray<NSData *> *)encryptPackets:(NSArray<NSData *> *)packets key:(uint8_t)key error:(NSError **)error;
- (NSArray<NSData *> *)decryptPackets:(nonnull NSArray<NSData *> *)packets keepAlive:(nullable bool *)keepAlive error:(NSError **)error; - (nullable NSArray<NSData *> *)decryptPackets:(NSArray<NSData *> *)packets keepAlive:(nullable bool *)keepAlive error:(NSError **)error;
@end @end
NS_ASSUME_NONNULL_END

View File

@ -156,24 +156,24 @@
{ {
switch (compressionFraming) { switch (compressionFraming) {
case CompressionFramingNativeDisabled: { case CompressionFramingNativeDisabled: {
self.assemblePayloadBlock = ^(uint8_t * _Nonnull packetDest, NSInteger * _Nonnull packetLengthOffset, NSData * _Nonnull payload) { self.assemblePayloadBlock = ^(uint8_t * packetDest, NSInteger * packetLengthOffset, NSData * payload) {
memcpy(packetDest, payload.bytes, payload.length); memcpy(packetDest, payload.bytes, payload.length);
*packetLengthOffset = 0; *packetLengthOffset = 0;
}; };
self.parsePayloadBlock = ^(uint8_t * _Nonnull payload, NSInteger *payloadOffset, NSInteger * _Nonnull headerLength, const uint8_t * _Nonnull packet, NSInteger packetLength) { self.parsePayloadBlock = ^(uint8_t * payload, NSInteger *payloadOffset, NSInteger * headerLength, const uint8_t * packet, NSInteger packetLength) {
*payloadOffset = 0; *payloadOffset = 0;
*headerLength = 0; *headerLength = 0;
}; };
break; break;
} }
case CompressionFramingNativeCompress: { case CompressionFramingNativeCompress: {
self.assemblePayloadBlock = ^(uint8_t * _Nonnull packetDest, NSInteger * _Nonnull packetLengthOffset, NSData * _Nonnull payload) { self.assemblePayloadBlock = ^(uint8_t * packetDest, NSInteger * packetLengthOffset, NSData * payload) {
memcpy(packetDest, payload.bytes, payload.length); memcpy(packetDest, payload.bytes, payload.length);
packetDest[payload.length] = packetDest[0]; packetDest[payload.length] = packetDest[0];
packetDest[0] = DataPacketNoCompressSwap; packetDest[0] = DataPacketNoCompressSwap;
*packetLengthOffset = 1; *packetLengthOffset = 1;
}; };
self.parsePayloadBlock = ^(uint8_t * _Nonnull payload, NSInteger *payloadOffset, NSInteger * _Nonnull headerLength, const uint8_t * _Nonnull packet, NSInteger packetLength) { self.parsePayloadBlock = ^(uint8_t * payload, NSInteger *payloadOffset, NSInteger * headerLength, const uint8_t * packet, NSInteger packetLength) {
NSCAssert(payload[0] == DataPacketNoCompressSwap, @"Expected NO_COMPRESS_SWAP (found %X != %X)", payload[0], DataPacketNoCompressSwap); NSCAssert(payload[0] == DataPacketNoCompressSwap, @"Expected NO_COMPRESS_SWAP (found %X != %X)", payload[0], DataPacketNoCompressSwap);
payload[0] = packet[packetLength - 1]; payload[0] = packet[packetLength - 1];
*payloadOffset = 0; *payloadOffset = 0;
@ -182,12 +182,12 @@
break; break;
} }
case CompressionFramingNativeCompLZO: { case CompressionFramingNativeCompLZO: {
self.assemblePayloadBlock = ^(uint8_t * _Nonnull packetDest, NSInteger * _Nonnull packetLengthOffset, NSData * _Nonnull payload) { self.assemblePayloadBlock = ^(uint8_t * packetDest, NSInteger * packetLengthOffset, NSData * payload) {
memcpy(packetDest + 1, payload.bytes, payload.length); memcpy(packetDest + 1, payload.bytes, payload.length);
packetDest[0] = DataPacketNoCompress; packetDest[0] = DataPacketNoCompress;
*packetLengthOffset = 1; *packetLengthOffset = 1;
}; };
self.parsePayloadBlock = ^(uint8_t * _Nonnull payload, NSInteger *payloadOffset, NSInteger * _Nonnull headerLength, const uint8_t * _Nonnull packet, NSInteger packetLength) { self.parsePayloadBlock = ^(uint8_t * payload, NSInteger *payloadOffset, NSInteger * headerLength, const uint8_t * packet, NSInteger packetLength) {
NSCAssert(payload[0] == DataPacketNoCompress, @"Expected NO_COMPRESS (found %X != %X)", payload[0], DataPacketNoCompress); NSCAssert(payload[0] == DataPacketNoCompress, @"Expected NO_COMPRESS (found %X != %X)", payload[0], DataPacketNoCompress);
*payloadOffset = 1; *payloadOffset = 1;
*headerLength = 1; *headerLength = 1;

View File

@ -36,8 +36,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
typedef void (^DataPathAssembleBlock)(uint8_t *_Nonnull packetDest, NSInteger *_Nonnull packetLengthOffset, NSData *_Nonnull payload); NS_ASSUME_NONNULL_BEGIN
typedef void (^DataPathParseBlock)(uint8_t *_Nonnull payload, NSInteger *_Nonnull payloadOffset, NSInteger *_Nonnull headerLength, const uint8_t *_Nonnull packet, NSInteger packetLength);
typedef void (^DataPathAssembleBlock)(uint8_t *packetDest, NSInteger *packetLengthOffset, NSData *payload);
typedef void (^DataPathParseBlock)(uint8_t *payload, NSInteger *payloadOffset, NSInteger *headerLength, const uint8_t *packet, NSInteger packetLength);
@protocol DataPathChannel @protocol DataPathChannel
@ -48,14 +50,16 @@ typedef void (^DataPathParseBlock)(uint8_t *_Nonnull payload, NSInteger *_Nonnul
@protocol DataPathEncrypter <DataPathChannel> @protocol DataPathEncrypter <DataPathChannel>
- (void)assembleDataPacketWithBlock:(DataPathAssembleBlock)block packetId:(uint32_t)packetId payload:(NSData *)payload into:(nonnull uint8_t *)packetBytes length:(nonnull NSInteger *)packetLength; - (void)assembleDataPacketWithBlock:(nullable DataPathAssembleBlock)block packetId:(uint32_t)packetId payload:(NSData *)payload into:(uint8_t *)packetBytes length:(NSInteger *)packetLength;
- (NSData *)encryptedDataPacketWithKey:(uint8_t)key packetId:(uint32_t)packetId packetBytes:(const uint8_t *)packetBytes packetLength:(NSInteger)packetLength error:(NSError **)error; - (nullable NSData *)encryptedDataPacketWithKey:(uint8_t)key packetId:(uint32_t)packetId packetBytes:(const uint8_t *)packetBytes packetLength:(NSInteger)packetLength error:(NSError **)error;
@end @end
@protocol DataPathDecrypter <DataPathChannel> @protocol DataPathDecrypter <DataPathChannel>
- (BOOL)decryptDataPacket:(nonnull NSData *)packet into:(nonnull uint8_t *)packetBytes length:(nonnull NSInteger *)packetLength packetId:(nonnull uint32_t *)packetId error:(NSError **)error; - (BOOL)decryptDataPacket:(NSData *)packet into:(uint8_t *)packetBytes length:(NSInteger *)packetLength packetId:(uint32_t *)packetId error:(NSError **)error;
- (nonnull const uint8_t *)parsePayloadWithBlock:(DataPathParseBlock)block length:(nonnull NSInteger *)length packetBytes:(nonnull uint8_t *)packetBytes packetLength:(NSInteger)packetLength; - (const uint8_t *)parsePayloadWithBlock:(nullable DataPathParseBlock)block length:(NSInteger *)length packetBytes:(uint8_t *)packetBytes packetLength:(NSInteger)packetLength;
@end @end
NS_ASSUME_NONNULL_END

View File

@ -38,6 +38,8 @@
#import "ZeroingData.h" #import "ZeroingData.h"
NS_ASSUME_NONNULL_BEGIN
@protocol DataPathEncrypter; @protocol DataPathEncrypter;
@protocol DataPathDecrypter; @protocol DataPathDecrypter;
@ -49,10 +51,10 @@
- (int)overheadLength; - (int)overheadLength;
- (int)extraLength; - (int)extraLength;
- (NSData *)encryptData:(nonnull NSData *)data offset:(NSInteger)offset extra:(const uint8_t *)extra error:(NSError **)error; - (nullable NSData *)encryptData:(NSData *)data offset:(NSInteger)offset extra:(nullable const uint8_t *)extra error:(NSError **)error;
- (BOOL)encryptBytes:(nonnull const uint8_t *)bytes length:(NSInteger)length dest:(nonnull uint8_t *)dest destLength:(nonnull NSInteger *)destLength extra:(const uint8_t *)extra error:(NSError **)error; - (BOOL)encryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(nullable const uint8_t *)extra error:(NSError **)error;
- (nonnull id<DataPathEncrypter>)dataPathEncrypter; - (id<DataPathEncrypter>)dataPathEncrypter;
@end @end
@ -64,11 +66,13 @@
- (int)overheadLength; - (int)overheadLength;
- (int)extraLength; - (int)extraLength;
- (NSData *)decryptData:(nonnull NSData *)data offset:(NSInteger)offset extra:(const uint8_t *)extra error:(NSError **)error; - (nullable NSData *)decryptData:(NSData *)data offset:(NSInteger)offset extra:(nullable const uint8_t *)extra error:(NSError **)error;
- (BOOL)decryptBytes:(nonnull const uint8_t *)bytes length:(NSInteger)length dest:(nonnull uint8_t *)dest destLength:(nonnull NSInteger *)destLength extra:(const uint8_t *)extra error:(NSError **)error; - (BOOL)decryptBytes:(const uint8_t *)bytes length:(NSInteger)length dest:(uint8_t *)dest destLength:(NSInteger *)destLength extra:(nullable const uint8_t *)extra error:(NSError **)error;
- (BOOL)verifyData:(nonnull NSData *)data offset:(NSInteger)offset extra:(const uint8_t *)extra error:(NSError **)error; - (BOOL)verifyData:(NSData *)data offset:(NSInteger)offset extra:(nullable const uint8_t *)extra error:(NSError **)error;
- (BOOL)verifyBytes:(nonnull const uint8_t *)bytes length:(NSInteger)length extra:(const uint8_t *)extra error:(NSError **)error; - (BOOL)verifyBytes:(const uint8_t *)bytes length:(NSInteger)length extra:(const uint8_t *)extra error:(NSError **)error;
- (nonnull id<DataPathDecrypter>)dataPathDecrypter; - (id<DataPathDecrypter>)dataPathDecrypter;
@end @end
NS_ASSUME_NONNULL_END

View File

@ -37,6 +37,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define PacketPeerIdDisabled 0xffffffu #define PacketPeerIdDisabled 0xffffffu
#define PacketIdLength 4 #define PacketIdLength 4
@ -56,14 +58,15 @@ typedef NS_ENUM(uint8_t, PacketCode) {
extern const uint8_t DataPacketPingData[16]; extern const uint8_t DataPacketPingData[16];
static inline int PacketHeaderSet(uint8_t *_Nonnull to, PacketCode code, uint8_t key) // Ruby: header
static inline int PacketHeaderSet(uint8_t *to, PacketCode code, uint8_t key)
{ {
*(uint8_t *)to = (code << 3) | (key & 0b111); *(uint8_t *)to = (code << 3) | (key & 0b111);
return sizeof(uint8_t); return sizeof(uint8_t);
} }
// Ruby: header // Ruby: header
static inline NSData *_Nonnull PacketWithHeader(PacketCode code, uint8_t key, NSData *sessionId) static inline NSData *PacketWithHeader(PacketCode code, uint8_t key, NSData *_Nullable sessionId)
{ {
NSMutableData *to = [[NSMutableData alloc] initWithLength:(sizeof(uint8_t) + (sessionId ? sessionId.length : 0))]; NSMutableData *to = [[NSMutableData alloc] initWithLength:(sizeof(uint8_t) + (sessionId ? sessionId.length : 0))];
const int offset = PacketHeaderSet(to.mutableBytes, code, key); const int offset = PacketHeaderSet(to.mutableBytes, code, key);
@ -73,18 +76,18 @@ static inline NSData *_Nonnull PacketWithHeader(PacketCode code, uint8_t key, NS
return to; return to;
} }
static inline int PacketHeaderSetDataV2(uint8_t *_Nonnull to, uint8_t key, uint32_t peerId) static inline int PacketHeaderSetDataV2(uint8_t *to, uint8_t key, uint32_t peerId)
{ {
*(uint32_t *)to = ((PacketCodeDataV2 << 3) | (key & 0b111)) | htonl(peerId & 0xffffff); *(uint32_t *)to = ((PacketCodeDataV2 << 3) | (key & 0b111)) | htonl(peerId & 0xffffff);
return sizeof(uint32_t); return sizeof(uint32_t);
} }
static inline int PacketHeaderGetDataV2PeerId(const uint8_t *_Nonnull from) static inline int PacketHeaderGetDataV2PeerId(const uint8_t *from)
{ {
return ntohl(*(const uint32_t *)from & 0xffffff00); return ntohl(*(const uint32_t *)from & 0xffffff00);
} }
static inline NSData *_Nonnull PacketWithHeaderDataV2(uint8_t key, uint32_t peerId, NSData *sessionId) static inline NSData *PacketWithHeaderDataV2(uint8_t key, uint32_t peerId, NSData *sessionId)
{ {
NSMutableData *to = [[NSMutableData alloc] initWithLength:(sizeof(uint32_t) + (sessionId ? sessionId.length : 0))]; NSMutableData *to = [[NSMutableData alloc] initWithLength:(sizeof(uint32_t) + (sessionId ? sessionId.length : 0))];
const int offset = PacketHeaderSetDataV2(to.mutableBytes, key, peerId); const int offset = PacketHeaderSetDataV2(to.mutableBytes, key, peerId);
@ -93,3 +96,5 @@ static inline NSData *_Nonnull PacketWithHeaderDataV2(uint8_t key, uint32_t peer
} }
return to; return to;
} }
NS_ASSUME_NONNULL_END

View File

@ -49,7 +49,7 @@ extern NSString *const TLSBoxPeerVerificationErrorNotification;
// //
@interface TLSBox : NSObject @interface TLSBox : NSObject
- (nonnull instancetype)initWithCAPath:(NSString *)caPath - (instancetype)initWithCAPath:(NSString *)caPath
clientCertificatePath:(NSString *)clientCertificatePath clientCertificatePath:(NSString *)clientCertificatePath
clientKeyPath:(NSString *)clientKeyPath; clientKeyPath:(NSString *)clientKeyPath;

View File

@ -37,6 +37,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZeroingData : NSObject @interface ZeroingData : NSObject
@property (nonatomic, readonly) const uint8_t *bytes; @property (nonatomic, readonly) const uint8_t *bytes;
@ -44,7 +46,7 @@
@property (nonatomic, readonly) NSInteger count; @property (nonatomic, readonly) NSInteger count;
- (instancetype)initWithCount:(NSInteger)count; - (instancetype)initWithCount:(NSInteger)count;
- (instancetype)initWithBytes:(const uint8_t *)bytes count:(NSInteger)count; - (instancetype)initWithBytes:(nullable const uint8_t *)bytes count:(NSInteger)count;
- (instancetype)initWithUInt8:(uint8_t)uint8; - (instancetype)initWithUInt8:(uint8_t)uint8;
- (instancetype)initWithUInt16:(uint16_t)uint16; - (instancetype)initWithUInt16:(uint16_t)uint16;
@ -57,13 +59,15 @@
- (void)removeUntilOffset:(NSInteger)until; - (void)removeUntilOffset:(NSInteger)until;
- (void)zero; - (void)zero;
- (nonnull ZeroingData *)appendingData:(ZeroingData *)other; - (ZeroingData *)appendingData:(ZeroingData *)other;
- (nonnull ZeroingData *)withOffset:(NSInteger)offset count:(NSInteger)count; - (ZeroingData *)withOffset:(NSInteger)offset count:(NSInteger)count;
- (uint16_t)UInt16ValueFromOffset:(NSInteger)from; - (uint16_t)UInt16ValueFromOffset:(NSInteger)from;
- (uint16_t)networkUInt16ValueFromOffset:(NSInteger)from; - (uint16_t)networkUInt16ValueFromOffset:(NSInteger)from;
- (NSString *)nullTerminatedStringFromOffset:(NSInteger)from; - (nullable NSString *)nullTerminatedStringFromOffset:(NSInteger)from;
- (BOOL)isEqualToData:(NSData *)data; - (BOOL)isEqualToData:(NSData *)data;
- (nonnull NSString *)toHex; - (NSString *)toHex;
@end @end
NS_ASSUME_NONNULL_END