Fix and clean up redundant nullability specifiers
This commit is contained in:
parent
a3fe740ad9
commit
aef7daec51
|
@ -45,13 +45,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@property (nonatomic, assign) int extraLength;
|
||||
|
||||
- (instancetype)initWithCipherName:(nonnull NSString *)cipherName;
|
||||
- (instancetype)initWithCipherName:(NSString *)cipherName;
|
||||
|
||||
@end
|
||||
|
||||
@interface DataPathCryptoAEAD : NSObject <DataPathEncrypter, DataPathDecrypter>
|
||||
|
||||
- (instancetype)initWithCrypto:(nonnull CryptoAEAD *)crypto;
|
||||
- (instancetype)initWithCrypto:(CryptoAEAD *)crypto;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ const NSInteger CryptoAEADTagLength = 16;
|
|||
[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(extra);
|
||||
|
@ -133,7 +133,7 @@ const NSInteger CryptoAEADTagLength = 16;
|
|||
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);
|
||||
|
||||
|
@ -179,7 +179,7 @@ const NSInteger CryptoAEADTagLength = 16;
|
|||
[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(extra);
|
||||
|
@ -197,7 +197,7 @@ const NSInteger CryptoAEADTagLength = 16;
|
|||
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);
|
||||
|
||||
|
|
|
@ -38,14 +38,16 @@
|
|||
|
||||
#import "ZeroingData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol Encrypter;
|
||||
@protocol Decrypter;
|
||||
|
||||
@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;
|
||||
|
||||
- (BOOL)configureWithCipherEncKey:(nullable ZeroingData *)cipherEncKey
|
||||
|
@ -55,19 +57,21 @@
|
|||
error:(NSError **)error;
|
||||
|
||||
// WARNING: hmac must be able to hold HMAC result
|
||||
+ (BOOL)hmacWithDigestName:(nonnull NSString *)digestName
|
||||
secret:(nonnull const uint8_t *)secret
|
||||
+ (BOOL)hmacWithDigestName:(NSString *)digestName
|
||||
secret:(const uint8_t *)secret
|
||||
secretLength:(NSInteger)secretLength
|
||||
data:(nonnull const uint8_t *)data
|
||||
data:(const uint8_t *)data
|
||||
dataLength:(NSInteger)dataLength
|
||||
hmac:(nonnull uint8_t *)hmac
|
||||
hmacLength:(nonnull NSInteger *)hmacLength
|
||||
hmac:(uint8_t *)hmac
|
||||
hmacLength:(NSInteger *)hmacLength
|
||||
error:(NSError **)error;
|
||||
|
||||
// encrypt/decrypt are mutually thread-safe
|
||||
- (nonnull id<Encrypter>)encrypter;
|
||||
- (nonnull id<Decrypter>)decrypter;
|
||||
- (id<Encrypter>)encrypter;
|
||||
- (id<Decrypter>)decrypter;
|
||||
|
||||
- (NSInteger)digestLength;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -43,13 +43,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface CryptoCBC : NSObject <Encrypter, Decrypter>
|
||||
|
||||
- (instancetype)initWithCipherName:(nullable NSString *)cipherName digestName:(nonnull NSString *)digestName;
|
||||
- (instancetype)initWithCipherName:(nullable NSString *)cipherName digestName:(NSString *)digestName;
|
||||
|
||||
@end
|
||||
|
||||
@interface DataPathCryptoCBC : NSObject <DataPathEncrypter, DataPathDecrypter>
|
||||
|
||||
- (instancetype)initWithCrypto:(nonnull CryptoCBC *)crypto;
|
||||
- (instancetype)initWithCrypto:(CryptoCBC *)crypto;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
|
|||
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);
|
||||
|
||||
|
@ -155,7 +155,7 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
|
|||
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 *outEncrypted = dest + self.digestLength + self.cipherIVLength;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol DataPathEncrypter;
|
||||
@protocol DataPathDecrypter;
|
||||
|
||||
|
@ -45,14 +47,16 @@
|
|||
|
||||
@property (nonatomic, assign) uint32_t maxPacketId;
|
||||
|
||||
- (nonnull instancetype)initWithEncrypter:(nonnull id<DataPathEncrypter>)encrypter
|
||||
decrypter:(nonnull id<DataPathDecrypter>)decrypter
|
||||
- (instancetype)initWithEncrypter:(id<DataPathEncrypter>)encrypter
|
||||
decrypter:(id<DataPathDecrypter>)decrypter
|
||||
peerId:(uint32_t)peerId // 24-bit, discard most significant byte
|
||||
compressionFraming:(CompressionFramingNative)compressionFraming
|
||||
maxPackets:(NSInteger)maxPackets
|
||||
usesReplayProtection:(BOOL)usesReplayProtection;
|
||||
|
||||
- (NSArray<NSData *> *)encryptPackets:(nonnull 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 *> *)encryptPackets:(NSArray<NSData *> *)packets key:(uint8_t)key error:(NSError **)error;
|
||||
- (nullable NSArray<NSData *> *)decryptPackets:(NSArray<NSData *> *)packets keepAlive:(nullable bool *)keepAlive error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -156,24 +156,24 @@
|
|||
{
|
||||
switch (compressionFraming) {
|
||||
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);
|
||||
*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;
|
||||
*headerLength = 0;
|
||||
};
|
||||
break;
|
||||
}
|
||||
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);
|
||||
packetDest[payload.length] = packetDest[0];
|
||||
packetDest[0] = DataPacketNoCompressSwap;
|
||||
*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);
|
||||
payload[0] = packet[packetLength - 1];
|
||||
*payloadOffset = 0;
|
||||
|
@ -182,12 +182,12 @@
|
|||
break;
|
||||
}
|
||||
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);
|
||||
packetDest[0] = DataPacketNoCompress;
|
||||
*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);
|
||||
*payloadOffset = 1;
|
||||
*headerLength = 1;
|
||||
|
|
|
@ -36,8 +36,10 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef void (^DataPathAssembleBlock)(uint8_t *_Nonnull packetDest, NSInteger *_Nonnull packetLengthOffset, NSData *_Nonnull payload);
|
||||
typedef void (^DataPathParseBlock)(uint8_t *_Nonnull payload, NSInteger *_Nonnull payloadOffset, NSInteger *_Nonnull headerLength, const uint8_t *_Nonnull packet, NSInteger packetLength);
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
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
|
||||
|
||||
|
@ -48,14 +50,16 @@ typedef void (^DataPathParseBlock)(uint8_t *_Nonnull payload, NSInteger *_Nonnul
|
|||
|
||||
@protocol DataPathEncrypter <DataPathChannel>
|
||||
|
||||
- (void)assembleDataPacketWithBlock:(DataPathAssembleBlock)block packetId:(uint32_t)packetId payload:(NSData *)payload into:(nonnull uint8_t *)packetBytes length:(nonnull NSInteger *)packetLength;
|
||||
- (NSData *)encryptedDataPacketWithKey:(uint8_t)key packetId:(uint32_t)packetId packetBytes:(const uint8_t *)packetBytes packetLength:(NSInteger)packetLength error:(NSError **)error;
|
||||
- (void)assembleDataPacketWithBlock:(nullable DataPathAssembleBlock)block packetId:(uint32_t)packetId payload:(NSData *)payload into:(uint8_t *)packetBytes length:(NSInteger *)packetLength;
|
||||
- (nullable NSData *)encryptedDataPacketWithKey:(uint8_t)key packetId:(uint32_t)packetId packetBytes:(const uint8_t *)packetBytes packetLength:(NSInteger)packetLength error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
@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;
|
||||
- (nonnull const uint8_t *)parsePayloadWithBlock:(DataPathParseBlock)block length:(nonnull NSInteger *)length packetBytes:(nonnull uint8_t *)packetBytes packetLength:(NSInteger)packetLength;
|
||||
- (BOOL)decryptDataPacket:(NSData *)packet into:(uint8_t *)packetBytes length:(NSInteger *)packetLength packetId:(uint32_t *)packetId error:(NSError **)error;
|
||||
- (const uint8_t *)parsePayloadWithBlock:(nullable DataPathParseBlock)block length:(NSInteger *)length packetBytes:(uint8_t *)packetBytes packetLength:(NSInteger)packetLength;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#import "ZeroingData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol DataPathEncrypter;
|
||||
@protocol DataPathDecrypter;
|
||||
|
||||
|
@ -49,10 +51,10 @@
|
|||
- (int)overheadLength;
|
||||
- (int)extraLength;
|
||||
|
||||
- (NSData *)encryptData:(nonnull NSData *)data offset:(NSInteger)offset extra:(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;
|
||||
- (nullable NSData *)encryptData:(NSData *)data offset:(NSInteger)offset extra:(nullable 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
|
||||
|
||||
|
@ -64,11 +66,13 @@
|
|||
- (int)overheadLength;
|
||||
- (int)extraLength;
|
||||
|
||||
- (NSData *)decryptData:(nonnull NSData *)data offset:(NSInteger)offset extra:(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)verifyData:(nonnull NSData *)data offset:(NSInteger)offset extra:(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;
|
||||
- (nullable NSData *)decryptData:(NSData *)data offset:(NSInteger)offset extra:(nullable 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:(NSData *)data offset:(NSInteger)offset extra:(nullable 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
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define PacketPeerIdDisabled 0xffffffu
|
||||
#define PacketIdLength 4
|
||||
|
||||
|
@ -56,14 +58,15 @@ typedef NS_ENUM(uint8_t, PacketCode) {
|
|||
|
||||
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);
|
||||
return sizeof(uint8_t);
|
||||
}
|
||||
|
||||
// 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))];
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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))];
|
||||
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;
|
||||
}
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -49,7 +49,7 @@ extern NSString *const TLSBoxPeerVerificationErrorNotification;
|
|||
//
|
||||
@interface TLSBox : NSObject
|
||||
|
||||
- (nonnull instancetype)initWithCAPath:(NSString *)caPath
|
||||
- (instancetype)initWithCAPath:(NSString *)caPath
|
||||
clientCertificatePath:(NSString *)clientCertificatePath
|
||||
clientKeyPath:(NSString *)clientKeyPath;
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ZeroingData : NSObject
|
||||
|
||||
@property (nonatomic, readonly) const uint8_t *bytes;
|
||||
|
@ -44,7 +46,7 @@
|
|||
@property (nonatomic, readonly) 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)initWithUInt16:(uint16_t)uint16;
|
||||
|
||||
|
@ -57,13 +59,15 @@
|
|||
- (void)removeUntilOffset:(NSInteger)until;
|
||||
- (void)zero;
|
||||
|
||||
- (nonnull ZeroingData *)appendingData:(ZeroingData *)other;
|
||||
- (nonnull ZeroingData *)withOffset:(NSInteger)offset count:(NSInteger)count;
|
||||
- (ZeroingData *)appendingData:(ZeroingData *)other;
|
||||
- (ZeroingData *)withOffset:(NSInteger)offset count:(NSInteger)count;
|
||||
- (uint16_t)UInt16ValueFromOffset:(NSInteger)from;
|
||||
- (uint16_t)networkUInt16ValueFromOffset:(NSInteger)from;
|
||||
- (NSString *)nullTerminatedStringFromOffset:(NSInteger)from;
|
||||
- (nullable NSString *)nullTerminatedStringFromOffset:(NSInteger)from;
|
||||
|
||||
- (BOOL)isEqualToData:(NSData *)data;
|
||||
- (nonnull NSString *)toHex;
|
||||
- (NSString *)toHex;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
Loading…
Reference in New Issue