diff --git a/MTAes.h b/MTAes.h new file mode 100644 index 0000000000..6663a3493b --- /dev/null +++ b/MTAes.h @@ -0,0 +1,11 @@ +#import + +void MyAesIgeEncrypt(const void *inBytes, int length, void *outBytes, const void *key, int keyLength, void *iv); +void MyAesIgeDecrypt(const void *inBytes, int length, void *outBytes, const void *key, int keyLength, void *iv); + +@interface MTAesCtr : NSObject + +- (instancetype)initWithKey:(const void *)key keyLength:(int)keyLength iv:(const void *)iv; +- (void)encryptIn:(const unsigned char *)in out:(unsigned char *)out len:(size_t)len; + +@end diff --git a/MTAes.m b/MTAes.m new file mode 100644 index 0000000000..53a08cd8e1 --- /dev/null +++ b/MTAes.m @@ -0,0 +1,288 @@ +#import "MTAes.h" + +#import + +# define AES_MAXNR 14 +# define AES_BLOCK_SIZE 16 + +#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long)) +typedef struct { + unsigned long data[N_WORDS]; +} aes_block_t; + +/* XXX: probably some better way to do this */ +#if defined(__i386__) || defined(__x86_64__) +# define UNALIGNED_MEMOPS_ARE_FAST 1 +#else +# define UNALIGNED_MEMOPS_ARE_FAST 0 +#endif + +#if UNALIGNED_MEMOPS_ARE_FAST +# define load_block(d, s) (d) = *(const aes_block_t *)(s) +# define store_block(d, s) *(aes_block_t *)(d) = (s) +#else +# define load_block(d, s) memcpy((d).data, (s), AES_BLOCK_SIZE) +# define store_block(d, s) memcpy((d), (s).data, AES_BLOCK_SIZE) +#endif + +void MyAesIgeEncrypt(const void *inBytes, int length, void *outBytes, const void *key, int keyLength, void *iv) { + int len; + size_t n; + void const *inB; + void *outB; + + unsigned char aesIv[AES_BLOCK_SIZE]; + memcpy(aesIv, iv, AES_BLOCK_SIZE); + unsigned char ccIv[AES_BLOCK_SIZE]; + memcpy(ccIv, iv + AES_BLOCK_SIZE, AES_BLOCK_SIZE); + + assert(((size_t)inBytes | (size_t)outBytes | (size_t)aesIv | (size_t)ccIv) % sizeof(long) == + 0); + + void *tmpInBytes = malloc(length); + len = length / AES_BLOCK_SIZE; + inB = inBytes; + outB = tmpInBytes; + + aes_block_t *inp = (aes_block_t *)inB; + aes_block_t *outp = (aes_block_t *)outB; + for (n = 0; n < N_WORDS; ++n) { + outp->data[n] = inp->data[n]; + } + + --len; + inB += AES_BLOCK_SIZE; + outB += AES_BLOCK_SIZE; + void const *inBCC = inBytes; + + aes_block_t const *iv3p = (aes_block_t *)ccIv; + + if (len > 0) { + while (len) { + aes_block_t *inp = (aes_block_t *)inB; + aes_block_t *outp = (aes_block_t *)outB; + + for (n = 0; n < N_WORDS; ++n) { + outp->data[n] = inp->data[n] ^ iv3p->data[n]; + } + + iv3p = inBCC; + --len; + inBCC += AES_BLOCK_SIZE; + inB += AES_BLOCK_SIZE; + outB += AES_BLOCK_SIZE; + } + } + + size_t realOutLength = 0; + CCCryptorStatus result = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, 0, key, keyLength, aesIv, tmpInBytes, length, outBytes, length, &realOutLength); + free(tmpInBytes); + + assert(result == kCCSuccess); + + len = length / AES_BLOCK_SIZE; + + aes_block_t const *ivp = inB; + aes_block_t *iv2p = (aes_block_t *)ccIv; + + inB = inBytes; + outB = outBytes; + + while (len) { + aes_block_t *inp = (aes_block_t *)inB; + aes_block_t *outp = (aes_block_t *)outB; + + for (n = 0; n < N_WORDS; ++n) { + outp->data[n] ^= iv2p->data[n]; + } + ivp = outp; + iv2p = inp; + --len; + inB += AES_BLOCK_SIZE; + outB += AES_BLOCK_SIZE; + } + + memcpy(iv, ivp->data, AES_BLOCK_SIZE); + memcpy(iv + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE); +} + +void MyAesIgeDecrypt(const void *inBytes, int length, void *outBytes, const void *key, int keyLength, void *iv) { + unsigned char aesIv[AES_BLOCK_SIZE]; + memcpy(aesIv, iv, AES_BLOCK_SIZE); + unsigned char ccIv[AES_BLOCK_SIZE]; + memcpy(ccIv, iv + AES_BLOCK_SIZE, AES_BLOCK_SIZE); + + assert(((size_t)inBytes | (size_t)outBytes | (size_t)aesIv | (size_t)ccIv) % sizeof(long) == + 0); + + CCCryptorRef decryptor = NULL; + CCCryptorCreate(kCCDecrypt, kCCAlgorithmAES128, kCCOptionECBMode, key, keyLength, nil, &decryptor); + if (decryptor != NULL) { + int len; + size_t n; + + len = length / AES_BLOCK_SIZE; + + aes_block_t *ivp = (aes_block_t *)(aesIv); + aes_block_t *iv2p = (aes_block_t *)(ccIv); + + while (len) { + aes_block_t tmp; + aes_block_t *inp = (aes_block_t *)inBytes; + aes_block_t *outp = (aes_block_t *)outBytes; + + for (n = 0; n < N_WORDS; ++n) + tmp.data[n] = inp->data[n] ^ iv2p->data[n]; + + size_t dataOutMoved = 0; + CCCryptorStatus result = CCCryptorUpdate(decryptor, &tmp, AES_BLOCK_SIZE, outBytes, AES_BLOCK_SIZE, &dataOutMoved); + assert(result == kCCSuccess); + assert(dataOutMoved == AES_BLOCK_SIZE); + + for (n = 0; n < N_WORDS; ++n) + outp->data[n] ^= ivp->data[n]; + + ivp = inp; + iv2p = outp; + + inBytes += AES_BLOCK_SIZE; + outBytes += AES_BLOCK_SIZE; + + --len; + } + + memcpy(iv, ivp->data, AES_BLOCK_SIZE); + memcpy(iv + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE); + + CCCryptorRelease(decryptor); + } +} + +static void ctr128_inc(unsigned char *counter) +{ + uint32_t n = 16, c = 1; + + do { + --n; + c += counter[n]; + counter[n] = (uint8_t)c; + c >>= 8; + } while (n); +} + +static void ctr128_inc_aligned(unsigned char *counter) +{ + size_t *data, c, d, n; + const union { + long one; + char little; + } is_endian = { + 1 + }; + + if (is_endian.little || ((size_t)counter % sizeof(size_t)) != 0) { + ctr128_inc(counter); + return; + } + + data = (size_t *)counter; + c = 1; + n = 16 / sizeof(size_t); + do { + --n; + d = data[n] += c; + /* did addition carry? */ + c = ((d - c) ^ d) >> (sizeof(size_t) * 8 - 1); + } while (n); +} + + +@interface MTAesCtr () { + CCCryptorRef _cryptor; + + unsigned char _ivec[16]; + unsigned int _num; + unsigned char _ecount[16]; +} + +@end + +@implementation MTAesCtr + +- (instancetype)initWithKey:(const void *)key keyLength:(int)keyLength iv:(const void *)iv { + self = [super init]; + if (self != nil) { + _num = 0; + memset(_ecount, 0, 16); + memcpy(_ivec, iv, 16); + + CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES128, kCCOptionECBMode, key, keyLength, nil, &_cryptor); + } + return self; +} + +- (void)dealloc { + if (_cryptor) { + CCCryptorRelease(_cryptor); + } +} + +- (void)encryptIn:(const unsigned char *)in out:(unsigned char *)out len:(size_t)len { + unsigned int n; + size_t l = 0; + + assert(in && out); + assert(_num < 16); + + n = _num; + + if (16 % sizeof(size_t) == 0) { /* always true actually */ + do { + while (n && len) { + *(out++) = *(in++) ^ _ecount[n]; + --len; + n = (n + 1) % 16; + } + + while (len >= 16) { + size_t dataOutMoved; + CCCryptorUpdate(_cryptor, _ivec, 16, _ecount, 16, &dataOutMoved); + ctr128_inc_aligned(_ivec); + for (n = 0; n < 16; n += sizeof(size_t)) + *(size_t *)(out + n) = + *(size_t *)(in + n) ^ *(size_t *)(_ecount + n); + len -= 16; + out += 16; + in += 16; + n = 0; + } + if (len) { + size_t dataOutMoved; + CCCryptorUpdate(_cryptor, _ivec, 16, _ecount, 16, &dataOutMoved); + ctr128_inc_aligned(_ivec); + while (len--) { + out[n] = in[n] ^ _ecount[n]; + ++n; + } + } + _num = n; + return; + } while (0); + } + /* the rest would be commonly eliminated by x86* compiler */ + + while (l < len) { + if (n == 0) { + size_t dataOutMoved; + CCCryptorUpdate(_cryptor, _ivec, 16, _ecount, 16, &dataOutMoved); + ctr128_inc(_ivec); + } + out[l] = in[l] ^ _ecount[n]; + ++l; + n = (n + 1) % 16; + } + + _num = n; +} + +@end diff --git a/MTAtomic.h b/MTAtomic.h new file mode 100644 index 0000000000..e25689ae0a --- /dev/null +++ b/MTAtomic.h @@ -0,0 +1,11 @@ +#import + +@interface MTAtomic : NSObject + +- (instancetype)initWithValue:(id)value; +- (id)swap:(id)newValue; +- (id)value; +- (id)modify:(id (^)(id))f; +- (id)with:(id (^)(id))f; + +@end diff --git a/MTAtomic.m b/MTAtomic.m new file mode 100644 index 0000000000..58ad159e18 --- /dev/null +++ b/MTAtomic.m @@ -0,0 +1,64 @@ +#import "MTAtomic.h" + +#import + +@interface MTAtomic () +{ + volatile OSSpinLock _lock; + id _value; +} + +@end + +@implementation MTAtomic + +- (instancetype)initWithValue:(id)value +{ + self = [super init]; + if (self != nil) + { + _value = value; + } + return self; +} + +- (id)swap:(id)newValue +{ + id previousValue = nil; + OSSpinLockLock(&_lock); + previousValue = _value; + _value = newValue; + OSSpinLockUnlock(&_lock); + return previousValue; +} + +- (id)value +{ + id previousValue = nil; + OSSpinLockLock(&_lock); + previousValue = _value; + OSSpinLockUnlock(&_lock); + + return previousValue; +} + +- (id)modify:(id (^)(id))f +{ + id newValue = nil; + OSSpinLockLock(&_lock); + newValue = f(_value); + _value = newValue; + OSSpinLockUnlock(&_lock); + return newValue; +} + +- (id)with:(id (^)(id))f +{ + id result = nil; + OSSpinLockLock(&_lock); + result = f(_value); + OSSpinLockUnlock(&_lock); + return result; +} + +@end diff --git a/MTBag.h b/MTBag.h new file mode 100644 index 0000000000..1c4c8c343d --- /dev/null +++ b/MTBag.h @@ -0,0 +1,11 @@ +#import + +@interface MTBag : NSObject + +- (NSInteger)addItem:(id)item; +- (void)enumerateItems:(void (^)(id))block; +- (void)removeItem:(NSInteger)key; +- (bool)isEmpty; +- (NSArray *)copyItems; + +@end diff --git a/MTBag.m b/MTBag.m new file mode 100644 index 0000000000..44e6c1f434 --- /dev/null +++ b/MTBag.m @@ -0,0 +1,74 @@ +#import "MTBag.h" + +@interface MTBag () +{ + NSInteger _nextKey; + NSMutableArray *_items; + NSMutableArray *_itemKeys; +} + +@end + +@implementation MTBag + +- (instancetype)init +{ + self = [super init]; + if (self != nil) + { + _items = [[NSMutableArray alloc] init]; + _itemKeys = [[NSMutableArray alloc] init]; + } + return self; +} + +- (NSInteger)addItem:(id)item +{ + if (item == nil) + return -1; + + NSInteger key = _nextKey; + [_items addObject:item]; + [_itemKeys addObject:@(key)]; + _nextKey++; + + return key; +} + +- (void)enumerateItems:(void (^)(id))block +{ + if (block) + { + for (id item in _items) + { + block(item); + } + } +} + +- (void)removeItem:(NSInteger)key +{ + NSUInteger index = 0; + for (NSNumber *itemKey in _itemKeys) + { + if ([itemKey integerValue] == key) + { + [_items removeObjectAtIndex:index]; + [_itemKeys removeObjectAtIndex:index]; + break; + } + index++; + } +} + +- (bool)isEmpty +{ + return _items.count == 0; +} + +- (NSArray *)copyItems +{ + return [[NSArray alloc] initWithArray:_items]; +} + +@end diff --git a/MTDiscoverConnectionSignals.h b/MTDiscoverConnectionSignals.h index 01a02ed7bd..e40089d422 100644 --- a/MTDiscoverConnectionSignals.h +++ b/MTDiscoverConnectionSignals.h @@ -1,10 +1,10 @@ #import -#import -#import +@class MTContext; +@class MTSignal; @interface MTDiscoverConnectionSignals : NSObject -+ (SSignal *)discoverSchemeWithContext:(MTContext *)context addressList:(NSArray *)addressList media:(bool)media; ++ (MTSignal *)discoverSchemeWithContext:(MTContext *)context addressList:(NSArray *)addressList media:(bool)media; @end diff --git a/MTDiscoverConnectionSignals.m b/MTDiscoverConnectionSignals.m index 7265a41b18..042e050709 100644 --- a/MTDiscoverConnectionSignals.m +++ b/MTDiscoverConnectionSignals.m @@ -2,9 +2,39 @@ #import "MTTcpConnection.h" #import "MTHttpWorker.h" -#import "MTTransportScheme.h" -#import "MTTcpTransport.h" -#import "MTHttpTransport.h" + +#if defined(MtProtoKitDynamicFramework) +# import +# import +# import +# import +# import +#elif defined(MtProtoKitMacFramework) +# import +# import +# import +# import +# import +#else +# import +# import +# import +# import +# import +#endif + +#import "MTDatacenterAddress.h" + +#if defined(MtProtoKitDynamicFramework) +# import +# import +#elif defined(MtProtoKitMacFramework) +# import +# import +#else +# import +# import +#endif #import #import @@ -63,14 +93,14 @@ typedef struct { return success == 1; } -+ (SSignal *)tcpConnectionWithContext:(MTContext *)context datacenterId:(NSUInteger)datacenterId address:(MTDatacenterAddress *)address; ++ (MTSignal *)tcpConnectionWithContext:(MTContext *)context datacenterId:(NSUInteger)datacenterId address:(MTDatacenterAddress *)address; { - return [[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) { MTPayloadData payloadData; NSData *data = [self payloadData:&payloadData]; - MTTcpConnection *connection = [[MTTcpConnection alloc] initWithContext:context datacenterId:datacenterId address:address interface:nil]; + MTTcpConnection *connection = [[MTTcpConnection alloc] initWithContext:context datacenterId:datacenterId address:address interface:nil usageCalculationInfo:nil]; __weak MTTcpConnection *weakConnection = connection; connection.connectionOpened = ^ { @@ -84,34 +114,43 @@ typedef struct { received = true; if ([self isResponseValid:data payloadData:payloadData]) { - MTLog(@"success tcp://%@:%d", address.ip, (int)address.port); + if (MTLogEnabled()) { + MTLog(@"success tcp://%@:%d", address.ip, (int)address.port); + } [subscriber putCompletion]; } else { - MTLog(@"failed tcp://%@:%d", address.ip, (int)address.port); + if (MTLogEnabled()) { + MTLog(@"failed tcp://%@:%d", address.ip, (int)address.port); + } [subscriber putError:nil]; } }; connection.connectionClosed = ^ { - if (!received) - MTLog(@"failed tcp://%@:%d", address.ip, (int)address.port); + if (!received) { + if (MTLogEnabled()) { + MTLog(@"failed tcp://%@:%d", address.ip, (int)address.port); + } + } [subscriber putError:nil]; }; - MTLog(@"trying tcp://%@:%d", address.ip, (int)address.port); + if (MTLogEnabled()) { + MTLog(@"trying tcp://%@:%d", address.ip, (int)address.port); + } [connection start]; - return [[SBlockDisposable alloc] initWithBlock:^ + return [[MTBlockDisposable alloc] initWithBlock:^ { [connection stop]; }]; }]; } -+ (SSignal *)httpConnectionWithAddress:(MTDatacenterAddress *)address ++ (MTSignal *)httpConnectionWithAddress:(MTDatacenterAddress *)address { - return [[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) { MTPayloadData payloadData; NSData *data = [self payloadData:&payloadData]; @@ -130,10 +169,12 @@ typedef struct { [subscriber putError:nil]; }; - MTLog(@"trying http://%@:%d", address.ip, (int)address.port); + if (MTLogEnabled()) { + MTLog(@"trying http://%@:%d", address.ip, (int)address.port); + } MTHttpWorker *httpWorker = [[MTHttpWorker alloc] initWithDelegate:delegate address:address payloadData:data performsLongPolling:false]; - return [[SBlockDisposable alloc] initWithBlock:^ + return [[MTBlockDisposable alloc] initWithBlock:^ { [delegate description]; // keep reference [httpWorker stop]; @@ -141,7 +182,7 @@ typedef struct { }]; } -+ (SSignal *)discoverSchemeWithContext:(MTContext *)context addressList:(NSArray *)addressList media:(bool)media ++ (MTSignal *)discoverSchemeWithContext:(MTContext *)context addressList:(NSArray *)addressList media:(bool)media { NSMutableArray *bestAddressList = [[NSMutableArray alloc] init]; @@ -165,52 +206,52 @@ typedef struct { if ([self isIpv6:address.ip]) { - SSignal *signal = [[[[self tcpConnectionWithContext:context datacenterId:0 address:address] then:[SSignal single:tcpTransportScheme]] timeout:5.0 onQueue:[SQueue concurrentDefaultQueue] orSignal:[SSignal fail:nil]] catch:^SSignal *(__unused id error) + MTSignal *signal = [[[[self tcpConnectionWithContext:context datacenterId:0 address:address] then:[MTSignal single:tcpTransportScheme]] timeout:5.0 onQueue:[MTQueue concurrentDefaultQueue] orSignal:[MTSignal fail:nil]] catch:^MTSignal *(__unused id error) { - return [SSignal complete]; + return [MTSignal complete]; }]; [bestTcp6Signals addObject:signal]; } else { - SSignal *tcpConnectionWithTimeout = [[[self tcpConnectionWithContext:context datacenterId:0 address:address] then:[SSignal single:tcpTransportScheme]] timeout:5.0 onQueue:[SQueue concurrentDefaultQueue] orSignal:[SSignal fail:nil]]; - SSignal *signal = [tcpConnectionWithTimeout catch:^SSignal *(__unused id error) + MTSignal *tcpConnectionWithTimeout = [[[self tcpConnectionWithContext:context datacenterId:0 address:address] then:[MTSignal single:tcpTransportScheme]] timeout:5.0 onQueue:[MTQueue concurrentDefaultQueue] orSignal:[MTSignal fail:nil]]; + MTSignal *signal = [tcpConnectionWithTimeout catch:^MTSignal *(__unused id error) { - return [SSignal complete]; + return [MTSignal complete]; }]; [bestTcp4Signals addObject:signal]; } if (!address.restrictToTcp) { - SSignal *signal = [[[[self httpConnectionWithAddress:address] then:[SSignal single:httpTransportScheme]] timeout:5.0 onQueue:[SQueue concurrentDefaultQueue] orSignal:[SSignal fail:nil]] catch:^SSignal *(__unused id error) + MTSignal *signal = [[[[self httpConnectionWithAddress:address] then:[MTSignal single:httpTransportScheme]] timeout:5.0 onQueue:[MTQueue concurrentDefaultQueue] orSignal:[MTSignal fail:nil]] catch:^MTSignal *(__unused id error) { - return [SSignal complete]; + return [MTSignal complete]; }]; [bestHttpSignals addObject:signal]; } } - SSignal *repeatDelaySignal = [[SSignal complete] delay:1.0 onQueue:[SQueue concurrentDefaultQueue]]; - SSignal *optimalDelaySignal = [[SSignal complete] delay:30.0 onQueue:[SQueue concurrentDefaultQueue]]; + MTSignal *repeatDelaySignal = [[MTSignal complete] delay:1.0 onQueue:[MTQueue concurrentDefaultQueue]]; + MTSignal *optimalDelaySignal = [[MTSignal complete] delay:30.0 onQueue:[MTQueue concurrentDefaultQueue]]; - SSignal *firstTcp4Match = [[[[SSignal mergeSignals:bestTcp4Signals] then:repeatDelaySignal] restart] take:1]; - SSignal *firstTcp6Match = [[[[SSignal mergeSignals:bestTcp6Signals] then:repeatDelaySignal] restart] take:1]; - SSignal *firstHttpMatch = [[[[SSignal mergeSignals:bestHttpSignals] then:repeatDelaySignal] restart] take:1]; + MTSignal *firstTcp4Match = [[[[MTSignal mergeSignals:bestTcp4Signals] then:repeatDelaySignal] restart] take:1]; + MTSignal *firstTcp6Match = [[[[MTSignal mergeSignals:bestTcp6Signals] then:repeatDelaySignal] restart] take:1]; + MTSignal *firstHttpMatch = [[[[MTSignal mergeSignals:bestHttpSignals] then:repeatDelaySignal] restart] take:1]; - SSignal *optimalTcp4Match = [[[[SSignal mergeSignals:bestTcp4Signals] then:optimalDelaySignal] restart] take:1]; - SSignal *optimalTcp6Match = [[[[SSignal mergeSignals:bestTcp6Signals] then:optimalDelaySignal] restart] take:1]; + MTSignal *optimalTcp4Match = [[[[MTSignal mergeSignals:bestTcp4Signals] then:optimalDelaySignal] restart] take:1]; + MTSignal *optimalTcp6Match = [[[[MTSignal mergeSignals:bestTcp6Signals] then:optimalDelaySignal] restart] take:1]; - SSignal *anySignal = [[SSignal mergeSignals:@[firstTcp4Match, firstTcp6Match, firstHttpMatch]] take:1]; - SSignal *optimalSignal = [[SSignal mergeSignals:@[optimalTcp4Match, optimalTcp6Match]] take:1]; + MTSignal *anySignal = [[MTSignal mergeSignals:@[firstTcp4Match, firstTcp6Match, firstHttpMatch]] take:1]; + MTSignal *optimalSignal = [[MTSignal mergeSignals:@[optimalTcp4Match, optimalTcp6Match]] take:1]; - SSignal *signal = [anySignal mapToSignal:^SSignal *(MTTransportScheme *scheme) + MTSignal *signal = [anySignal mapToSignal:^MTSignal *(MTTransportScheme *scheme) { if (![scheme isOptimal]) { - return [[SSignal single:scheme] then:[optimalSignal delay:5.0 onQueue:[SQueue concurrentDefaultQueue]]]; + return [[MTSignal single:scheme] then:[optimalSignal delay:5.0 onQueue:[MTQueue concurrentDefaultQueue]]]; } else - return [SSignal single:scheme]; + return [MTSignal single:scheme]; }]; return signal; diff --git a/MTDisposable.h b/MTDisposable.h new file mode 100644 index 0000000000..07d9f91940 --- /dev/null +++ b/MTDisposable.h @@ -0,0 +1,26 @@ +#import + +@protocol MTDisposable + +- (void)dispose; + +@end + +@interface MTBlockDisposable : NSObject + +- (instancetype)initWithBlock:(void (^)())block; + +@end + +@interface MTMetaDisposable : NSObject + +- (void)setDisposable:(id)disposable; + +@end + +@interface MTDisposableSet : NSObject + +- (void)add:(id)disposable; +- (void)remove:(id)disposable; + +@end diff --git a/MTDisposable.m b/MTDisposable.m new file mode 100644 index 0000000000..356b419a1e --- /dev/null +++ b/MTDisposable.m @@ -0,0 +1,198 @@ +#import "MTDisposable.h" + +#import +#import + +@interface MTBlockDisposable () +{ + void *_block; +} + +@end + +@implementation MTBlockDisposable + +- (instancetype)initWithBlock:(void (^)())block +{ + self = [super init]; + if (self != nil) + { + _block = (__bridge_retained void *)[block copy]; + } + return self; +} + +- (void)dealloc +{ + void *block = _block; + if (block != NULL) + { + if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) + { + if (block != nil) + { + __strong id strongBlock = (__bridge_transfer id)block; + strongBlock = nil; + } + } + } +} + +- (void)dispose +{ + void *block = _block; + if (block != NULL) + { + if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) + { + if (block != nil) + { + __strong id strongBlock = (__bridge_transfer id)block; + ((dispatch_block_t)strongBlock)(); + strongBlock = nil; + } + } + } +} + +@end + +@interface MTMetaDisposable () +{ + OSSpinLock _lock; + bool _disposed; + id _disposable; +} + +@end + +@implementation MTMetaDisposable + +- (void)setDisposable:(id)disposable +{ + id previousDisposable = nil; + bool dispose = false; + + OSSpinLockLock(&_lock); + dispose = _disposed; + if (!dispose) + { + previousDisposable = _disposable; + _disposable = disposable; + } + OSSpinLockUnlock(&_lock); + + if (previousDisposable != nil) + [previousDisposable dispose]; + + if (dispose) + [disposable dispose]; +} + +- (void)dispose +{ + id disposable = nil; + + OSSpinLockLock(&_lock); + if (!_disposed) + { + disposable = _disposable; + _disposed = true; + } + OSSpinLockUnlock(&_lock); + + if (disposable != nil) + [disposable dispose]; +} + +@end + +@interface MTDisposableSet () +{ + OSSpinLock _lock; + bool _disposed; + id _singleDisposable; + NSArray *_multipleDisposables; +} + +@end + +@implementation MTDisposableSet + +- (void)add:(id)disposable +{ + if (disposable == nil) + return; + + bool dispose = false; + + OSSpinLockLock(&_lock); + dispose = _disposed; + if (!dispose) + { + if (_multipleDisposables != nil) + { + NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables]; + [multipleDisposables addObject:disposable]; + _multipleDisposables = multipleDisposables; + } + else if (_singleDisposable != nil) + { + NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithObjects:_singleDisposable, disposable, nil]; + _multipleDisposables = multipleDisposables; + _singleDisposable = nil; + } + else + { + _singleDisposable = disposable; + } + } + OSSpinLockUnlock(&_lock); + + if (dispose) + [disposable dispose]; +} + +- (void)remove:(id)disposable { + OSSpinLockLock(&_lock); + if (_multipleDisposables != nil) + { + NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables]; + [multipleDisposables removeObject:disposable]; + _multipleDisposables = multipleDisposables; + } + else if (_singleDisposable == disposable) + { + _singleDisposable = nil; + } + OSSpinLockUnlock(&_lock); +} + +- (void)dispose +{ + id singleDisposable = nil; + NSArray *multipleDisposables = nil; + + OSSpinLockLock(&_lock); + if (!_disposed) + { + _disposed = true; + singleDisposable = _singleDisposable; + multipleDisposables = _multipleDisposables; + _singleDisposable = nil; + _multipleDisposables = nil; + } + OSSpinLockUnlock(&_lock); + + if (singleDisposable != nil) + [singleDisposable dispose]; + if (multipleDisposables != nil) + { + for (id disposable in multipleDisposables) + { + [disposable dispose]; + } + } +} + +@end diff --git a/MTNetworkUsageCalculationInfo.h b/MTNetworkUsageCalculationInfo.h new file mode 100644 index 0000000000..ba3bce666f --- /dev/null +++ b/MTNetworkUsageCalculationInfo.h @@ -0,0 +1,15 @@ +#import + +@class MTQueue; + +@interface MTNetworkUsageCalculationInfo : NSObject + +@property (nonatomic, strong, readonly) NSString *filePath; +@property (nonatomic, readonly) int32_t incomingWWANKey; +@property (nonatomic, readonly) int32_t outgoingWWANKey; +@property (nonatomic, readonly) int32_t incomingOtherKey; +@property (nonatomic, readonly) int32_t outgoingOtherKey; + +- (instancetype)initWithFilePath:(NSString *)filePath incomingWWANKey:(int32_t)incomingWWANKey outgoingWWANKey:(int32_t)outgoingWWANKey incomingOtherKey:(int32_t)incomingOtherKey outgoingOtherKey:(int32_t)outgoingOtherKey; + +@end diff --git a/MTNetworkUsageCalculationInfo.m b/MTNetworkUsageCalculationInfo.m new file mode 100644 index 0000000000..1650e44970 --- /dev/null +++ b/MTNetworkUsageCalculationInfo.m @@ -0,0 +1,17 @@ +#import "MTNetworkUsageCalculationInfo.h" + +@implementation MTNetworkUsageCalculationInfo + +- (instancetype)initWithFilePath:(NSString *)filePath incomingWWANKey:(int32_t)incomingWWANKey outgoingWWANKey:(int32_t)outgoingWWANKey incomingOtherKey:(int32_t)incomingOtherKey outgoingOtherKey:(int32_t)outgoingOtherKey { + self = [super init]; + if (self != nil) { + _filePath = filePath; + _incomingWWANKey = incomingWWANKey; + _outgoingWWANKey = outgoingWWANKey; + _incomingOtherKey = incomingOtherKey; + _outgoingOtherKey = outgoingOtherKey; + } + return self; +} + +@end diff --git a/MTNetworkUsageManager.h b/MTNetworkUsageManager.h new file mode 100644 index 0000000000..d9d2b401f6 --- /dev/null +++ b/MTNetworkUsageManager.h @@ -0,0 +1,26 @@ +#import + +@class MTSignal; +@class MTNetworkUsageCalculationInfo; + +typedef enum { + MTNetworkUsageManagerInterfaceWWAN, + MTNetworkUsageManagerInterfaceOther +} MTNetworkUsageManagerInterface; + +typedef struct { + NSUInteger incomingBytes; + NSUInteger outgoingBytes; +} MTNetworkUsageManagerInterfaceStats; + +@interface MTNetworkUsageManager : NSObject + +- (instancetype)initWithInfo:(MTNetworkUsageCalculationInfo *)info; + +- (void)addIncomingBytes:(NSUInteger)incomingBytes interface:(MTNetworkUsageManagerInterface)interface; +- (void)addOutgoingBytes:(NSUInteger)outgoingBytes interface:(MTNetworkUsageManagerInterface)interface; + +- (void)resetKeys:(NSArray *)keys completion:(void (^)())completion; +- (MTSignal *)currentStatsForKeys:(NSArray *)keys; + +@end diff --git a/MTNetworkUsageManager.m b/MTNetworkUsageManager.m new file mode 100644 index 0000000000..816482459d --- /dev/null +++ b/MTNetworkUsageManager.m @@ -0,0 +1,140 @@ +#import "MTNetworkUsageManager.h" + +#include +#import + +#if defined(MtProtoKitDynamicFramework) +# import +# import +# import +# import +#elif defined(MtProtoKitMacFramework) +# import +# import +# import +# import +#else +# import +# import +# import +# import +#endif + +@interface MTNetworkUsageManager () { + MTQueue *_queue; + MTNetworkUsageCalculationInfo *_info; + + NSUInteger _pendingIncomingBytes; + NSUInteger _pendingOutgoingBytes; + + int _fd; + void *_map; +} + +@end + +@implementation MTNetworkUsageManager + +- (instancetype)initWithInfo:(MTNetworkUsageCalculationInfo *)info { + self = [super init]; + if (self != nil) { + _queue = [[MTQueue alloc] init]; + _info = info; + + NSString *path = info.filePath; + int32_t fd = open([path UTF8String], O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + if (fd >= 0) { + _fd = fd; + ftruncate(fd, 4096); + void *map = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (map != MAP_FAILED) { + _map = map; + } + } + } + return self; +} + +- (void)dealloc { + void *map = _map; + int32_t fd = _fd; + [_queue dispatchOnQueue:^{ + if (map) { + munmap(map, 4096); + } + if (fd > 0) { + close(fd); + } + }]; +} + +static int offsetForInterface(MTNetworkUsageCalculationInfo *info, MTNetworkUsageManagerInterface interface, bool incoming) { + switch (interface) { + case MTNetworkUsageManagerInterfaceWWAN: + if (incoming) { + return info.incomingWWANKey * 8; + } else { + return info.outgoingWWANKey * 8; + } + case MTNetworkUsageManagerInterfaceOther: + if (incoming) { + return info.incomingOtherKey * 8; + } else { + return info.outgoingOtherKey * 8; + } + } +} + +- (void)addIncomingBytes:(NSUInteger)incomingBytes interface:(MTNetworkUsageManagerInterface)interface { + [_queue dispatchOnQueue:^{ + if (_map) { + int64_t *ptr = (int64_t *)(_map + offsetForInterface(_info, interface, true)); + OSAtomicAdd64((int64_t)incomingBytes, ptr); + } + }]; +} + +- (void)addOutgoingBytes:(NSUInteger)outgoingBytes interface:(MTNetworkUsageManagerInterface)interface { + [_queue dispatchOnQueue:^{ + if (_map) { + int64_t *ptr = (int64_t *)(_map + offsetForInterface(_info, interface, false)); + OSAtomicAdd64((int64_t)outgoingBytes, ptr); + } + }]; +} + +- (void)resetKeys:(NSArray *)keys completion:(void (^)())completion { + [_queue dispatchOnQueue:^{ + if (_map) { + for (NSNumber *key in keys) { + int64_t *ptr = (int64_t *)(_map + [key intValue] * 8); + *ptr = 0; + } + if (completion) { + completion(); + } + } + }]; +} + +- (MTSignal *)currentStatsForKeys:(NSArray *)keys { + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) { + [_queue dispatchOnQueue:^{ + if (_map) { + NSMutableDictionary *result = [[NSMutableDictionary alloc] init]; + for (NSNumber *key in keys) { + int64_t *ptr = (int64_t *)(_map + [key intValue] * 8); + result[key] = @(*ptr); + } + + [subscriber putNext:result]; + } else { + [subscriber putNext:nil]; + } + [subscriber putCompletion]; + }]; + return nil; + }]; +} + +@end diff --git a/MTProtoKit/Info.plist b/MTProtoKit/Info.plist index f6228f96e7..d3de8eefb6 100644 --- a/MTProtoKit/Info.plist +++ b/MTProtoKit/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.telegram.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/MTProtoKit/MTApiEnvironment.m b/MTProtoKit/MTApiEnvironment.m index 09f6f615c4..400d590744 100644 --- a/MTProtoKit/MTApiEnvironment.m +++ b/MTProtoKit/MTApiEnvironment.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTApiEnvironment.h" #if TARGET_OS_IPHONE # import @@ -31,6 +31,8 @@ #define IPHONE_6Plus_NAMESTRING @"iPhone 6 Plus" #define IPHONE_6S_NAMESTRING @"iPhone 6S" #define IPHONE_6SPlus_NAMESTRING @"iPhone 6S Plus" +#define IPHONE_7_NAMESTRING @"iPhone 7" +#define IPHONE_7Plus_NAMESTRING @"iPhone 7 Plus" #define IPHONE_UNKNOWN_NAMESTRING @"Unknown iPhone" #define IPOD_1G_NAMESTRING @"iPod touch 1G" @@ -79,6 +81,8 @@ typedef enum { UIDevice6PlusiPhone, UIDevice6siPhone, UIDevice6SPlusiPhone, + UIDevice7iPhone, + UIDevice7PlusiPhone, UIDevice1GiPod, UIDevice2GiPod, @@ -136,11 +140,27 @@ typedef enum { _langCode = [[NSLocale preferredLanguages] objectAtIndex:0]; - _apiInitializationHash = [[NSString alloc] initWithFormat:@"apiId=%" PRId32 "&deviceModel=%@&systemVersion=%@&appVersion=%@&langCode=%@&layer=%@", _apiId, _deviceModel, _systemVersion, _appVersion, _langCode, _layer]; + [self _updateApiInitializationHash]; } return self; } +- (void)_updateApiInitializationHash { + _apiInitializationHash = [[NSString alloc] initWithFormat:@"apiId=%" PRId32 "&deviceModel=%@&systemVersion=%@&appVersion=%@&langCode=%@&layer=%@", _apiId, _deviceModel, _systemVersion, _appVersion, _langCode, _layer]; +} + +- (void)setLayer:(NSNumber *)layer { + _layer = layer; + + [self _updateApiInitializationHash]; +} + +- (void)setAppVersion:(NSString *)appVersion { + _appVersion = appVersion; + + [self _updateApiInitializationHash]; +} + - (NSString *)platformString { switch ([self platformType]) @@ -156,6 +176,8 @@ typedef enum { case UIDevice6PlusiPhone: return IPHONE_6Plus_NAMESTRING; case UIDevice6siPhone: return IPHONE_6S_NAMESTRING; case UIDevice6SPlusiPhone: return IPHONE_6SPlus_NAMESTRING; + case UIDevice7iPhone: return IPHONE_7_NAMESTRING; + case UIDevice7PlusiPhone: return IPHONE_7Plus_NAMESTRING; case UIDeviceUnknowniPhone: return IPHONE_UNKNOWN_NAMESTRING; case UIDevice1GiPod: return IPOD_1G_NAMESTRING; @@ -212,6 +234,8 @@ typedef enum { if ([platform isEqualToString:@"iPhone7,2"]) return UIDevice6iPhone; if ([platform isEqualToString:@"iPhone8,1"]) return UIDevice6siPhone; if ([platform isEqualToString:@"iPhone8,2"]) return UIDevice6SPlusiPhone; + if ([platform isEqualToString:@"iPhone9,3"]) return UIDevice7iPhone; + if ([platform isEqualToString:@"iPhone9,2"]) return UIDevice7PlusiPhone; // iPod if ([platform hasPrefix:@"iPod1"]) return UIDevice1GiPod; @@ -240,8 +264,7 @@ typedef enum { // Simulator thanks Jordan Breeding if ([platform hasSuffix:@"86"] || [platform isEqual:@"x86_64"]) { - BOOL smallerScreen = [[UIScreen mainScreen] bounds].size.width < 768; - return smallerScreen ? UIDeviceSimulatoriPhone : UIDeviceSimulatoriPad; + return UIDeviceSimulatoriPhone; } #else return UIDeviceOSX; diff --git a/MTProtoKit/MTContext.m b/MTProtoKit/MTContext.m index e49304d415..48157ec4bb 100644 --- a/MTProtoKit/MTContext.m +++ b/MTProtoKit/MTContext.m @@ -6,33 +6,45 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTContext.h" #import -#import -#import -#import -#import +#import "MTLogging.h" +#import "MTTimer.h" +#import "MTQueue.h" +#import "MTKeychain.h" -#import -#import -#import -#import +#import "MTDatacenterAddressSet.h" +#import "MTDatacenterAddress.h" +#import "MTDatacenterAuthInfo.h" +#import "MTDatacenterSaltInfo.h" +#import "MTSessionInfo.h" -#import -#import -#import +#import "MTDiscoverDatacenterAddressAction.h" +#import "MTDatacenterAuthAction.h" +#import "MTDatacenterTransferAuthAction.h" -#import -#import +#import "MTTransportScheme.h" +#import "MTTcpTransport.h" -#import +#import "MTApiEnvironment.h" #import #import "MTDiscoverConnectionSignals.h" +#if defined(MtProtoKitDynamicFramework) +# import +# import +#elif defined(MtProtoKitMacFramework) +# import +# import +#else +# import +# import +#endif + @implementation MTContextBlockChangeListener - (void)contextIsPasswordRequiredUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId @@ -63,7 +75,6 @@ NSMutableArray *_changeListeners; NSMutableDictionary *_discoverDatacenterAddressActions; - NSMutableDictionary *_discoverDatacenterTransportSchemeActions; NSMutableDictionary *_datacenterAuthActions; NSMutableDictionary *_datacenterTransferAuthActions; @@ -121,7 +132,6 @@ _changeListeners = [[NSMutableArray alloc] init]; _discoverDatacenterAddressActions = [[NSMutableDictionary alloc] init]; - _discoverDatacenterTransportSchemeActions = [[NSMutableDictionary alloc] init]; _datacenterAuthActions = [[NSMutableDictionary alloc] init]; _datacenterTransferAuthActions = [[NSMutableDictionary alloc] init]; @@ -159,9 +169,6 @@ NSDictionary *discoverDatacenterAddressActions = _discoverDatacenterAddressActions; _discoverDatacenterAddressActions = nil; - NSDictionary *discoverDatacenterTransportSchemeActions = _discoverDatacenterTransportSchemeActions; - _discoverDatacenterTransportSchemeActions = nil; - NSDictionary *datacenterTransferAuthActions = _datacenterTransferAuthActions; _datacenterTransferAuthActions = nil; @@ -288,7 +295,9 @@ { _globalTimeDifference = globalTimeDifference; - MTLog(@"[MTContext#%x: global time difference changed: %.1fs]", (int)self, globalTimeDifference); + if (MTLogEnabled()) { + MTLog(@"[MTContext#%x: global time difference changed: %.1fs]", (int)self, globalTimeDifference); + } [_keychain setObject:@(_globalTimeDifference) forKey:@"globalTimeDifference" group:@"temp"]; }]; @@ -308,7 +317,9 @@ { if (addressSet != nil && datacenterId != 0) { - MTLog(@"[MTContext#%x: address set updated for %d]", (int)self, datacenterId); + if (MTLogEnabled()) { + MTLog(@"[MTContext#%x: address set updated for %d]", (int)self, datacenterId); + } bool previousAddressSetWasEmpty = ((MTDatacenterAddressSet *)_datacenterAddressSetById[@(datacenterId)]).addressList.count == 0; @@ -359,7 +370,9 @@ if (updated) { - MTLog(@"[MTContext#%x: added address %@ for datacenter %d]", (int)self, address, datacenterId); + if (MTLogEnabled()) { + MTLog(@"[MTContext#%x: added address %@ for datacenter %d]", (int)self, address, datacenterId); + } _datacenterAddressSetById[@(datacenterId)] = addressSet; [_keychain setObject:_datacenterAddressSetById forKey:@"datacenterAddressSetById" group:@"persistent"]; @@ -381,7 +394,9 @@ { if (authInfo != nil && datacenterId != 0) { - MTLog(@"[MTContext#%x: auth info updated for %d]", (int)self, datacenterId); + if (MTLogEnabled()) { + MTLog(@"[MTContext#%x: auth info updated for %d]", (int)self, datacenterId); + } _datacenterAuthInfoById[@(datacenterId)] = authInfo; [_keychain setObject:_datacenterAuthInfoById forKey:@"datacenterAuthInfoById" group:@"persistent"]; @@ -461,7 +476,9 @@ if (currentScheme != nil && (previousScheme == nil || ![previousScheme isEqualToScheme:currentScheme])) { - MTLog(@"[MTContext#%x: %@ transport scheme updated for %d: %@]", (int)self, media ? @"media" : @"generic", datacenterId, transportScheme); + if (MTLogEnabled()) { + MTLog(@"[MTContext#%x: %@ transport scheme updated for %d: %@]", (int)self, media ? @"media" : @"generic", datacenterId, transportScheme); + } for (id listener in currentListeners) { @@ -748,7 +765,7 @@ { if (_transportSchemeDisposableByDatacenterId == nil) _transportSchemeDisposableByDatacenterId = [[NSMutableDictionary alloc] init]; - id disposable = _transportSchemeDisposableByDatacenterId[@(datacenterId)]; + id disposable = _transportSchemeDisposableByDatacenterId[@(datacenterId)]; if (disposable == nil) { __weak MTContext *weakSelf = self; @@ -765,7 +782,9 @@ } }] startWithNext:^(id next) { - MTLog(@"scheme: %@", next); + if (MTLogEnabled()) { + MTLog(@"scheme: %@", next); + } __strong MTContext *strongSelf = weakSelf; if (strongSelf != nil) { @@ -801,7 +820,7 @@ { if (_transportSchemeDisposableByDatacenterId == nil) _transportSchemeDisposableByDatacenterId = [[NSMutableDictionary alloc] init]; - id disposable = _transportSchemeDisposableByDatacenterId[@(datacenterId)]; + id disposable = _transportSchemeDisposableByDatacenterId[@(datacenterId)]; [disposable dispose]; [_transportSchemeDisposableByDatacenterId removeObjectForKey:@(datacenterId)]; } diff --git a/MTProtoKit/MTDatacenterAddress.m b/MTProtoKit/MTDatacenterAddress.m index 4a11ab751e..03eb91a7de 100644 --- a/MTProtoKit/MTDatacenterAddress.m +++ b/MTProtoKit/MTDatacenterAddress.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDatacenterAddress.h" #import #import diff --git a/MTProtoKit/MTDatacenterAddressSet.h b/MTProtoKit/MTDatacenterAddressSet.h index 9eea4963eb..987e5ca93a 100644 --- a/MTProtoKit/MTDatacenterAddressSet.h +++ b/MTProtoKit/MTDatacenterAddressSet.h @@ -6,7 +6,9 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import + +@class MTDatacenterAddress; @interface MTDatacenterAddressSet : NSObject diff --git a/MTProtoKit/MTDatacenterAddressSet.m b/MTProtoKit/MTDatacenterAddressSet.m index 868a08438b..b29137772b 100644 --- a/MTProtoKit/MTDatacenterAddressSet.m +++ b/MTProtoKit/MTDatacenterAddressSet.m @@ -6,7 +6,9 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDatacenterAddressSet.h" + +#import "MTDatacenterAddress.h" @implementation MTDatacenterAddressSet diff --git a/MTProtoKit/MTDatacenterAuthAction.m b/MTProtoKit/MTDatacenterAuthAction.m index fbb6ce3583..871cf96730 100644 --- a/MTProtoKit/MTDatacenterAuthAction.m +++ b/MTProtoKit/MTDatacenterAuthAction.m @@ -6,14 +6,14 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDatacenterAuthAction.h" -#import -#import -#import -#import +#import "MTContext.h" +#import "MTProto.h" +#import "MTRequest.h" +#import "MTDatacenterSaltInfo.h" -#import +#import "MTDatacenterAuthMessageService.h" @interface MTDatacenterAuthAction () { @@ -44,7 +44,7 @@ [self complete]; else { - _authMtProto = [[MTProto alloc] initWithContext:context datacenterId:_datacenterId]; + _authMtProto = [[MTProto alloc] initWithContext:context datacenterId:_datacenterId usageCalculationInfo:nil]; _authMtProto.useUnauthorizedMode = true; MTDatacenterAuthMessageService *authService = [[MTDatacenterAuthMessageService alloc] initWithContext:context]; diff --git a/MTProtoKit/MTDatacenterAuthInfo.m b/MTProtoKit/MTDatacenterAuthInfo.m index a6dcbd3eb9..42c904ca29 100644 --- a/MTProtoKit/MTDatacenterAuthInfo.m +++ b/MTProtoKit/MTDatacenterAuthInfo.m @@ -6,9 +6,8 @@ * Copyright Peter Iakovlev, 2013. */ -#import - -#import +#import "MTDatacenterAuthInfo.h" +#import "MTDatacenterSaltInfo.h" @implementation MTDatacenterAuthInfo diff --git a/MTProtoKit/MTDatacenterAuthMessageService.h b/MTProtoKit/MTDatacenterAuthMessageService.h index 452504e391..8cdf696592 100644 --- a/MTProtoKit/MTDatacenterAuthMessageService.h +++ b/MTProtoKit/MTDatacenterAuthMessageService.h @@ -6,7 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @class MTContext; @class MTDatacenterAuthMessageService; diff --git a/MTProtoKit/MTDatacenterAuthMessageService.m b/MTProtoKit/MTDatacenterAuthMessageService.m index 98aac50f3e..a079efebf2 100644 --- a/MTProtoKit/MTDatacenterAuthMessageService.m +++ b/MTProtoKit/MTDatacenterAuthMessageService.m @@ -6,27 +6,27 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDatacenterAuthMessageService.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "MTLogging.h" +#import "MTContext.h" +#import "MTProto.h" +#import "MTSerialization.h" +#import "MTSessionInfo.h" +#import "MTIncomingMessage.h" +#import "MTOutgoingMessage.h" +#import "MTMessageTransaction.h" +#import "MTPreparedMessage.h" +#import "MTDatacenterAuthInfo.h" +#import "MTDatacenterSaltInfo.h" +#import "MTBuffer.h" +#import "MTEncryption.h" -#import -#import -#import -#import -#import +#import "MTInternalMessageParser.h" +#import "MTServerDhInnerDataMessage.h" +#import "MTResPqMessage.h" +#import "MTServerDhParamsMessage.h" +#import "MTSetClientDhParamsResponseMessage.h" static NSDictionary *selectPublicKey(NSArray *fingerprints) { @@ -178,7 +178,7 @@ typedef enum { if (_nonce == nil) { uint8_t nonceBytes[16]; - SecRandomCopyBytes(kSecRandomDefault, 16, nonceBytes); + __unused int result = SecRandomCopyBytes(kSecRandomDefault, 16, nonceBytes); _nonce = [[NSData alloc] initWithBytes:nonceBytes length:16]; } @@ -260,7 +260,9 @@ typedef enum { NSDictionary *publicKey = selectPublicKey(resPqMessage.serverPublicKeyFingerprints); if (publicKey == nil) { - MTLog(@"[MTDatacenterAuthMessageService#%p couldn't find valid server public key]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p couldn't find valid server public key]", self); + } [self reset:mtProto]; } else @@ -306,7 +308,7 @@ typedef enum { _dhPublicKeyFingerprint = [[publicKey objectForKey:@"fingerprint"] longLongValue]; uint8_t nonceBytes[32]; - SecRandomCopyBytes(kSecRandomDefault, 32, nonceBytes); + __unused int result = SecRandomCopyBytes(kSecRandomDefault, 32, nonceBytes); _newNonce = [[NSData alloc] initWithBytes:nonceBytes length:32]; MTBuffer *innerDataBuffer = [[MTBuffer alloc] init]; @@ -414,7 +416,9 @@ typedef enum { if (!hashVerified) { - MTLog(@"[MTDatacenterAuthMessageService#%p couldn't decode DH params]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p couldn't decode DH params]", self); + } [self reset:mtProto]; return; @@ -424,7 +428,9 @@ typedef enum { if (![dhInnerData isKindOfClass:[MTServerDhInnerDataMessage class]]) { - MTLog(@"[MTDatacenterAuthMessageService#%p couldn't parse decoded DH params]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p couldn't parse decoded DH params]", self); + } [self reset:mtProto]; return; @@ -432,7 +438,9 @@ typedef enum { if (![_nonce isEqualToData:dhInnerData.nonce]) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH nonce]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH nonce]", self); + } [self reset:mtProto]; return; @@ -440,7 +448,9 @@ typedef enum { if (![_serverNonce isEqualToData:dhInnerData.serverNonce]) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH server nonce]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH server nonce]", self); + } [self reset:mtProto]; return; @@ -449,7 +459,9 @@ typedef enum { int32_t innerDataG = dhInnerData.g; if (innerDataG < 0 || !MTCheckIsSafeG((unsigned int)innerDataG)) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH g]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH g]", self); + } [self reset:mtProto]; return; @@ -459,7 +471,9 @@ typedef enum { NSData *innerDataDhPrime = dhInnerData.dhPrime; if (!MTCheckIsSafeGAOrB(innerDataGA, innerDataDhPrime)) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH g_a]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH g_a]", self); + } [self reset:mtProto]; return; @@ -467,7 +481,9 @@ typedef enum { if (!MTCheckMod(innerDataDhPrime, (unsigned int)innerDataG, mtProto.context.keychain)) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH g (2)]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH g (2)]", self); + } [self reset:mtProto]; return; @@ -475,14 +491,16 @@ typedef enum { if (!MTCheckIsSafePrime(innerDataDhPrime, mtProto.context.keychain)) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH prime]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH prime]", self); + } [self reset:mtProto]; return; } uint8_t bBytes[256]; - SecRandomCopyBytes(kSecRandomDefault, 256, bBytes); + __unused int result = SecRandomCopyBytes(kSecRandomDefault, 256, bBytes); NSData *b = [[NSData alloc] initWithBytes:bBytes length:256]; int32_t tmpG = innerDataG; @@ -536,7 +554,9 @@ typedef enum { } else { - MTLog(@"[MTDatacenterAuthMessageService#%p couldn't set DH params]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p couldn't set DH params]", self); + } [self reset:mtProto]; } } @@ -578,7 +598,9 @@ typedef enum { { if (![newNonceHash1 isEqualToData:((MTSetClientDhParamsResponseOkMessage *)setClientDhParamsResponseMessage).nextNonceHash1]) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH answer nonce hash 1]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH answer nonce hash 1]", self); + } [self reset:mtProto]; } else @@ -597,12 +619,16 @@ typedef enum { { if (![newNonceHash2 isEqualToData:((MTSetClientDhParamsResponseRetryMessage *)setClientDhParamsResponseMessage).nextNonceHash2]) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH answer nonce hash 2]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH answer nonce hash 2]", self); + } [self reset:mtProto]; } else { - MTLog(@"[MTDatacenterAuthMessageService#%p retry DH]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p retry DH]", self); + } [self reset:mtProto]; } } @@ -610,18 +636,24 @@ typedef enum { { if (![newNonceHash3 isEqualToData:((MTSetClientDhParamsResponseFailMessage *)setClientDhParamsResponseMessage).nextNonceHash3]) { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH answer nonce hash 3]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH answer nonce hash 3]", self); + } [self reset:mtProto]; } else { - MTLog(@"[MTDatacenterAuthMessageService#%p server rejected DH params]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p server rejected DH params]", self); + } [self reset:mtProto]; } } else { - MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH params response]", self); + if (MTLogEnabled()) { + MTLog(@"[MTDatacenterAuthMessageService#%p invalid DH params response]", self); + } [self reset:mtProto]; } } diff --git a/MTProtoKit/MTDatacenterSaltInfo.m b/MTProtoKit/MTDatacenterSaltInfo.m index 8a3d24d745..fd0225b93e 100644 --- a/MTProtoKit/MTDatacenterSaltInfo.m +++ b/MTProtoKit/MTDatacenterSaltInfo.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDatacenterSaltInfo.h" @implementation MTDatacenterSaltInfo diff --git a/MTProtoKit/MTDatacenterTransferAuthAction.m b/MTProtoKit/MTDatacenterTransferAuthAction.m index 86758057e7..af1c74f79f 100644 --- a/MTProtoKit/MTDatacenterTransferAuthAction.m +++ b/MTProtoKit/MTDatacenterTransferAuthAction.m @@ -6,14 +6,14 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDatacenterTransferAuthAction.h" -#import -#import -#import -#import -#import -#import +#import "MTContext.h" +#import "MTSerialization.h" +#import "MTProto.h" +#import "MTRequestMessageService.h" +#import "MTRequest.h" +#import "MTBuffer.h" @interface MTDatacenterTransferAuthAction () { @@ -90,7 +90,7 @@ return; } - _sourceDatacenterMtProto = [[MTProto alloc] initWithContext:context datacenterId:sourceDatacenterId]; + _sourceDatacenterMtProto = [[MTProto alloc] initWithContext:context datacenterId:sourceDatacenterId usageCalculationInfo:nil]; MTRequestMessageService *requestService = [[MTRequestMessageService alloc] initWithContext:context]; [_sourceDatacenterMtProto addMessageService:requestService]; @@ -126,7 +126,7 @@ _sourceDatacenterMtProto = nil; MTContext *context = _context; - _destinationDatacenterMtProto = [[MTProto alloc] initWithContext:context datacenterId:_destinationDatacenterId]; + _destinationDatacenterMtProto = [[MTProto alloc] initWithContext:context datacenterId:_destinationDatacenterId usageCalculationInfo:nil]; MTRequestMessageService *requestService = [[MTRequestMessageService alloc] initWithContext:context]; [_destinationDatacenterMtProto addMessageService:requestService]; diff --git a/MTProtoKit/MTDiscoverDatacenterAddressAction.h b/MTProtoKit/MTDiscoverDatacenterAddressAction.h index 3eb7ae244b..58352d78a4 100644 --- a/MTProtoKit/MTDiscoverDatacenterAddressAction.h +++ b/MTProtoKit/MTDiscoverDatacenterAddressAction.h @@ -24,4 +24,4 @@ - (void)execute:(MTContext *)context datacenterId:(NSInteger)datacenterId; - (void)cancel; -@end \ No newline at end of file +@end diff --git a/MTProtoKit/MTDiscoverDatacenterAddressAction.m b/MTProtoKit/MTDiscoverDatacenterAddressAction.m index 791b9295dd..a1acfd7a90 100644 --- a/MTProtoKit/MTDiscoverDatacenterAddressAction.m +++ b/MTProtoKit/MTDiscoverDatacenterAddressAction.m @@ -6,14 +6,14 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDiscoverDatacenterAddressAction.h" -#import -#import -#import -#import -#import -#import +#import "MTContext.h" +#import "MTSerialization.h" +#import "MTProto.h" +#import "MTDatacenterAddressSet.h" +#import "MTRequestMessageService.h" +#import "MTRequest.h" @interface MTDiscoverDatacenterAddressAction () { @@ -98,7 +98,7 @@ { if ([context authInfoForDatacenterWithId:_targetDatacenterId] != nil) { - _mtProto = [[MTProto alloc] initWithContext:context datacenterId:_targetDatacenterId]; + _mtProto = [[MTProto alloc] initWithContext:context datacenterId:_targetDatacenterId usageCalculationInfo:nil]; _requestService = [[MTRequestMessageService alloc] initWithContext:_context]; [_mtProto addMessageService:_requestService]; diff --git a/MTProtoKit/MTDropResponseContext.m b/MTProtoKit/MTDropResponseContext.m index af460f08d5..13799be45a 100644 --- a/MTProtoKit/MTDropResponseContext.m +++ b/MTProtoKit/MTDropResponseContext.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTDropResponseContext.h" @implementation MTDropResponseContext diff --git a/MTProtoKit/MTEncryption.h b/MTProtoKit/MTEncryption.h index 6316d0b6fa..503664a4ed 100644 --- a/MTProtoKit/MTEncryption.h +++ b/MTProtoKit/MTEncryption.h @@ -24,7 +24,6 @@ int32_t MTMurMurHash32(const void *bytes, int length); void MTAesEncryptInplace(NSMutableData *data, NSData *key, NSData *iv); void MTAesEncryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableData *iv); -void MTAesDecryptInplace(NSMutableData *data, NSData *key, NSData *iv); void MTAesDecryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableData *iv); NSData *MTAesEncrypt(NSData *data, NSData *key, NSData *iv); NSData *MTAesDecrypt(NSData *data, NSData *key, NSData *iv); diff --git a/MTProtoKit/MTEncryption.m b/MTProtoKit/MTEncryption.m index 9fe7c4e628..b09fd4f314 100644 --- a/MTProtoKit/MTEncryption.m +++ b/MTProtoKit/MTEncryption.m @@ -6,23 +6,24 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTEncryption.h" -#import -#import +#import "MTLogging.h" +#import "MTKeychain.h" #import #import #include -#include -#include -#include -#include #include -#include -#include -#include + +#import "MTAes.h" +#import "MTRsa.h" + +#if TARGET_OS_IOS +#else +# include +#endif NSData *MTSha1(NSData *data) { @@ -166,78 +167,89 @@ int32_t MTMurMurHash32(const void *bytes, int length) void MTAesEncryptInplace(NSMutableData *data, NSData *key, NSData *iv) { - AES_KEY aesKey; - AES_set_encrypt_key(key.bytes, 256, &aesKey); - unsigned char aesIv[AES_BLOCK_SIZE * 2]; + unsigned char aesIv[16 * 2]; memcpy(aesIv, iv.bytes, iv.length); - AES_ige_encrypt(data.bytes, (void *)data.bytes, data.length, &aesKey, aesIv, true); + void *outData = malloc(data.length); + MyAesIgeEncrypt(data.bytes, (int)data.length, outData, key.bytes, (int)key.length, aesIv); + memcpy(data.mutableBytes, outData, data.length); + free(outData); } void MTAesEncryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableData *iv) { - AES_KEY aesKey; - AES_set_encrypt_key(key.bytes, 256, &aesKey); - - AES_ige_encrypt(data.bytes, (void *)data.bytes, data.length, &aesKey, iv.mutableBytes, true); -} - -void MTAesDecryptInplace(NSMutableData *data, NSData *key, NSData *iv) -{ - AES_KEY aesKey; - AES_set_decrypt_key(key.bytes, 256, &aesKey); - unsigned char aesIv[AES_BLOCK_SIZE * 2]; + unsigned char aesIv[16 * 2]; memcpy(aesIv, iv.bytes, iv.length); - AES_ige_encrypt(data.bytes, (void *)data.bytes, data.length, &aesKey, aesIv, false); + void *outData = malloc(data.length); + MyAesIgeEncrypt(data.bytes, (int)data.length, outData, key.bytes, (int)key.length, aesIv); + memcpy(data.mutableBytes, outData, data.length); + free(outData); + + memcpy(iv.mutableBytes, aesIv, 16 * 2); } void MTAesDecryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableData *iv) { - AES_KEY aesKey; - AES_set_decrypt_key(key.bytes, 256, &aesKey); + unsigned char aesIv[16 * 2]; + memcpy(aesIv, iv.bytes, iv.length); - AES_ige_encrypt(data.bytes, (void *)data.bytes, data.length, &aesKey, iv.mutableBytes, false); + void *outData = malloc(data.length); + MyAesIgeDecrypt(data.bytes, (int)data.length, outData, key.bytes, (int)key.length, aesIv); + memcpy(data.mutableBytes, outData, data.length); + free(outData); + + memcpy(iv.mutableBytes, aesIv, 16 * 2); } NSData *MTAesEncrypt(NSData *data, NSData *key, NSData *iv) { if (key == nil || iv == nil) { - MTLog(@"***** MTAesEncrypt: empty key or iv"); + if (MTLogEnabled()) { + MTLog(@"***** MTAesEncrypt: empty key or iv"); + } return nil; } - AES_KEY aesKey; - AES_set_encrypt_key(key.bytes, 256, &aesKey); - unsigned char aesIv[AES_BLOCK_SIZE * 2]; + + unsigned char aesIv[16 * 2]; memcpy(aesIv, iv.bytes, iv.length); - uint8_t *resultBytes = malloc(data.length); - AES_ige_encrypt(data.bytes, resultBytes, data.length, &aesKey, aesIv, true); - - return [[NSData alloc] initWithBytesNoCopy:resultBytes length:data.length freeWhenDone:true]; + void *outData = malloc(data.length); + MyAesIgeEncrypt(data.bytes, (int)data.length, outData, key.bytes, (int)key.length, aesIv); + return [[NSData alloc] initWithBytesNoCopy:outData length:data.length freeWhenDone:true]; } NSData *MTAesDecrypt(NSData *data, NSData *key, NSData *iv) { if (key == nil || iv == nil) { - MTLog(@"***** MTAesEncrypt: empty key or iv"); + if (MTLogEnabled()) { + MTLog(@"***** MTAesEncrypt: empty key or iv"); + } return nil; } - AES_KEY aesKey; - AES_set_decrypt_key(key.bytes, 256, &aesKey); - unsigned char aesIv[AES_BLOCK_SIZE * 2]; + + NSMutableData *resultData = [[NSMutableData alloc] initWithLength:data.length]; + + unsigned char aesIv[16 * 2]; memcpy(aesIv, iv.bytes, iv.length); + MyAesIgeDecrypt(data.bytes, (int)data.length, resultData.mutableBytes, key.bytes, (int)key.length, aesIv); - uint8_t *resultBytes = malloc(data.length); - AES_ige_encrypt(data.bytes, resultBytes, data.length, &aesKey, aesIv, false); - - return [[NSData alloc] initWithBytesNoCopy:resultBytes length:data.length freeWhenDone:true]; + return resultData; } NSData *MTRsaEncrypt(NSString *publicKey, NSData *data) { +#if TARGET_OS_IOS + + NSMutableData *updatedData = [[NSMutableData alloc] initWithData:data]; + while (updatedData.length < 256) { + uint8_t zero = 0; + [updatedData replaceBytesInRange:NSMakeRange(0, 0) withBytes:&zero length:1]; + } + return [MTRsa encryptData:updatedData publicKey:publicKey]; +#else BIO *keyBio = BIO_new(BIO_s_mem()); const char *keyData = [publicKey UTF8String]; BIO_write(keyBio, keyData, (int)publicKey.length); @@ -262,6 +274,7 @@ NSData *MTRsaEncrypt(NSString *publicKey, NSData *data) NSData *result = [[NSData alloc] initWithBytesNoCopy:res length:(NSUInteger)resLen freeWhenDone:true]; return result; +#endif } NSData *MTExp(NSData *base, NSData *exp, NSData *modulus) @@ -380,7 +393,9 @@ bool MTFactorize(uint64_t what, uint64_t *resA, uint64_t *resB) } else { - MTLog(@"Factorization failed for %lld", (long long int)what); + if (MTLogEnabled()) { + MTLog(@"Factorization failed for %lld", (long long int)what); + } return false; } diff --git a/MTProtoKit/MTFileBasedKeychain.h b/MTProtoKit/MTFileBasedKeychain.h index e4f36cd021..0a3a22ad4d 100644 --- a/MTProtoKit/MTFileBasedKeychain.h +++ b/MTProtoKit/MTFileBasedKeychain.h @@ -1,6 +1,12 @@ #import -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @interface MTFileBasedKeychain : NSObject diff --git a/MTProtoKit/MTFileBasedKeychain.m b/MTProtoKit/MTFileBasedKeychain.m index 307ef82668..24fe2c7f68 100644 --- a/MTProtoKit/MTFileBasedKeychain.m +++ b/MTProtoKit/MTFileBasedKeychain.m @@ -1,6 +1,6 @@ #import "MTFileBasedKeychain.h" -#import +#import "MTLogging.h" #import @@ -10,7 +10,7 @@ #define TG_SYNCHRONIZED_END(lock) pthread_mutex_unlock(&_TG_SYNCHRONIZED_##lock); #import -#import +#import "MTEncryption.h" static TG_SYNCHRONIZED_DEFINE(_keychains) = PTHREAD_MUTEX_INITIALIZER; static NSMutableDictionary *keychains() @@ -136,10 +136,11 @@ static NSMutableDictionary *keychains() { uint8_t buf[32]; - SecRandomCopyBytes(kSecRandomDefault, 32, buf); + int result = 0; + result = SecRandomCopyBytes(kSecRandomDefault, 32, buf); _aesKey = [[NSData alloc] initWithBytes:buf length:32]; - SecRandomCopyBytes(kSecRandomDefault, 32, buf); + result = SecRandomCopyBytes(kSecRandomDefault, 32, buf); _aesIv = [[NSData alloc] initWithBytes:buf length:32]; } @@ -192,8 +193,11 @@ static NSMutableDictionary *keychains() __autoreleasing NSError *error = nil; [[NSFileManager defaultManager] createDirectoryAtPath:dataDirectory withIntermediateDirectories:true attributes:nil error:&error]; - if (error != nil) - MTLog(@"[MTKeychain error creating keychain directory: %@]", error); + if (error != nil) { + if (MTLogEnabled()) { + MTLog(@"[MTKeychain error creating keychain directory: %@]", error); + } + } }); return [dataDirectory stringByAppendingPathComponent:[[NSString alloc] initWithFormat:@"%@_%@.bin", name, group]]; @@ -219,10 +223,16 @@ static NSMutableDictionary *keychains() if (data.length == 4 + paddedLength || data.length == 4 + paddedLength + 4) { - NSMutableData *decryptedData = [[NSMutableData alloc] init]; - [decryptedData appendData:[data subdataWithRange:NSMakeRange(4, paddedLength)]]; - if (_encrypted) - MTAesDecryptInplace(decryptedData, _aesKey, _aesIv); + NSMutableData *encryptedData = [[NSMutableData alloc] init]; + [encryptedData appendData:[data subdataWithRange:NSMakeRange(4, paddedLength)]]; + + NSMutableData *decryptedData = nil; + if (_encrypted) { + decryptedData = [[NSMutableData alloc] initWithData:MTAesDecrypt(encryptedData, _aesKey, _aesIv)]; + } else { + decryptedData = encryptedData; + } + [decryptedData setLength:length]; bool hashVerified = true; @@ -235,7 +245,9 @@ static NSMutableDictionary *keychains() int32_t decryptedHash = MTMurMurHash32(decryptedData.bytes, (int)decryptedData.length); if (hash != decryptedHash) { - MTLog(@"[MTKeychain invalid decrypted hash]"); + if (MTLogEnabled()) { + MTLog(@"[MTKeychain invalid decrypted hash]"); + } hashVerified = false; } } @@ -247,17 +259,25 @@ static NSMutableDictionary *keychains() id object = [NSKeyedUnarchiver unarchiveObjectWithData:decryptedData]; if ([object respondsToSelector:@selector(objectForKey:)] && [object respondsToSelector:@selector(setObject:forKey:)]) _dictByGroup[group] = object; - else - MTLog(@"[MTKeychain invalid root object %@]", object); + else { + if (MTLogEnabled()) { + MTLog(@"[MTKeychain invalid root object %@]", object); + } + } } @catch (NSException *e) { - MTLog(@"[MTKeychain error parsing keychain: %@]", e); + if (MTLogEnabled()) { + MTLog(@"[MTKeychain error parsing keychain: %@]", e); + } } } } - else - MTLog(@"[MTKeychain error loading keychain: expected data length %d, got %d]", 4 + (int)paddedLength, (int)data.length); + else { + if (MTLogEnabled()) { + MTLog(@"[MTKeychain error loading keychain: expected data length %d, got %d]", 4 + (int)paddedLength, (int)data.length); + } + } } } @@ -291,20 +311,29 @@ static NSMutableDictionary *keychains() [encryptedData appendBytes:&hash length:4]; NSString *filePath = [self filePathForName:_name group:group]; - if (![encryptedData writeToFile:filePath atomically:true]) - MTLog(@"[MTKeychain error writing keychain to file]"); + if (![encryptedData writeToFile:filePath atomically:true]) { + if (MTLogEnabled()) { + MTLog(@"[MTKeychain error writing keychain to file]"); + } + } else { #if TARGET_OS_IPHONE __autoreleasing NSError *error = nil; [[NSURL fileURLWithPath:filePath] setResourceValue:[NSNumber numberWithBool:true] forKey:NSURLIsExcludedFromBackupKey error:&error]; - if (error != nil) - MTLog(@"[MTKeychain error setting \"exclude from backup\" flag]"); + if (error != nil) { + if (MTLogEnabled()) { + MTLog(@"[MTKeychain error setting \"exclude from backup\" flag]"); + } + } #endif } } - else - MTLog(@"[MTKeychain error serializing keychain]"); + else { + if (MTLogEnabled()) { + MTLog(@"[MTKeychain error serializing keychain]"); + } + } } } diff --git a/MTProtoKit/MTHttpRequestOperation.h b/MTProtoKit/MTHttpRequestOperation.h new file mode 100644 index 0000000000..bd6c6f53ab --- /dev/null +++ b/MTProtoKit/MTHttpRequestOperation.h @@ -0,0 +1,9 @@ +#import + +@class MTSignal; + +@interface MTHttpRequestOperation : NSObject + ++ (MTSignal *)dataForHttpUrl:(NSURL *)url; + +@end diff --git a/MTProtoKit/MTHttpRequestOperation.m b/MTProtoKit/MTHttpRequestOperation.m new file mode 100644 index 0000000000..bbcad501a7 --- /dev/null +++ b/MTProtoKit/MTHttpRequestOperation.m @@ -0,0 +1,46 @@ +#import "MTHttpRequestOperation.h" + +#import "../thirdparty/AFNetworking/AFHTTPRequestOperation.h" + +#if defined(MtProtoKitDynamicFramework) +# import +# import +#elif defined(MtProtoKitMacFramework) +# import +# import +#else +# import +# import +#endif + +@implementation MTHttpRequestOperation + ++ (MTSignal *)dataForHttpUrl:(NSURL *)url { + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) { + NSURLRequest *request = [NSURLRequest requestWithURL:url]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + + [operation setSuccessCallbackQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; + [operation setFailureCallbackQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; + + [operation setCompletionBlockWithSuccess:^(__unused AFHTTPRequestOperation *operation, __unused id responseObject) + { + [subscriber putNext:[operation responseData]]; + [subscriber putCompletion]; + } failure:^(__unused AFHTTPRequestOperation *operation, __unused NSError *error) + { + [subscriber putError:nil]; + }]; + + [operation start]; + + __weak AFHTTPRequestOperation *weakOperation = operation; + + return [[MTBlockDisposable alloc] initWithBlock:^ + { + __strong AFHTTPRequestOperation *strongOperation = weakOperation; + [strongOperation cancel]; + }]; + }]; +} +@end diff --git a/MTProtoKit/MTHttpTransport.h b/MTProtoKit/MTHttpTransport.h index 2ec6eb66de..cfb815d0eb 100644 --- a/MTProtoKit/MTHttpTransport.h +++ b/MTProtoKit/MTHttpTransport.h @@ -6,7 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @interface MTHttpTransport : MTTransport diff --git a/MTProtoKit/MTHttpTransport.m b/MTProtoKit/MTHttpTransport.m index 0c74ca0a9f..36b40497e0 100644 --- a/MTProtoKit/MTHttpTransport.m +++ b/MTProtoKit/MTHttpTransport.m @@ -6,27 +6,29 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTHttpTransport.h" -#import -#import -#import +#import "MTLogging.h" +#import "MTQueue.h" +#import "MTTimer.h" -#import -#import +#import "MTDatacenterAddressSet.h" +#import "MTDatacenterAddress.h" -#import -#import -#import -#import -#import -#import +#import "MTSerialization.h" +#import "MTTransportTransaction.h" +#import "MTMessageTransaction.h" +#import "MTOutgoingMessage.h" +#import "MTIncomingMessage.h" +#import "MTPreparedMessage.h" -#import -#import +#import "MTHttpWorkerBehaviour.h" +#import "MTHttpWorker.h" -#import -#import +#import "MTBuffer.h" +#import "MTPongMessage.h" +#import "MTContext.h" +#import "MTDatacenterAuthInfo.h" @interface MTHttpTransport () { @@ -61,9 +63,9 @@ return queue; } -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { - self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address]; + self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address usageCalculationInfo:usageCalculationInfo]; if (self != nil) { _address = address; @@ -460,7 +462,9 @@ else if (transaction.payload.length != 0) { MTHttpWorker *worker = [[MTHttpWorker alloc] initWithDelegate:self address:_address payloadData:transaction.payload performsLongPolling:performsLongPolling && transactionIndex == 0]; - MTLog(@"[MTHttpTransport#%x spawn MTHttpWorker#%x(longPolling: %s), %d active]", (int)self, (int)worker, worker.performsLongPolling ? "1" : "0", _workers.count + 1); + if (MTLogEnabled()) { + MTLog(@"[MTHttpTransport#%x spawn MTHttpWorker#%x(longPolling: %s), %d active]", (int)self, (int)worker, worker.performsLongPolling ? "1" : "0", _workers.count + 1); + } worker.delegate = self; if (_workers == nil) diff --git a/MTProtoKit/MTHttpWorker.m b/MTProtoKit/MTHttpWorker.m index a05e353689..8732083027 100644 --- a/MTProtoKit/MTHttpWorker.m +++ b/MTProtoKit/MTHttpWorker.m @@ -6,14 +6,14 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTHttpWorker.h" -#import -#import +#import "MTTimer.h" +#import "MTQueue.h" -#import +#import "MTDatacenterAddress.h" -#import +#import "MTInternalId.h" MTInternalIdClass(MTHttpWorker) @@ -69,6 +69,12 @@ MTInternalIdClass(MTHttpWorker) int32_t randomId = 0; arc4random_buf(&randomId, 4); +/*#ifdef DEBUG + if (![address isIpv6]) { + address = [[MTDatacenterAddress alloc] initWithIp:@"127.0.0.1" port:443 preferForMedia:address.preferForMedia restrictToTcp:address.restrictToTcp]; + } +#endif*/ + NSString *urlString = [[NSString alloc] initWithFormat:@"http://%@:%d/api%" PRIx32 "", address.ip, (int)address.port, randomId]; self = [super initWithBaseURL:[[NSURL alloc] initWithString:urlString]]; diff --git a/MTProtoKit/MTHttpWorkerBehaviour.m b/MTProtoKit/MTHttpWorkerBehaviour.m index 6fedb05e3f..6d89f197c1 100644 --- a/MTProtoKit/MTHttpWorkerBehaviour.m +++ b/MTProtoKit/MTHttpWorkerBehaviour.m @@ -6,10 +6,10 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTHttpWorkerBehaviour.h" -#import -#import +#import "MTQueue.h" +#import "MTTimer.h" @interface MTHttpWorkerBehaviour () { diff --git a/MTProtoKit/MTIncomingMessage.m b/MTProtoKit/MTIncomingMessage.m index 4cd0b76611..76b4119ada 100644 --- a/MTProtoKit/MTIncomingMessage.m +++ b/MTProtoKit/MTIncomingMessage.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTIncomingMessage.h" @implementation MTIncomingMessage diff --git a/MTProtoKit/MTInputStream.m b/MTProtoKit/MTInputStream.m index b432f6d847..d0f012a13d 100644 --- a/MTProtoKit/MTInputStream.m +++ b/MTProtoKit/MTInputStream.m @@ -7,8 +7,8 @@ */ #import -#import -#import +#import "MTLogging.h" +#import "MTInputStream.h" #if TARGET_OS_IPHONE # import @@ -66,7 +66,11 @@ static inline int roundUpInput(int numToRound, int multiple) if ([_wrappedInputStream read:(uint8_t *)&value maxLength:4] != 4) { - MTLog(@"***** Couldn't read int32"); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read int32"); + + @throw [[NSException alloc] initWithName:@"MTInputStreamException" reason:@"readInt32 end of stream" userInfo:@{}]; + } } #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -105,7 +109,9 @@ static inline int roundUpInput(int numToRound, int multiple) if ([_wrappedInputStream read:(uint8_t *)&value maxLength:8] != 8) { - MTLog(@"***** Couldn't read int64"); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read int64"); + } } #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -144,7 +150,9 @@ static inline int roundUpInput(int numToRound, int multiple) if ([_wrappedInputStream read:(uint8_t *)&value maxLength:8] != 8) { - MTLog(@"***** Couldn't read double"); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read double"); + } } #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -183,7 +191,9 @@ static inline int roundUpInput(int numToRound, int multiple) NSInteger readLen = [_wrappedInputStream read:bytes maxLength:length]; if (readLen != length) { - MTLog(@"***** Couldn't read %d bytes", length); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read %d bytes", length); + } } NSData *data = [[NSData alloc] initWithBytesNoCopy:bytes length:length freeWhenDone:true]; return data; @@ -209,7 +219,9 @@ static inline int roundUpInput(int numToRound, int multiple) NSInteger readLen = [_wrappedInputStream read:bytes maxLength:length]; if (readLen != length) { - MTLog(@"***** Couldn't read %d bytes", length); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read %d bytes", length); + } } NSMutableData *data = [[NSMutableData alloc] initWithBytesNoCopy:bytes length:length freeWhenDone:true]; return data; @@ -265,7 +277,9 @@ static inline int roundUpInput(int numToRound, int multiple) NSInteger readLen = [_wrappedInputStream read:bytes maxLength:length]; if (readLen != length) { - MTLog(@"***** Couldn't read %d bytes", length); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read %d bytes", length); + } } string = [[NSString alloc] initWithBytesNoCopy:bytes length:length encoding:NSUTF8StringEncoding freeWhenDone:true]; @@ -360,7 +374,9 @@ static inline int roundUpInput(int numToRound, int multiple) NSInteger readLen = [_wrappedInputStream read:bytes maxLength:length]; if (readLen != length) { - MTLog(@"***** Couldn't read %d bytes", length); + if (MTLogEnabled()) { + MTLog(@"***** Couldn't read %d bytes", length); + } } NSData *result = [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:true]; diff --git a/MTProtoKit/MTInternalMessageParser.m b/MTProtoKit/MTInternalMessageParser.m index 8a41237f7a..e56944151f 100644 --- a/MTProtoKit/MTInternalMessageParser.m +++ b/MTProtoKit/MTInternalMessageParser.m @@ -1,28 +1,30 @@ #import "MTInternalMessageParser.h" -#import +#import "MTBufferReader.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "MTResPqMessage.h" +#import "MTRpcResultMessage.h" +#import "MTRpcError.h" +#import "MTDropRpcResultMessage.h" +#import "MTServerDhParamsMessage.h" +#import "MTServerDhInnerDataMessage.h" +#import "MTSetClientDhParamsResponseMessage.h" +#import "MTMsgsAckMessage.h" +#import "MTMsgsStateReqMessage.h" +#import "MtMsgsStateInfoMessage.h" +#import "MTMsgDetailedInfoMessage.h" +#import "MTMsgAllInfoMessage.h" +#import "MTMessage.h" +#import "MTMsgResendReqMessage.h" +#import "MTBadMsgNotificationMessage.h" +#import "MTPingMessage.h" +#import "MTPongMessage.h" +#import "MTNewSessionCreatedMessage.h" +#import "MTDestroySessionResponseMessage.h" +#import "MTMsgContainerMessage.h" +#import "MTFutureSaltsMessage.h" + +#import "MTLogging.h" #import @@ -415,19 +417,25 @@ int32_t vectorSignature = 0; if (![reader readInt32:&vectorSignature]) { - MTLog(@"[MTInternalMessageParser: msgs_ack can't read vectorSignature]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msgs_ack can't read vectorSignature]"); + } return nil; } else if (vectorSignature != (int32_t)0x1cb5c415) { - MTLog(@"[MTInternalMessageParser: msgs_ack invalid vectorSignature]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msgs_ack invalid vectorSignature]"); + } return nil; } int32_t count = 0; if (![reader readInt32:&count]) { - MTLog(@"[MTInternalMessageParser: msgs_ack can't read count]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msgs_ack can't read count]"); + } return nil; } @@ -437,7 +445,9 @@ int64_t messageId = 0; if (![reader readInt64:&messageId]) { - MTLog(@"[MTInternalMessageParser: msgs_ack can't read messageId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msgs_ack can't read messageId]"); + } return nil; } [messageIds addObject:@(messageId)]; @@ -450,7 +460,9 @@ int64_t pingId = 0; if (![reader readInt64:&pingId]) { - MTLog(@"[MTInternalMessageParser: ping can't read pingId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: ping can't read pingId]"); + } return nil; } @@ -461,14 +473,18 @@ int64_t messageId = 0; if (![reader readInt64:&messageId]) { - MTLog(@"[MTInternalMessageParser: pong can't read messageId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: pong can't read messageId]"); + } return nil; } int64_t pingId = 0; if (![reader readInt64:&pingId]) { - MTLog(@"[MTInternalMessageParser: pong can't read pingId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: pong can't read pingId]"); + } return nil; } @@ -479,21 +495,27 @@ int64_t firstMessageId = 0; if (![reader readInt64:&firstMessageId]) { - MTLog(@"[MTInternalMessageParser: new_session_created can't read firstMessageId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: new_session_created can't read firstMessageId]"); + } return nil; } int64_t uniqueId = 0; if (![reader readInt64:&uniqueId]) { - MTLog(@"[MTInternalMessageParser: new_session_created can't read uniqueId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: new_session_created can't read uniqueId]"); + } return nil; } int64_t serverSalt = 0; if (![reader readInt64:&serverSalt]) { - MTLog(@"[MTInternalMessageParser: new_session_created can't read serverSalt]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: new_session_created can't read serverSalt]"); + } return nil; } @@ -504,7 +526,9 @@ int64_t sessionId = 0; if (![reader readInt64:&sessionId]) { - MTLog(@"[MTInternalMessageParser: destroy_session_ok can't read sessionId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: destroy_session_ok can't read sessionId]"); + } return nil; } @@ -515,7 +539,9 @@ int64_t sessionId = 0; if (![reader readInt64:&sessionId]) { - MTLog(@"[MTInternalMessageParser: destroy_session_none can't read sessionId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: destroy_session_none can't read sessionId]"); + } return nil; } @@ -532,7 +558,9 @@ int32_t count = 0; if (![reader readInt32:&count]) { - MTLog(@"[MTInternalMessageParser: msg_container can't read count]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msg_container can't read count]"); + } return nil; } @@ -543,27 +571,35 @@ int64_t messageId = 0; if (![reader readInt64:&messageId]) { - MTLog(@"[MTInternalMessageParser: msg_container can't read messageId]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msg_container can't read messageId]"); + } return nil; } int32_t seqNo = 0; if (![reader readInt32:&seqNo]) { - MTLog(@"[MTInternalMessageParser: msg_container can't read seqNo]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msg_container can't read seqNo]"); + } return nil; } int32_t length = 0; if (![reader readInt32:&length]) { - MTLog(@"[MTInternalMessageParser: msg_container can't read length]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msg_container can't read length]"); + } return nil; } if (length < 0 || length > 16 * 1024 * 1024) { - MTLog(@"[MTInternalMessageParser: msg_container invalid length %d]", length); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msg_container invalid length %d]", length); + } return nil; } @@ -571,7 +607,9 @@ [messageData setLength:(NSUInteger)length]; if (![reader readBytes:messageData.mutableBytes length:(NSUInteger)length]) { - MTLog(@"[MTInternalMessageParser: msg_container can't read bytes]"); + if (MTLogEnabled()) { + MTLog(@"[MTInternalMessageParser: msg_container can't read bytes]"); + } return nil; } diff --git a/MTProtoKit/MTKeychain.m b/MTProtoKit/MTKeychain.m index 99198352f2..f4bb53a83a 100644 --- a/MTProtoKit/MTKeychain.m +++ b/MTProtoKit/MTKeychain.m @@ -6,4 +6,4 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTKeychain.h" diff --git a/MTProtoKit/MTLogging.h b/MTProtoKit/MTLogging.h index 1ed60e7577..32907bb35c 100644 --- a/MTProtoKit/MTLogging.h +++ b/MTProtoKit/MTLogging.h @@ -15,6 +15,7 @@ extern "C" { #endif +bool MTLogEnabled(); void MTLog(NSString *format, ...); void MTLogSetLoggingFunction(void (*function)(NSString *, va_list args)); diff --git a/MTProtoKit/MTLogging.m b/MTProtoKit/MTLogging.m index 7a931afb1c..b1d330fc97 100644 --- a/MTProtoKit/MTLogging.m +++ b/MTProtoKit/MTLogging.m @@ -6,22 +6,23 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTLogging.h" static void (*loggingFunction)(NSString *, va_list args) = NULL; -void MTLog(NSString *format, ...) -{ +bool MTLogEnabled() { + return loggingFunction != NULL; +} + +void MTLog(NSString *format, ...) { va_list L; va_start(L, format); - if (loggingFunction == NULL) - NSLogv(format, L); - else + if (loggingFunction != NULL) { loggingFunction(format, L); + } va_end(L); } -void MTLogSetLoggingFunction(void (*function)(NSString *, va_list args)) -{ +void MTLogSetLoggingFunction(void (*function)(NSString *, va_list args)) { loggingFunction = function; -} \ No newline at end of file +} diff --git a/MTProtoKit/MTMessageEncryptionKey.h b/MTProtoKit/MTMessageEncryptionKey.h index 2f82ace6e8..364cef36a6 100644 --- a/MTProtoKit/MTMessageEncryptionKey.h +++ b/MTProtoKit/MTMessageEncryptionKey.h @@ -14,6 +14,8 @@ @property (nonatomic, strong, readonly) NSData *iv; + (instancetype)messageEncryptionKeyForAuthKey:(NSData *)authKey messageKey:(NSData *)messageKey toClient:(bool)toClient; ++ (instancetype)messageEncryptionKeyV2ForAuthKey:(NSData *)authKey messageKey:(NSData *)messageKey toClient:(bool)toClient; + - (instancetype)initWithKey:(NSData *)key iv:(NSData *)iv; @end diff --git a/MTProtoKit/MTMessageEncryptionKey.m b/MTProtoKit/MTMessageEncryptionKey.m index 55c2e0f771..8fdb96d0ad 100644 --- a/MTProtoKit/MTMessageEncryptionKey.m +++ b/MTProtoKit/MTMessageEncryptionKey.m @@ -6,9 +6,9 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTMessageEncryptionKey.h" -#import +#import "MTEncryption.h" @implementation MTMessageEncryptionKey @@ -19,8 +19,6 @@ NSAssert(messageKey != nil, @"message key should not be nil"); #endif -#warning TODO more precise length check - if (authKey == nil || authKey.length == 0 || messageKey == nil || messageKey.length == 0) return nil; @@ -77,6 +75,55 @@ return result; } ++ (instancetype)messageEncryptionKeyV2ForAuthKey:(NSData *)authKey messageKey:(NSData *)messageKey toClient:(bool)toClient { +#ifdef DEBUG + NSAssert(authKey != nil, @"authKey should not be nil"); + NSAssert(messageKey != nil, @"message key should not be nil"); +#endif + + if (authKey == nil || authKey.length == 0 || messageKey == nil || messageKey.length == 0) + return nil; + + /* + sha256_a = SHA256 (msg_key + substr (auth_key, x, 36)); + + sha256_b = SHA256 (substr (auth_key, 40+x, 36) + msg_key); + + aes_key = substr (sha256_a, 0, 8) + substr (sha256_b, 8, 16) + substr (sha256_a, 24, 8); + aes_iv = substr (sha256_b, 0, 8) + substr (sha256_a, 8, 16) + substr (sha256_b, 24, 8); + */ + + int xValue = toClient ? 8 : 0; + + NSMutableData *sha256_a_data = [[NSMutableData alloc] init]; + [sha256_a_data appendData:messageKey]; + [sha256_a_data appendBytes:authKey.bytes + xValue length:36]; + + NSData *sha256_a = MTSha256(sha256_a_data); + + NSMutableData *sha256_b_data = [[NSMutableData alloc] init]; + [sha256_b_data appendBytes:authKey.bytes + 40 + xValue length:36]; + [sha256_b_data appendData:messageKey]; + + NSData *sha256_b = MTSha256(sha256_b_data); + + NSMutableData *aesKey = [[NSMutableData alloc] init]; + [aesKey appendBytes:sha256_a.bytes + 0 length:8]; + [aesKey appendBytes:sha256_b.bytes + 8 length:16]; + [aesKey appendBytes:sha256_a.bytes + 24 length:8]; + + NSMutableData *aesIv = [[NSMutableData alloc] init]; + [aesIv appendBytes:sha256_b.bytes + 0 length:8]; + [aesIv appendBytes:sha256_a.bytes + 8 length:16]; + [aesIv appendBytes:sha256_b.bytes + 24 length:8]; + + MTMessageEncryptionKey *result = [[MTMessageEncryptionKey alloc] init]; + result->_key = [[NSData alloc] initWithData:aesKey]; + result->_iv = [[NSData alloc] initWithData:aesIv]; + + return result; +} + - (instancetype)initWithKey:(NSData *)key iv:(NSData *)iv { self = [super init]; diff --git a/MTProtoKit/MTMessageTransaction.h b/MTProtoKit/MTMessageTransaction.h index 4e96d61f64..41302e384f 100644 --- a/MTProtoKit/MTMessageTransaction.h +++ b/MTProtoKit/MTMessageTransaction.h @@ -13,7 +13,7 @@ @property (nonatomic, strong, readonly) id internalId; /* - * Can be invoked multiple times in case when message transaction maps to multiple different transport transactions + * Can be invoked multiple times in case message transaction maps to multiple different transport transactions */ @property (nonatomic, copy) void (^completion)(NSDictionary *messageInternalIdToTransactionId, NSDictionary *messageInternalIdToPreparedMessage, NSDictionary *messageInternalIdToQuickAckId); @property (nonatomic, copy) void (^prepared)(NSDictionary *messageInternalIdToPreparedMessage); diff --git a/MTProtoKit/MTMessageTransaction.m b/MTProtoKit/MTMessageTransaction.m index 9ac2387f9d..c07e050e86 100644 --- a/MTProtoKit/MTMessageTransaction.m +++ b/MTProtoKit/MTMessageTransaction.m @@ -6,9 +6,9 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTMessageTransaction.h" -#import +#import "MTInternalId.h" MTInternalIdClass(MTMessageTransaction) diff --git a/MTProtoKit/MTNetworkAvailability.m b/MTProtoKit/MTNetworkAvailability.m index e803f3a3b8..0d92378baa 100644 --- a/MTProtoKit/MTNetworkAvailability.m +++ b/MTProtoKit/MTNetworkAvailability.m @@ -6,11 +6,11 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTNetworkAvailability.h" -#import -#import -#import +#import "MTLogging.h" +#import "MTQueue.h" +#import "MTTimer.h" #import #import @@ -155,7 +155,9 @@ static void MTNetworkAvailabilityContextRelease(const void *info) if (![currentReachabilityState isEqualToString:_lastReachabilityState]) { _lastReachabilityState = currentReachabilityState; - MTLog(@"[MTNetworkAvailability#%p state: %@]", self, _lastReachabilityState); + if (MTLogEnabled()) { + MTLog(@"[MTNetworkAvailability#%p state: %@]", self, _lastReachabilityState); + } if (notify) { diff --git a/MTProtoKit/MTOutgoingMessage.m b/MTProtoKit/MTOutgoingMessage.m index e594d81e93..06245a3cac 100644 --- a/MTProtoKit/MTOutgoingMessage.m +++ b/MTProtoKit/MTOutgoingMessage.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTOutgoingMessage.h" @interface MTOutgoingMessageInternalId : NSObject { diff --git a/MTProtoKit/MTOutputStream.m b/MTProtoKit/MTOutputStream.m index 1bcce89231..b20bf59ec6 100644 --- a/MTProtoKit/MTOutputStream.m +++ b/MTProtoKit/MTOutputStream.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTOutputStream.h" #if TARGET_OS_IPHONE # import diff --git a/MTProtoKit/MTPreparedMessage.m b/MTProtoKit/MTPreparedMessage.m index 3a004c9c1c..9fedc1c0f6 100644 --- a/MTProtoKit/MTPreparedMessage.m +++ b/MTProtoKit/MTPreparedMessage.m @@ -6,9 +6,9 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTPreparedMessage.h" -#import +#import "MTInternalId.h" MTInternalIdClass(MTPreparedMessage) diff --git a/MTProtoKit/MTProto.h b/MTProtoKit/MTProto.h index 394e2de5d9..1d5e60b71b 100644 --- a/MTProtoKit/MTProto.h +++ b/MTProtoKit/MTProto.h @@ -11,6 +11,7 @@ @protocol MTMessageService; @class MTQueue; @class MTContext; +@class MTNetworkUsageCalculationInfo; @class MTProto; @@ -38,7 +39,9 @@ @property (nonatomic) id requiredAuthToken; @property (nonatomic) NSInteger authTokenMasterDatacenterId; -- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId; +- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; + +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; - (void)pause; - (void)resume; diff --git a/MTProtoKit/MTProto.m b/MTProtoKit/MTProto.m index 06bce3c200..1818d5beb5 100644 --- a/MTProtoKit/MTProto.m +++ b/MTProtoKit/MTProto.m @@ -6,50 +6,56 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTProto.h" #import -#import -#import -#import -#import +#import "MTLogging.h" +#import "MTQueue.h" +#import "MTOutputStream.h" +#import "MTInputStream.h" -#import -#import -#import -#import -#import -#import +#import "MTContext.h" -#import -#import -#import -#import +#import "MTDatacenterAddressSet.h" +#import "MTTransportScheme.h" +#import "MTDatacenterAuthInfo.h" +#import "MTSessionInfo.h" +#import "MTDatacenterSaltInfo.h" +#import "MTTimeFixContext.h" -#import -#import -#import -#import +#import "MTMessageService.h" +#import "MTMessageTransaction.h" +#import "MTTimeSyncMessageService.h" +#import "MTResendMessageService.h" -#import -#import +#import "MTIncomingMessage.h" +#import "MTOutgoingMessage.h" +#import "MTPreparedMessage.h" +#import "MTMessageEncryptionKey.h" -#import -#import +#import "MTTransport.h" +#import "MTTransportTransaction.h" -#import -#import +#import "MTTcpTransport.h" +#import "MTHttpTransport.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "MTSerialization.h" +#import "MTEncryption.h" + +#import "MTBuffer.h" +#import "MTInternalMessageParser.h" +#import "MTMsgContainerMessage.h" +#import "MTMessage.h" +#import "MTBadMsgNotificationMessage.h" +#import "MTMsgsAckMessage.h" +#import "MTMsgDetailedInfoMessage.h" +#import "MTNewSessionCreatedMessage.h" +#import "MTPongMessage.h" + +#import "MTTime.h" + +#define MTProtoV2 1 typedef enum { MTProtoStateAwaitingDatacenterScheme = 1, @@ -79,6 +85,8 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; int _mtState; bool _willRequestTransactionOnNextQueuePass; + + MTNetworkUsageCalculationInfo *_usageCalculationInfo; } @end @@ -96,7 +104,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; return queue; } -- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId +- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { #ifdef DEBUG NSAssert(context != nil, @"context should not be nil"); @@ -109,6 +117,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { _context = context; _datacenterId = datacenterId; + _usageCalculationInfo = usageCalculationInfo; [_context addChangeListener:self]; @@ -134,13 +143,22 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; }]; } +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { + [[MTProto managerQueue] dispatchOnQueue:^{ + _usageCalculationInfo = usageCalculationInfo; + [_transport setUsageCalculationInfo:usageCalculationInfo]; + }]; +} + - (void)pause { [[MTProto managerQueue] dispatchOnQueue:^ { if ((_mtState & MTProtoStatePaused) == 0) { - MTLog(@"[MTProto#%p pause]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p pause]", self); + } _mtState |= MTProtoStatePaused; @@ -156,7 +174,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { if (_mtState & MTProtoStatePaused) { - MTLog(@"[MTProto#%p resume]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p resume]", self); + } [self setMtState:_mtState & (~MTProtoStatePaused)]; @@ -207,7 +227,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { [[MTProto managerQueue] dispatchOnQueue:^ { - MTLog(@"[MTProto#%p changing transport %@#%p to %@#%p]", self, [_transport class] == nil ? @"" : NSStringFromClass([_transport class]), _transport, [transport class] == nil ? @"" : NSStringFromClass([transport class]), transport); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p changing transport %@#%p to %@#%p]", self, [_transport class] == nil ? @"" : NSStringFromClass([_transport class]), _transport, [transport class] == nil ? @"" : NSStringFromClass([transport class]), transport); + } [self allTransactionsMayHaveFailed]; @@ -279,7 +301,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { MTTransport *transport = nil; - transport = [_transportScheme createTransportWithContext:_context datacenterId:_datacenterId delegate:self]; + transport = [_transportScheme createTransportWithContext:_context datacenterId:_datacenterId delegate:self usageCalculationInfo:_usageCalculationInfo]; [self setTransport:transport]; } @@ -290,7 +312,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { [[MTProto managerQueue] dispatchOnQueue:^ { - MTLog(@"[MTProto#%p resetting session]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p resetting session]", self); + } _sessionInfo = [[MTSessionInfo alloc] initWithRandomSessionIdAndContext:_context]; _timeFixContext = nil; @@ -324,7 +348,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (!alreadySyncing) { - MTLog(@"[MTProto#%p begin time sync]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p begin time sync]", self); + } MTTimeSyncMessageService *timeSyncService = [[MTTimeSyncMessageService alloc] init]; timeSyncService.delegate = self; @@ -354,7 +380,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; } } - MTLog(@"[MTProto#%p service tasks state: %d, resend: %s]", self, _mtState, haveResendMessagesPending ? "yes" : "no"); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p service tasks state: %d, resend: %s]", self, _mtState, haveResendMessagesPending ? "yes" : "no"); + } for (id messageService in _messageServices) { @@ -402,7 +430,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (notifyAboutServiceTask) { - MTLog(@"[MTProto#%p service tasks state: %d, resend: %s]", self, _mtState, true ? "yes" : "no"); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p service tasks state: %d, resend: %s]", self, _mtState, true ? "yes" : "no"); + } for (id messageService in _messageServices) { @@ -452,7 +482,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; bool performingServiceTasks = _mtState & MTProtoStateAwaitingTimeFixAndSalts; if (!performingServiceTasks) { - MTLog(@"[MTProto#%p service tasks state: %d, resend: %s]", self, _mtState, false ? "yes" : "no"); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p service tasks state: %d, resend: %s]", self, _mtState, false ? "yes" : "no"); + } for (id messageService in _messageServices) { @@ -611,7 +643,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (transport != _transport) return; - MTLog(@"[MTProto#%p network state: %s]", self, isNetworkAvailable ? "available" : "waiting"); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p network state: %s]", self, isNetworkAvailable ? "available" : "waiting"); + } for (id messageService in _messageServices) { @@ -632,7 +666,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (transport != _transport) return; - MTLog(@"[MTProto#%p connection state: %s]", self, isConnected ? "connected" : "connecting"); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p connection state: %s]", self, isConnected ? "connected" : "connecting"); + } for (id messageService in _messageServices) { @@ -653,7 +689,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (transport != _transport) return; - MTLog(@"[MTProto#%p connection context update state: %s]", self, isUpdatingConnectionContext ? "updating" : "up to date"); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p connection context update state: %s]", self, isUpdatingConnectionContext ? "updating" : "up to date"); + } for (id messageService in _messageServices) { @@ -823,7 +861,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; messageSeqNo = outgoingMessage.messageSeqNo; } - MTLog(@"[MTProto#%p preparing %@]", self, [self outgoingMessageDescription:outgoingMessage messageId:messageId messageSeqNo:messageSeqNo]); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p preparing %@]", self, [self outgoingMessageDescription:outgoingMessage messageId:messageId messageSeqNo:messageSeqNo]); + } if (!monotonityViolated || _useUnauthorizedMode) { @@ -865,7 +905,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (monotonityViolated) { - MTLog(@"[MTProto#%p client message id monotonity violated]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p client message id monotonity violated]", self); + } [self resetSessionInfo]; } @@ -1050,7 +1092,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; } } - MTLog(@"[MTProto#%p transport did not accept transactions with messages (%@)]", self, idsString); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p transport did not accept transactions with messages (%@)]", self, idsString); + } } }]; } needsQuickAck:transactionNeedsQuickAck expectsDataInResponse:transactionExpectsDataInResponse]]; @@ -1104,7 +1148,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; MTOutputStream *decryptedOs = [[MTOutputStream alloc] init]; - MTLog(@"[MTProto#%x sending time fix ping (%" PRId64 "/%" PRId32 ")]", self, timeFixMessageId, timeFixSeqNo); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%x sending time fix ping (%" PRId64 "/%" PRId32 ")]", self, timeFixMessageId, timeFixSeqNo); + } [decryptedOs writeInt64:[_authInfo authSaltForMessageId:timeFixMessageId]]; // salt [decryptedOs writeInt64:_sessionInfo.sessionId]; @@ -1114,21 +1160,25 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; [decryptedOs writeInt32:(int32_t)messageData.length]; [decryptedOs writeData:messageData]; - uint8_t randomBytes[15]; - arc4random_buf(randomBytes, 15); - for (int i = 0; ((int)messageData.length + i) % 16 != 0; i++) - { - [decryptedOs write:&randomBytes[i] maxLength:1]; - } + NSData *decryptedData = [self paddedData:[decryptedOs currentBytes]]; - NSData *decryptedData = [decryptedOs currentBytes]; +#if MTProtoV2 + int xValue = 0; + NSMutableData *msgKeyLargeData = [[NSMutableData alloc] init]; + [msgKeyLargeData appendBytes:_authInfo.authKey.bytes + 88 + xValue length:32]; + [msgKeyLargeData appendData:decryptedData]; + NSData *msgKeyLarge = MTSha256(msgKeyLargeData); + NSData *messageKey = [msgKeyLarge subdataWithRange:NSMakeRange(8, 16)]; + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyV2ForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; +#else NSData *messageKeyFull = MTSubdataSha1(decryptedData, 0, 32 + messageData.length); NSData *messageKey = [[NSData alloc] initWithBytes:(((int8_t *)messageKeyFull.bytes) + messageKeyFull.length - 16) length:16]; + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; +#endif NSData *transactionData = nil; - MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; if (encryptionKey != nil) { NSMutableData *encryptedData = [[NSMutableData alloc] initWithCapacity:14 + decryptedData.length]; @@ -1215,7 +1265,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; [idsString appendString:@","]; [idsString appendFormat:@"%lld", [nMessageId longLongValue]]; } - MTLog(@" container (%" PRId64 ") of (%@)", containerMessageId, idsString); + if (MTLogEnabled()) { + MTLog(@" container (%" PRId64 ") of (%@)", containerMessageId, idsString); + } #endif } @@ -1227,27 +1279,32 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; [decryptedOs writeInt32:(int32_t)containerData.length]; [decryptedOs writeData:containerData]; - uint8_t randomBytes[15]; - arc4random_buf(randomBytes, 15); - for (int i = 0; ((int)containerData.length + i) % 16 != 0; i++) - { - [decryptedOs write:&randomBytes[i] maxLength:1]; - } + NSData *decryptedData = [self paddedData:[decryptedOs currentBytes]]; - NSData *decryptedData = [decryptedOs currentBytes]; +#if MTProtoV2 + int xValue = 0; + NSMutableData *msgKeyLargeData = [[NSMutableData alloc] init]; + [msgKeyLargeData appendBytes:_authInfo.authKey.bytes + 88 + xValue length:32]; + [msgKeyLargeData appendData:decryptedData]; + NSData *msgKeyLarge = MTSha256(msgKeyLargeData); + NSData *messageKey = [msgKeyLarge subdataWithRange:NSMakeRange(8, 16)]; + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyV2ForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; + int32_t nQuickAckId = *((int32_t *)(msgKeyLarge.bytes)); +#else NSData *messageKeyFull = MTSubdataSha1(decryptedData, 0, 32 + containerData.length); NSData *messageKey = [[NSData alloc] initWithBytes:(((int8_t *)messageKeyFull.bytes) + messageKeyFull.length - 16) length:16]; - + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; int32_t nQuickAckId = *((int32_t *)(messageKeyFull.bytes)); +#endif + nQuickAckId = nQuickAckId & 0x7fffffff; if (quickAckId != NULL) *quickAckId = nQuickAckId; - MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; if (encryptionKey != nil) { - NSMutableData *encryptedData = [[NSMutableData alloc] initWithCapacity:14 + decryptedData.length]; + NSMutableData *encryptedData = [[NSMutableData alloc] init]; [encryptedData appendData:decryptedData]; MTAesEncryptInplace(encryptedData, encryptionKey.key, encryptionKey.iv); @@ -1275,6 +1332,39 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; return messageData; } +- (NSData *)paddedData:(NSData *)data { + NSMutableData *padded = [[NSMutableData alloc] initWithData:data]; + uint8_t randomBytes[128]; + arc4random_buf(randomBytes, 128); +#if MTProtoV2 + int take = 0; + while (take < 12) { + [padded appendBytes:randomBytes + take length:1]; + take++; + } + + while (padded.length % 16 != 0) { + [padded appendBytes:randomBytes + take length:1]; + take++; + } + + int remainingCount = arc4random_uniform(72 + 1 - take); + while (remainingCount % 16 != 0) { + remainingCount--; + } + + for (int i = 0; i < remainingCount; i++) { + [padded appendBytes:randomBytes + take length:1]; + take++; + } +#else + for (int i = 0; ((int)data.length + i) % 16 != 0; i++) { + [padded appendBytes:randomBytes + i length:1]; + } +#endif + return padded; +} + - (NSData *)_dataForEncryptedMessage:(MTPreparedMessage *)preparedMessage sessionInfo:(MTSessionInfo *)sessionInfo quickAckId:(int32_t *)quickAckId { MTOutputStream *decryptedOs = [[MTOutputStream alloc] init]; @@ -1287,15 +1377,18 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; [decryptedOs writeInt32:(int32_t)preparedMessage.data.length]; [decryptedOs writeData:preparedMessage.data]; - uint8_t randomBytes[15]; - arc4random_buf(randomBytes, 15); - for (int i = 0; ((int)preparedMessage.data.length + i) % 16 != 0; i++) - { - [decryptedOs write:&randomBytes[i] maxLength:1]; - } + NSData *decryptedData = [self paddedData:[decryptedOs currentBytes]]; - NSData *decryptedData = [decryptedOs currentBytes]; +#if MTProtoV2 + int xValue = 0; + NSMutableData *msgKeyLargeData = [[NSMutableData alloc] init]; + [msgKeyLargeData appendBytes:_authInfo.authKey.bytes + 88 + xValue length:32]; + [msgKeyLargeData appendData:decryptedData]; + NSData *msgKeyLarge = MTSha256(msgKeyLargeData); + NSData *messageKey = [msgKeyLarge subdataWithRange:NSMakeRange(8, 16)]; + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyV2ForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; +#else NSData *messageKeyFull = MTSubdataSha1(decryptedData, 0, 32 + preparedMessage.data.length); NSData *messageKey = [[NSData alloc] initWithBytes:(((int8_t *)messageKeyFull.bytes) + messageKeyFull.length - 16) length:16]; @@ -1305,6 +1398,8 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; *quickAckId = nQuickAckId; MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:messageKey toClient:false]; +#endif + if (encryptionKey != nil) { NSMutableData *encryptedData = [[NSMutableData alloc] initWithCapacity:14 + decryptedData.length]; @@ -1405,16 +1500,21 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (keyId != 0 && _authInfo != nil) { NSData *messageKey = [is readData:16]; +#if MTProtoV2 + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyV2ForAuthKey:_authInfo.authKey messageKey:messageKey toClient:true]; +#else MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:messageKey toClient:true]; +#endif - NSMutableData *messageData = [is readMutableData:(data.length - 24)]; - while (messageData.length % 16 != 0) - [messageData setLength:messageData.length - 1]; - if (messageData.length != 0) + NSMutableData *encryptedMessageData = [is readMutableData:(data.length - 24)]; + while (encryptedMessageData.length % 16 != 0) { + [encryptedMessageData setLength:encryptedMessageData.length - 1]; + } + if (encryptedMessageData.length != 0) { - MTAesDecryptInplace(messageData, encryptionKey.key, encryptionKey.iv); + NSData *decryptedData = MTAesDecrypt(encryptedMessageData, encryptionKey.key, encryptionKey.iv); - MTInputStream *messageIs = [[MTInputStream alloc] initWithData:messageData]; + MTInputStream *messageIs = [[MTInputStream alloc] initWithData:decryptedData]; [messageIs readInt64]; [messageIs readInt64]; @@ -1557,7 +1657,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; int32_t protocolErrorCode = 0; [data getBytes:&protocolErrorCode range:NSMakeRange(0, 4)]; - MTLog(@"[MTProto#%p protocol error %" PRId32 "", self, protocolErrorCode); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p protocol error %" PRId32 "", self, protocolErrorCode); + } if (decodeResult != nil) decodeResult(transactionId, false); @@ -1597,7 +1699,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; NSArray *parsedMessages = [self _parseIncomingMessages:decryptedData dataMessageId:&dataMessageId parseError:&parseError]; if (parseError) { - MTLog(@"[MTProto#%p incoming data parse error]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p incoming data parse error]", self); + } [self transportTransactionsMayHaveFailed:transport transactionIds:@[transactionId]]; @@ -1618,7 +1722,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; } else { - MTLog(@"[MTProto#%p couldn't decrypt incoming data]", self); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p couldn't decrypt incoming data]", self); + } if (decodeResult != nil) decodeResult(transactionId, false); @@ -1644,7 +1750,13 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; return nil; NSData *embeddedMessageKey = [data subdataWithRange:NSMakeRange(8, 16)]; + +#if MTProtoV2 + MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyV2ForAuthKey:_authInfo.authKey messageKey:embeddedMessageKey toClient:true]; +#else MTMessageEncryptionKey *encryptionKey = [MTMessageEncryptionKey messageEncryptionKeyForAuthKey:_authInfo.authKey messageKey:embeddedMessageKey toClient:true]; +#endif + if (encryptionKey == nil) return nil; @@ -1653,11 +1765,22 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; int32_t messageDataLength = 0; [decryptedData getBytes:&messageDataLength range:NSMakeRange(28, 4)]; - if (messageDataLength < 0 || messageDataLength < (int32_t)decryptedData.length - 32 - 16 || messageDataLength > (int32_t)decryptedData.length - 32) + if (messageDataLength < 0 || messageDataLength > (int32_t)decryptedData.length) return nil; +#if MTProtoV2 + int xValue = 8; + NSMutableData *msgKeyLargeData = [[NSMutableData alloc] init]; + [msgKeyLargeData appendBytes:_authInfo.authKey.bytes + 88 + xValue length:32]; + [msgKeyLargeData appendData:decryptedData]; + + NSData *msgKeyLarge = MTSha256(msgKeyLargeData); + NSData *messageKey = [msgKeyLarge subdataWithRange:NSMakeRange(8, 16)]; +#else NSData *messageKeyFull = MTSubdataSha1(decryptedData, 0, 32 + messageDataLength); NSData *messageKey = [[NSData alloc] initWithBytes:(((int8_t *)messageKeyFull.bytes) + messageKeyFull.length - 16) length:16]; +#endif + if (![messageKey isEqualToData:embeddedMessageKey]) return nil; @@ -1831,7 +1954,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { if ([_sessionInfo messageProcessed:incomingMessage.messageId]) { - MTLog(@"[MTProto#%p received duplicate message %" PRId64 "]", self, incomingMessage.messageId); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p received duplicate message %" PRId64 "]", self, incomingMessage.messageId); + } [_sessionInfo scheduleMessageConfirmation:incomingMessage.messageId size:incomingMessage.size]; if ([_sessionInfo scheduledMessageConfirmationsExceedSize:MTMaxUnacknowledgedMessageSize orCount:MTMaxUnacknowledgedMessageCount]) @@ -1840,7 +1965,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; return; } - MTLog(@"[MTProto#%p received %@]", self, [self incomingMessageDescription:incomingMessage]); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p received %@]", self, [self incomingMessageDescription:incomingMessage]); + } [_sessionInfo setMessageProcessed:incomingMessage.messageId]; if (!_useUnauthorizedMode && incomingMessage.seqNo % 2 != 0) @@ -1968,7 +2095,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { int64_t requestMessageId = ((MTMsgDetailedResponseInfoMessage *)detailedInfoMessage).requestMessageId; - MTLog(@"[MTProto#%p detailed info %" PRId64 " is for %" PRId64 "", self, incomingMessage.messageId, requestMessageId); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p detailed info %" PRId64 " is for %" PRId64 "", self, incomingMessage.messageId, requestMessageId); + } for (id messageService in _messageServices) { @@ -1988,7 +2117,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if (shouldRequest) { [self requestMessageWithId:detailedInfoMessage.responseMessageId]; - MTLog(@"[MTProto#%p will request message %" PRId64 "", self, detailedInfoMessage.responseMessageId); + if (MTLogEnabled()) { + MTLog(@"[MTProto#%p will request message %" PRId64 "", self, detailedInfoMessage.responseMessageId); + } } else { diff --git a/MTProtoKit/MTProtoKit.h b/MTProtoKit/MTProtoKit.h index 0623781359..d44f3fb958 100644 --- a/MTProtoKit/MTProtoKit.h +++ b/MTProtoKit/MTProtoKit.h @@ -17,15 +17,56 @@ FOUNDATION_EXPORT const unsigned char MtProtoKitVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import -#import -#import -#import -#import -#import +#import +#import +#import +#import +#import +#import +#import +#import #import +#import +#import +#import +#import +#import +#import +#import +#import +#import #import #import #import -#import -#import +#import +#import +#import +#import +#import +#import +#import #import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import diff --git a/MTProtoKit/MTQueue.h b/MTProtoKit/MTQueue.h index ad0fd4be98..b5487a9f18 100644 --- a/MTProtoKit/MTQueue.h +++ b/MTProtoKit/MTQueue.h @@ -13,6 +13,8 @@ - (instancetype)initWithName:(const char *)name; + (MTQueue *)mainQueue; ++ (MTQueue *)concurrentDefaultQueue; ++ (MTQueue *)concurrentLowQueue; - (dispatch_queue_t)nativeQueue; diff --git a/MTProtoKit/MTQueue.m b/MTProtoKit/MTQueue.m index 128c34a5f7..dd2c9852cd 100644 --- a/MTProtoKit/MTQueue.m +++ b/MTProtoKit/MTQueue.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTQueue.h" @interface MTQueue () { @@ -20,6 +20,15 @@ @implementation MTQueue +- (instancetype)init { + self = [super init]; + if (self != nil) + { + _queue = dispatch_queue_create(nil, 0); + } + return self; +} + - (instancetype)initWithName:(const char *)name { self = [super init]; @@ -54,6 +63,27 @@ return queue; } ++ (MTQueue *)concurrentDefaultQueue { + static MTQueue *queue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^ + { + queue = [[MTQueue alloc] init]; + queue->_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + }); + return queue; +} + ++ (MTQueue *)concurrentLowQueue { + static MTQueue *queue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^ { + queue = [[MTQueue alloc] init]; + queue->_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); + }); + return queue; +} + - (dispatch_queue_t)nativeQueue { return _queue; @@ -61,7 +91,7 @@ - (bool)isCurrentQueue { - if (_queue == nil) + if (_queue == nil || _name == nil) return false; if (_isMainQueue) @@ -70,6 +100,10 @@ return dispatch_get_specific(_name) == _name; } +- (void)dispatch:(dispatch_block_t)block { + [self dispatchOnQueue:block synchronous:false]; +} + - (void)dispatchOnQueue:(dispatch_block_t)block { [self dispatchOnQueue:block synchronous:false]; @@ -93,7 +127,7 @@ } else { - if (dispatch_get_specific(_name) == _name) + if (_name != NULL && dispatch_get_specific(_name) == _name) block(); else if (synchronous) dispatch_sync(_queue, block); diff --git a/MTProtoKit/MTRequest.h b/MTProtoKit/MTRequest.h index 74272b4a6d..1050efcebb 100644 --- a/MTProtoKit/MTRequest.h +++ b/MTProtoKit/MTRequest.h @@ -6,10 +6,11 @@ * Copyright Peter Iakovlev, 2013. */ +#import + @class MTRequestContext; @class MTRequestErrorContext; - -#import +@class MTRpcError; @interface MTRequest : NSObject diff --git a/MTProtoKit/MTRequest.m b/MTProtoKit/MTRequest.m index 2e707d242c..34c23ca60f 100644 --- a/MTProtoKit/MTRequest.m +++ b/MTProtoKit/MTRequest.m @@ -6,7 +6,9 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTRequest.h" + +#import "MTRpcError.h" @interface MTRequestInternalId : NSObject { diff --git a/MTProtoKit/MTRequestContext.m b/MTProtoKit/MTRequestContext.m index b258058a75..d713d52f8d 100644 --- a/MTProtoKit/MTRequestContext.m +++ b/MTProtoKit/MTRequestContext.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTRequestContext.h" @implementation MTRequestContext diff --git a/MTProtoKit/MTRequestErrorContext.h b/MTProtoKit/MTRequestErrorContext.h index 41758ee7ee..1ee405d3ff 100644 --- a/MTProtoKit/MTRequestErrorContext.h +++ b/MTProtoKit/MTRequestErrorContext.h @@ -7,11 +7,10 @@ */ #import -#import @interface MTRequestErrorContext : NSObject -@property (nonatomic) MTAbsoluteTime minimalExecuteTime; +@property (nonatomic) CFAbsoluteTime minimalExecuteTime; @property (nonatomic) NSUInteger internalServerErrorCount; @property (nonatomic) NSUInteger floodWaitSeconds; diff --git a/MTProtoKit/MTRequestMessageService.h b/MTProtoKit/MTRequestMessageService.h index 2ed016145d..93852be41b 100644 --- a/MTProtoKit/MTRequestMessageService.h +++ b/MTProtoKit/MTRequestMessageService.h @@ -6,7 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @class MTContext; @class MTRequest; diff --git a/MTProtoKit/MTRequestMessageService.m b/MTProtoKit/MTRequestMessageService.m index 963f29444f..517d84ffc8 100644 --- a/MTProtoKit/MTRequestMessageService.m +++ b/MTProtoKit/MTRequestMessageService.m @@ -6,31 +6,31 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTRequestMessageService.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "MTLogging.h" +#import "MTTime.h" +#import "MTTimer.h" +#import "MTContext.h" +#import "MTSerialization.h" +#import "MTProto.h" +#import "MTQueue.h" +#import "MTMessageTransaction.h" +#import "MTIncomingMessage.h" +#import "MTOutgoingMessage.h" +#import "MTPreparedMessage.h" +#import "MTRequest.h" +#import "MTRequestContext.h" +#import "MTRequestErrorContext.h" +#import "MTDropResponseContext.h" +#import "MTApiEnvironment.h" +#import "MTDatacenterAuthInfo.h" +#import "MTBuffer.h" -#import -#import -#import -#import +#import "MTInternalMessageParser.h" +#import "MTRpcResultMessage.h" +#import "MTRpcError.h" +#import "MTDropRpcResultMessage.h" @interface MTRequestMessageService () { @@ -125,8 +125,11 @@ anyNewDropRequests = true; } - if (request.requestContext.messageId != 0) - MTLog(@"[MTRequestMessageService#%x drop %" PRId64 "]", (int)self, request.requestContext.messageId); + if (request.requestContext.messageId != 0) { + if (MTLogEnabled()) { + MTLog(@"[MTRequestMessageService#%x drop %" PRId64 "]", (int)self, request.requestContext.messageId); + } + } request.requestContext = nil; [_requests removeObjectAtIndex:(NSUInteger)index]; @@ -193,9 +196,9 @@ { [_queue dispatchOnQueue:^ { - MTAbsoluteTime currentTime = MTAbsoluteSystemTime(); + CFAbsoluteTime currentTime = MTAbsoluteSystemTime(); - MTAbsoluteTime minWaitTime = DBL_MAX; + CFAbsoluteTime minWaitTime = DBL_MAX; bool needTimer = false; bool needTransaction = false; @@ -345,9 +348,7 @@ bool requestsWillInitializeApi = _apiEnvironment != nil && ![_apiEnvironment.apiInitializationHash isEqualToString:[_context authInfoForDatacenterWithId:mtProto.datacenterId].authKeyAttributes[@"apiInitializationHash"]]; - MTAbsoluteTime currentTime = MTAbsoluteSystemTime(); - - static bool catchPrepare = false; + CFAbsoluteTime currentTime = MTAbsoluteSystemTime(); for (MTRequest *request in _requests) { @@ -536,11 +537,15 @@ if (rpcResult != nil) { - MTLog(@"[MTRequestMessageService#%p response for %" PRId64 " is %@]", self, request.requestContext.messageId, rpcResult); + if (MTLogEnabled()) { + MTLog(@"[MTRequestMessageService#%p response for %" PRId64 " is %@]", self, request.requestContext.messageId, rpcResult); + } } else { - MTLog(@"[MTRequestMessageService#%p response for %" PRId64 " is error: %d: %@]", self, request.requestContext.messageId, (int)rpcError.errorCode, rpcError.errorDescription); + if (MTLogEnabled()) { + MTLog(@"[MTRequestMessageService#%p response for %" PRId64 " is error: %d: %@]", self, request.requestContext.messageId, (int)rpcError.errorCode, rpcError.errorDescription); + } } if (rpcResult != nil && request.requestContext.willInitializeApi) @@ -620,13 +625,13 @@ if (request.shouldContinueExecutionWithErrorContext(request.errorContext)) { restartRequest = true; - request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (MTAbsoluteTime)errorWaitTime); + request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (CFAbsoluteTime)errorWaitTime); } } else { restartRequest = true; - request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (MTAbsoluteTime)errorWaitTime); + request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (CFAbsoluteTime)errorWaitTime); } } } @@ -645,7 +650,7 @@ }]; } -#warning TODO other service errors +//#warning TODO other service errors } request.requestContext = nil; @@ -656,7 +661,7 @@ } else { - void (^completed)(id result, NSTimeInterval completionTimestamp, id error) = request.completed; + void (^completed)(id result, NSTimeInterval completionTimestamp, id error) = [request.completed copy]; [_requests removeObjectAtIndex:(NSUInteger)index]; if (completed) @@ -667,8 +672,11 @@ } } - if (!requestFound) - MTLog(@"[MTRequestMessageService#%p response %" PRId64 " didn't match any request]", self, message.messageId); + if (!requestFound) { + if (MTLogEnabled()) { + MTLog(@"[MTRequestMessageService#%p response %" PRId64 " didn't match any request]", self, message.messageId); + } + } else if (_requests.count == 0) { id delegate = _delegate; diff --git a/MTProtoKit/MTResendMessageService.h b/MTProtoKit/MTResendMessageService.h index 2b91afd158..a7052e33b0 100644 --- a/MTProtoKit/MTResendMessageService.h +++ b/MTProtoKit/MTResendMessageService.h @@ -6,7 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @class MTResendMessageService; diff --git a/MTProtoKit/MTResendMessageService.m b/MTProtoKit/MTResendMessageService.m index 48c3ae1e99..8a146e2602 100644 --- a/MTProtoKit/MTResendMessageService.m +++ b/MTProtoKit/MTResendMessageService.m @@ -7,18 +7,18 @@ */ #import -#import -#import +#import "MTLogging.h" +#import "MTResendMessageService.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "MTProto.h" +#import "MTContext.h" +#import "MTSerialization.h" +#import "MTMessageTransaction.h" +#import "MTOutgoingMessage.h" +#import "MTPreparedMessage.h" +#import "MTIncomingMessage.h" +#import "MTBuffer.h" +#import "MTMsgsStateInfoMessage.h" @interface MTResendMessageService () { @@ -73,7 +73,9 @@ _currentRequestMessageId = ((MTPreparedMessage *)messageInternalIdToPreparedMessage[outgoingMessage.internalId]).messageId; _currentRequestTransactionId = messageInternalIdToTransactionId[outgoingMessage.internalId]; - MTLog(@"[MTResendMessageService#%p request %" PRId64 " for %" PRId64 "]", self, _currentRequestMessageId, _messageId); + if (MTLogEnabled()) { + MTLog(@"[MTResendMessageService#%p request %" PRId64 " for %" PRId64 "]", self, _currentRequestMessageId, _messageId); + } } }]; } diff --git a/MTProtoKit/MTSerialization.h b/MTProtoKit/MTSerialization.h index 65eda95662..24c41c54d2 100644 --- a/MTProtoKit/MTSerialization.h +++ b/MTProtoKit/MTSerialization.h @@ -8,8 +8,16 @@ #import -#import -#import +#if defined(MtProtoKitDynamicFramework) +# import +# import +#elif defined(MtProtoKitMacFramework) +# import +# import +#else +# import +# import +#endif typedef MTExportedAuthorizationData *(^MTExportAuthorizationResponseParser)(NSData *); typedef MTDatacenterAddressListData *(^MTRequestDatacenterAddressListParser)(NSData *); diff --git a/MTProtoKit/MTSessionInfo.m b/MTProtoKit/MTSessionInfo.m index 070b167b2d..22ac33e945 100644 --- a/MTProtoKit/MTSessionInfo.m +++ b/MTProtoKit/MTSessionInfo.m @@ -6,10 +6,10 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTSessionInfo.h" -#import -#import +#import "MTLogging.h" +#import "MTContext.h" @interface MTScheduledMessageConfirmation : NSObject diff --git a/MTProtoKit/MTTcpConnection.h b/MTProtoKit/MTTcpConnection.h index e22f6a2981..e843b1cce8 100644 --- a/MTProtoKit/MTTcpConnection.h +++ b/MTProtoKit/MTTcpConnection.h @@ -6,11 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import +@class MTDatacenterAddress; @class MTContext; @class MTQueue; @class MTTcpConnection; +@class MTNetworkUsageCalculationInfo; /*! MTTcpConnection delegate protocol @@ -45,7 +47,9 @@ + (MTQueue *)tcpQueue; -- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address interface:(NSString *)interface; +- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address interface:(NSString *)interface usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; + +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; - (void)start; - (void)stop; diff --git a/MTProtoKit/MTTcpConnection.m b/MTProtoKit/MTTcpConnection.m index 0cf71223bd..70c1c73a70 100644 --- a/MTProtoKit/MTTcpConnection.m +++ b/MTProtoKit/MTTcpConnection.m @@ -6,19 +6,22 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTcpConnection.h" -#import -#import -#import +#import "MTLogging.h" +#import "MTQueue.h" +#import "MTTimer.h" #import "GCDAsyncSocket.h" #import -#import +#import "MTInternalId.h" -#import -#import +#import "MTContext.h" +#import "MTApiEnvironment.h" +#import "MTDatacenterAddress.h" + +#import "MTAes.h" MTInternalIdClass(MTTcpConnection) @@ -32,6 +35,20 @@ typedef enum { static const NSTimeInterval MTMinTcpResponseTimeout = 12.0; static const NSUInteger MTTcpProgressCalculationThreshold = 4096; +static const bool useEncryption = true; + +struct ctr_state { + unsigned char ivec[16]; /* ivec[0..7] is the IV, ivec[8..15] is the big-endian counter */ + unsigned int num; + unsigned char ecount[16]; +}; + +static void init_ctr(struct ctr_state *state, const unsigned char *iv) +{ + state->num = 0; + memset(state->ecount, 0, 16); + memcpy(state->ivec, iv, 16); +} @interface MTTcpConnection () { @@ -51,6 +68,11 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; NSData *_firstPacketControlByte; bool _addedControlHeader; + + MTAesCtr *_outgoingAesCtr; + MTAesCtr *_incomingAesCtr; + + MTNetworkUsageCalculationInfo *_usageCalculationInfo; } @property (nonatomic) int64_t packetHeadDecodeToken; @@ -71,7 +93,7 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; return queue; } -- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address interface:(NSString *)interface +- (instancetype)initWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address interface:(NSString *)interface usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { #ifdef DEBUG NSAssert(address != nil, @"address should not be nil"); @@ -82,8 +104,16 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; { _internalId = [[MTInternalId(MTTcpConnection) alloc] init]; +/*#ifdef DEBUG + if (![address isIpv6]) { + address = [[MTDatacenterAddress alloc] initWithIp:@"127.0.0.1" port:443 preferForMedia:address.preferForMedia restrictToTcp:address.restrictToTcp]; + } +#endif*/ + _address = address; + _interface = interface; + _usageCalculationInfo = usageCalculationInfo; if (context.apiEnvironment.datacenterAddressOverrides[@(datacenterId)] != nil) { _firstPacketControlByte = [context.apiEnvironment tcpPayloadPrefix]; @@ -108,6 +138,13 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; }]; } +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { + [[MTTcpConnection tcpQueue] dispatchOnQueue:^{ + _usageCalculationInfo = usageCalculationInfo; + _socket.usageCalculationInfo = usageCalculationInfo; + }]; +} + - (void)setDelegate:(id)delegate { _delegate = delegate; @@ -122,8 +159,11 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; if (_socket == nil) { _socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:[[MTTcpConnection tcpQueue] nativeQueue]]; + _socket.usageCalculationInfo = _usageCalculationInfo; - MTLog(@"[MTTcpConnection#%x connecting to %@:%d]", (int)self, _address.ip, (int)_address.port); + if (MTLogEnabled()) { + MTLog(@"[MTTcpConnection#%x connecting to %@:%d]", (int)self, _address.ip, (int)_address.port); + } NSString *ip = _address.ip; @@ -221,21 +261,52 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; uint8_t controlBytes[64]; arc4random_buf(controlBytes, 64); - int32_t *firstByte = (int32_t *)controlBytes; - while (*firstByte == 0x44414548 || *firstByte == 0x54534f50 || *firstByte == 0x20544547 || *firstByte == 0x4954504f || *firstByte == 0xeeeeeeee) { - arc4random_buf(controlBytes, 4); + if (useEncryption) { + int32_t controlVersion = 0xefefefef; + memcpy(controlBytes + 56, &controlVersion, 4); + + uint8_t controlBytesReversed[64]; + for (int i = 0; i < 64; i++) { + controlBytesReversed[i] = controlBytes[64 - 1 - i]; + } + + _outgoingAesCtr = [[MTAesCtr alloc] initWithKey:controlBytes + 8 keyLength:32 iv:controlBytes + 8 + 32]; + _incomingAesCtr = [[MTAesCtr alloc] initWithKey:controlBytesReversed + 8 keyLength:32 iv:controlBytesReversed + 8 + 32]; + + uint8_t encryptedControlBytes[64]; + [_outgoingAesCtr encryptIn:controlBytes out:encryptedControlBytes len:64]; + + NSMutableData *outData = [[NSMutableData alloc] initWithLength:64 + packetData.length]; + memcpy(outData.mutableBytes, controlBytes, 56); + memcpy(outData.mutableBytes + 56, encryptedControlBytes + 56, 8); + + [_outgoingAesCtr encryptIn:packetData.bytes out:outData.mutableBytes + 64 len:packetData.length]; + + [_socket writeData:outData withTimeout:-1 tag:0]; + } else { + int32_t *firstByte = (int32_t *)controlBytes; + while (*firstByte == 0x44414548 || *firstByte == 0x54534f50 || *firstByte == 0x20544547 || *firstByte == 0x4954504f || *firstByte == 0xeeeeeeee) { + arc4random_buf(controlBytes, 4); + } + + while (controlBytes[0] == 0xef) { + arc4random_buf(controlBytes, 1); + } + + NSMutableData *controlData = [[NSMutableData alloc] init]; + [controlData appendBytes:controlBytes length:64]; + [controlData appendData:packetData]; + [_socket writeData:controlData withTimeout:-1 tag:0]; } - - while (controlBytes[0] == 0xef) { - arc4random_buf(controlBytes, 1); - } - - NSMutableData *controlData = [[NSMutableData alloc] init]; - [controlData appendBytes:controlBytes length:64]; - [controlData appendData:packetData]; - [_socket writeData:controlData withTimeout:-1 tag:0]; } else { - [_socket writeData:packetData withTimeout:-1 tag:0]; + if (useEncryption) { + NSMutableData *encryptedData = [[NSMutableData alloc] initWithLength:packetData.length]; + [_outgoingAesCtr encryptIn:packetData.bytes out:encryptedData.mutableBytes len:packetData.length]; + + [_socket writeData:encryptedData withTimeout:-1 tag:0]; + } else { + [_socket writeData:packetData withTimeout:-1 tag:0]; + } } } @@ -255,7 +326,9 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; } else { - MTLog(@"***** %s: can't send data: connection is not opened", __PRETTY_FUNCTION__); + if (MTLogEnabled()) { + MTLog(@"***** %s: can't send data: connection is not opened", __PRETTY_FUNCTION__); + } if (completion) completion(false); @@ -274,7 +347,9 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; [_responseTimeoutTimer invalidate]; _responseTimeoutTimer = nil; - MTLog(@"[MTTcpConnection#%x response timeout]", (int)self); + if (MTLogEnabled()) { + MTLog(@"[MTTcpConnection#%x response timeout]", (int)self); + } [self stop]; } @@ -299,11 +374,21 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; } } -- (void)socket:(GCDAsyncSocket *)__unused socket didReadData:(NSData *)data withTag:(long)tag +- (void)socket:(GCDAsyncSocket *)__unused socket didReadData:(NSData *)rawData withTag:(long)tag { if (_closed) return; + NSData *data = nil; + if (useEncryption) { + NSMutableData *decryptedData = [[NSMutableData alloc] initWithLength:rawData.length]; + [_incomingAesCtr encryptIn:rawData.bytes out:decryptedData.mutableBytes len:rawData.length]; + + data = decryptedData; + } else { + data = rawData; + } + if (tag == MTTcpReadTagPacketShortLength) { #ifdef DEBUG @@ -336,7 +421,9 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; [_socket readDataToLength:3 withTimeout:-1 tag:MTTcpReadTagPacketLongLength]; else { - MTLog(@"***** %s: invalid quarter length marker (%" PRIu8 ")", __PRETTY_FUNCTION__, quarterLengthMarker); + if (MTLogEnabled()) { + MTLog(@"***** %s: invalid quarter length marker (%" PRIu8 ")", __PRETTY_FUNCTION__, quarterLengthMarker); + } [self closeAndNotify]; } } @@ -352,7 +439,9 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; if (quarterLength <= 0 || quarterLength > (4 * 1024 * 1024) / 4) { - MTLog(@"***** %s: invalid quarter length (%" PRIu32 ")", __PRETTY_FUNCTION__, quarterLength); + if (MTLogEnabled()) { + MTLog(@"***** %s: invalid quarter length (%" PRIu32 ")", __PRETTY_FUNCTION__, quarterLength); + } [self closeAndNotify]; } else @@ -447,10 +536,16 @@ static const NSUInteger MTTcpProgressCalculationThreshold = 4096; - (void)socketDidDisconnect:(GCDAsyncSocket *)__unused socket withError:(NSError *)error { - if (error != nil) - MTLog(@"[MTTcpConnection#%x disconnected from %@ (%@)]", (int)self, _address.ip, error); - else - MTLog(@"[MTTcpConnection#%x disconnected from %@]", (int)self, _address.ip); + if (error != nil) { + if (MTLogEnabled()) { + MTLog(@"[MTTcpConnection#%x disconnected from %@ (%@)]", (int)self, _address.ip, error); + } + } + else { + if (MTLogEnabled()) { + MTLog(@"[MTTcpConnection#%x disconnected from %@]", (int)self, _address.ip); + } + } [self closeAndNotify]; } diff --git a/MTProtoKit/MTTcpConnectionBehaviour.m b/MTProtoKit/MTTcpConnectionBehaviour.m index 5364bf9cf2..ac4d8e6046 100644 --- a/MTProtoKit/MTTcpConnectionBehaviour.m +++ b/MTProtoKit/MTTcpConnectionBehaviour.m @@ -8,10 +8,10 @@ #import -#import +#import "MTTcpConnectionBehaviour.h" -#import -#import +#import "MTTimer.h" +#import "MTQueue.h" @interface MTTcpConnectionBehaviour () { diff --git a/MTProtoKit/MTTcpTransport.h b/MTProtoKit/MTTcpTransport.h index 79e50064ae..1632eff7f7 100644 --- a/MTProtoKit/MTTcpTransport.h +++ b/MTProtoKit/MTTcpTransport.h @@ -6,7 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @interface MTTcpTransport : MTTransport diff --git a/MTProtoKit/MTTcpTransport.m b/MTProtoKit/MTTcpTransport.m index db741de0a6..1a557346ec 100644 --- a/MTProtoKit/MTTcpTransport.m +++ b/MTProtoKit/MTTcpTransport.m @@ -6,27 +6,27 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTcpTransport.h" -#import -#import -#import -#import +#import "MTLogging.h" +#import "MTQueue.h" +#import "MTTimer.h" +#import "MTTime.h" -#import +#import "MTDatacenterAddressSet.h" -#import -#import -#import -#import -#import +#import "MTTransportTransaction.h" +#import "MTOutgoingMessage.h" +#import "MTIncomingMessage.h" +#import "MTMessageTransaction.h" +#import "MTPreparedMessage.h" -#import -#import +#import "MTTcpConnection.h" +#import "MTTcpConnectionBehaviour.h" -#import -#import -#import +#import "MTSerialization.h" +#import "MTBuffer.h" +#import "MTPongMessage.h" static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; @@ -69,6 +69,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; MTTcpTransportContext *_transportContext; __weak MTContext *_context; NSInteger _datacenterId; + MTNetworkUsageCalculationInfo *_usageCalculationInfo; } @end @@ -86,7 +87,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; return queue; } -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { #ifdef DEBUG NSAssert(context != nil, @"context should not be nil"); @@ -94,11 +95,12 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; NSAssert(address != nil, @"address should not be nil"); #endif - self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address]; + self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address usageCalculationInfo:usageCalculationInfo]; if (self != nil) { _context = context; _datacenterId = datacenterId; + _usageCalculationInfo = usageCalculationInfo; MTTcpTransportContext *transportContext = [[MTTcpTransportContext alloc] init]; _transportContext = transportContext; @@ -135,6 +137,13 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; }]; } +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { + [[MTTcpTransport tcpTransportQueue] dispatchOnQueue:^{ + _usageCalculationInfo = usageCalculationInfo; + [_transportContext.connection setUsageCalculationInfo:usageCalculationInfo]; + }]; +} + - (bool)needsParityCorrection { return true; @@ -188,7 +197,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; [self startSleepWatchdogTimer]; MTContext *context = _context; - transportContext.connection = [[MTTcpConnection alloc] initWithContext:context datacenterId:_datacenterId address:transportContext.address interface:nil]; + transportContext.connection = [[MTTcpConnection alloc] initWithContext:context datacenterId:_datacenterId address:transportContext.address interface:nil usageCalculationInfo:_usageCalculationInfo]; transportContext.connection.delegate = self; [transportContext.connection start]; } @@ -258,7 +267,9 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; { if (ABS(currentTime - strongSelf->_transportContext.sleepWatchdogTimerLastTime) > MTTcpTransportSleepWatchdogTimeout * 2.0) { - MTLog(@"[MTTcpTransport#%p system sleep detected, resetting connection]", strongSelf); + if (MTLogEnabled()) { + MTLog(@"[MTTcpTransport#%p system sleep detected, resetting connection]", strongSelf); + } [strongSelf reset]; } strongSelf->_transportContext.sleepWatchdogTimerLastTime = currentTime; @@ -544,19 +555,25 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; { if (!transportContext.didSendActualizationPingAfterConnection) { - MTLog(@"[MTTcpTransport#%x unlocking transaction processing due to connection context update task]", (int)self); + if (MTLogEnabled()) { + MTLog(@"[MTTcpTransport#%x unlocking transaction processing due to connection context update task]", (int)self); + } transportContext.isWaitingForTransactionToBecomeReady = false; transportContext.transactionLockTime = 0.0; } else if (CFAbsoluteTimeGetCurrent() > transportContext.transactionLockTime + 1.0) { - MTLog(@"[MTTcpTransport#%x unlocking transaction processing due to timeout]", (int)self); + if (MTLogEnabled()) { + MTLog(@"[MTTcpTransport#%x unlocking transaction processing due to timeout]", (int)self); + } transportContext.isWaitingForTransactionToBecomeReady = false; transportContext.transactionLockTime = 0.0; } else { - MTLog(@"[MTTcpTransport#%x skipping transaction request]", (int)self); + if (MTLogEnabled()) { + MTLog(@"[MTTcpTransport#%x skipping transaction request]", (int)self); + } transportContext.requestAnotherTransactionWhenReady = true; return; diff --git a/MTProtoKit/MTTime.h b/MTProtoKit/MTTime.h index 56181cd9ed..21e3871be0 100644 --- a/MTProtoKit/MTTime.h +++ b/MTProtoKit/MTTime.h @@ -9,13 +9,13 @@ #ifndef MtProtoKit_MTTime_h #define MtProtoKit_MTTime_h -typedef double MTAbsoluteTime; - #ifdef __cplusplus extern "C" { #endif + +#import -MTAbsoluteTime MTAbsoluteSystemTime(); +CFAbsoluteTime MTAbsoluteSystemTime(); #ifdef __cplusplus } diff --git a/MTProtoKit/MTTime.m b/MTProtoKit/MTTime.m index 802e43d882..0d79a469b7 100644 --- a/MTProtoKit/MTTime.m +++ b/MTProtoKit/MTTime.m @@ -6,15 +6,15 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTime.h" #import -MTAbsoluteTime MTAbsoluteSystemTime() +CFAbsoluteTime MTAbsoluteSystemTime() { static mach_timebase_info_data_t s_timebase_info; if (s_timebase_info.denom == 0) mach_timebase_info(&s_timebase_info); - return ((MTAbsoluteTime)(mach_absolute_time() * s_timebase_info.numer)) / (s_timebase_info.denom * NSEC_PER_SEC); + return ((CFAbsoluteTime)(mach_absolute_time() * s_timebase_info.numer)) / (s_timebase_info.denom * NSEC_PER_SEC); } diff --git a/MTProtoKit/MTTimeFixContext.h b/MTProtoKit/MTTimeFixContext.h index 0b0615e571..501661bfbb 100644 --- a/MTProtoKit/MTTimeFixContext.h +++ b/MTProtoKit/MTTimeFixContext.h @@ -7,15 +7,14 @@ */ #import -#import @interface MTTimeFixContext : NSObject @property (nonatomic, readonly) int64_t messageId; @property (nonatomic, readonly) int32_t messageSeqNo; @property (nonatomic, strong, readonly) id transactionId; -@property (nonatomic, readonly) MTAbsoluteTime timeFixAbsoluteStartTime; +@property (nonatomic, readonly) CFAbsoluteTime timeFixAbsoluteStartTime; -- (instancetype)initWithMessageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo transactionId:(id)transactionId timeFixAbsoluteStartTime:(MTAbsoluteTime)timeFixAbsoluteStartTime; +- (instancetype)initWithMessageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo transactionId:(id)transactionId timeFixAbsoluteStartTime:(CFAbsoluteTime)timeFixAbsoluteStartTime; @end diff --git a/MTProtoKit/MTTimeFixContext.m b/MTProtoKit/MTTimeFixContext.m index 78063ee533..e06266a0e1 100644 --- a/MTProtoKit/MTTimeFixContext.m +++ b/MTProtoKit/MTTimeFixContext.m @@ -6,11 +6,11 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTimeFixContext.h" @implementation MTTimeFixContext -- (instancetype)initWithMessageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo transactionId:(id)transactionId timeFixAbsoluteStartTime:(MTAbsoluteTime)timeFixAbsoluteStartTime +- (instancetype)initWithMessageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo transactionId:(id)transactionId timeFixAbsoluteStartTime:(CFAbsoluteTime)timeFixAbsoluteStartTime { self = [super init]; if (self != nil) diff --git a/MTProtoKit/MTTimeSyncMessageService.h b/MTProtoKit/MTTimeSyncMessageService.h index 477717d03e..593d57e9f6 100644 --- a/MTProtoKit/MTTimeSyncMessageService.h +++ b/MTProtoKit/MTTimeSyncMessageService.h @@ -6,7 +6,13 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @class MTTimeSyncMessageService; diff --git a/MTProtoKit/MTTimeSyncMessageService.m b/MTProtoKit/MTTimeSyncMessageService.m index 7fbd156255..51c76f64d0 100644 --- a/MTProtoKit/MTTimeSyncMessageService.m +++ b/MTProtoKit/MTTimeSyncMessageService.m @@ -6,25 +6,25 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTimeSyncMessageService.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "MTTime.h" +#import "MTContext.h" +#import "MTProto.h" +#import "MTSerialization.h" +#import "MTOutgoingMessage.h" +#import "MTIncomingMessage.h" +#import "MTPreparedMessage.h" +#import "MTMessageTransaction.h" +#import "MTDatacenterSaltInfo.h" +#import "MTBuffer.h" +#import "MTFutureSaltsMessage.h" @interface MTTimeSyncMessageService () { int64_t _currentMessageId; id _currentTransactionId; - MTAbsoluteTime _currentSampleAbsoluteStartTime; + CFAbsoluteTime _currentSampleAbsoluteStartTime; NSUInteger _takenSampleCount; NSUInteger _requiredSampleCount; diff --git a/MTProtoKit/MTTimer.m b/MTProtoKit/MTTimer.m index 9b1deb1467..33b1a76077 100644 --- a/MTProtoKit/MTTimer.m +++ b/MTProtoKit/MTTimer.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTimer.h" @interface MTTimer () diff --git a/MTProtoKit/MTTransport.h b/MTProtoKit/MTTransport.h index 82be0d3f6b..801b642dce 100644 --- a/MTProtoKit/MTTransport.h +++ b/MTProtoKit/MTTransport.h @@ -6,16 +6,24 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import +@class MTContext; @class MTDatacenterAddress; @class MTTransport; @class MTTransportTransaction; @class MTOutgoingMessage; @class MTIncomingMessage; @class MTMessageTransaction; +@class MTNetworkUsageCalculationInfo; -#import +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif @protocol MTTransportDelegate @@ -44,7 +52,9 @@ @property (nonatomic) bool simultaneousTransactionsEnabled; @property (nonatomic) bool reportTransportConnectionContextUpdateStates; -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address; +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; + +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; - (bool)needsParityCorrection; diff --git a/MTProtoKit/MTTransport.m b/MTProtoKit/MTTransport.m index a9bad210f8..5e92de3923 100644 --- a/MTProtoKit/MTTransport.m +++ b/MTProtoKit/MTTransport.m @@ -6,9 +6,10 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTransport.h" -#import +#import "MTContext.h" +#import "MTNetworkAvailability.h" @interface MTTransport () { @@ -19,7 +20,7 @@ @implementation MTTransport -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)__unused usageCalculationInfo { #ifdef DEBUG NSAssert(context != nil, @"context should not be nil"); @@ -40,6 +41,9 @@ return self; } +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)__unused usageCalculationInfo { +} + - (bool)needsParityCorrection { return false; diff --git a/MTProtoKit/MTTransportScheme.h b/MTProtoKit/MTTransportScheme.h index d218704b41..764f215d71 100644 --- a/MTProtoKit/MTTransportScheme.h +++ b/MTProtoKit/MTTransportScheme.h @@ -12,6 +12,7 @@ @class MTTransport; @class MTDatacenterAddress; @protocol MTTransportDelegate; +@class MTNetworkUsageCalculationInfo; @interface MTTransportScheme : NSObject @@ -25,6 +26,6 @@ - (BOOL)isOptimal; - (NSComparisonResult)compareToScheme:(MTTransportScheme *)other; -- (MTTransport *)createTransportWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId delegate:(id)delegate; +- (MTTransport *)createTransportWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId delegate:(id)delegate usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; @end diff --git a/MTProtoKit/MTTransportScheme.m b/MTProtoKit/MTTransportScheme.m index 9da0f1b71d..69dc11d188 100644 --- a/MTProtoKit/MTTransportScheme.m +++ b/MTProtoKit/MTTransportScheme.m @@ -6,12 +6,12 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTransportScheme.h" -#import -#import +#import "MTTransport.h" +#import "MTDatacenterAddress.h" -#import +#import "MTTcpTransport.h" @interface MTTransportScheme () { @@ -87,9 +87,9 @@ return NSOrderedSame; } -- (MTTransport *)createTransportWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId delegate:(id)delegate +- (MTTransport *)createTransportWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId delegate:(id)delegate usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { - return [(MTTransport *)[_transportClass alloc] initWithDelegate:delegate context:context datacenterId:datacenterId address:_address]; + return [(MTTransport *)[_transportClass alloc] initWithDelegate:delegate context:context datacenterId:datacenterId address:_address usageCalculationInfo:usageCalculationInfo]; } - (NSString *)description diff --git a/MTProtoKit/MTTransportTransaction.m b/MTProtoKit/MTTransportTransaction.m index 0b7fbb13ce..1608f0b3c1 100644 --- a/MTProtoKit/MTTransportTransaction.m +++ b/MTProtoKit/MTTransportTransaction.m @@ -6,7 +6,7 @@ * Copyright Peter Iakovlev, 2013. */ -#import +#import "MTTransportTransaction.h" @implementation MTTransportTransaction diff --git a/MTRsa.h b/MTRsa.h new file mode 100644 index 0000000000..123319aa21 --- /dev/null +++ b/MTRsa.h @@ -0,0 +1,21 @@ +#import + +@interface MTRsa : NSObject + +// return base64 encoded string ++ (NSString *)encryptString:(NSString *)str publicKey:(NSString *)pubKey; +// return raw data ++ (NSData *)encryptData:(NSData *)data publicKey:(NSString *)pubKey; +// return base64 encoded string +// enc with private key NOT working YET! +//+ (NSString *)encryptString:(NSString *)str privateKey:(NSString *)privKey; +// return raw data +//+ (NSData *)encryptData:(NSData *)data privateKey:(NSString *)privKey; + +// decrypt base64 encoded string, convert result to string(not base64 encoded) ++ (NSString *)decryptString:(NSString *)str publicKey:(NSString *)pubKey; ++ (NSData *)decryptData:(NSData *)data publicKey:(NSString *)pubKey; ++ (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey; ++ (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey; + +@end diff --git a/MTRsa.m b/MTRsa.m new file mode 100644 index 0000000000..c8dcc54390 --- /dev/null +++ b/MTRsa.m @@ -0,0 +1,448 @@ +#import "MTRsa.h" + +/* + @author: ideawu + @link: https://github.com/ideawu/Objective-C-RSA + */ + +#import + +@implementation MTRsa + +/* + static NSString *base64_encode(NSString *str){ + NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding]; + if(!data){ + return nil; + } + return base64_encode_data(data); + } + */ + +NSString *MTStringByEncodingInBase64(NSData *data) { + NSUInteger length = [data length]; + NSMutableData *mutableData = [[NSMutableData alloc] initWithLength:((length + 2) / 3) * 4]; + + uint8_t *input = (uint8_t *)[data bytes]; + uint8_t *output = (uint8_t *)[mutableData mutableBytes]; + + for (NSUInteger i = 0; i < length; i += 3) + { + NSUInteger value = 0; + for (NSUInteger j = i; j < (i + 3); j++) + { + value <<= 8; + if (j < length) + { + value |= (0xFF & input[j]); + } + } + + static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + NSUInteger idx = (i / 3) * 4; + output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; + output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; + output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; + output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; + } + + return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; +} + +static NSString *base64_encode_data(NSData *data) { + if ([data respondsToSelector:@selector(base64EncodedDataWithOptions:)]) { + data = [data base64EncodedDataWithOptions:0]; + NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return ret; + } else { + return MTStringByEncodingInBase64(data); + } +} + +static NSData *base64_decode(NSString *str) { + if ([NSData instancesRespondToSelector:@selector(initWithBase64EncodedString:options:)]) { + NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters]; + return data; + } else { + return [[NSData alloc] initWithBase64Encoding:[str stringByReplacingOccurrencesOfString:@"[^A-Za-z0-9+/=]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, [str length])]]; + } +} + ++ (NSData *)stripPublicKeyHeader:(NSData *)d_key{ + // Skip ASN.1 public key header + if (d_key == nil) return(nil); + + unsigned long len = [d_key length]; + if (!len) return(nil); + + unsigned char *c_key = (unsigned char *)[d_key bytes]; + unsigned int idx = 0; + + if (c_key[idx++] != 0x30) return(nil); + + if (c_key[idx] > 0x80) idx += c_key[idx] - 0x80 + 1; + else idx++; + + // PKCS #1 rsaEncryption szOID_RSA_RSA + static unsigned char seqiod[] = + { 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0x05, 0x00 }; + if (memcmp(&c_key[idx], seqiod, 15)) return(nil); + + idx += 15; + + if (c_key[idx++] != 0x03) return(nil); + + if (c_key[idx] > 0x80) idx += c_key[idx] - 0x80 + 1; + else idx++; + + if (c_key[idx++] != '\0') return(nil); + + // Now make a new NSData from this buffer + return([NSData dataWithBytes:&c_key[idx] length:len - idx]); +} + +//credit: http://hg.mozilla.org/services/fx-home/file/tip/Sources/NetworkAndStorage/CryptoUtils.m#l1036 ++ (NSData *)stripPrivateKeyHeader:(NSData *)d_key{ + // Skip ASN.1 private key header + if (d_key == nil) return(nil); + + unsigned long len = [d_key length]; + if (!len) return(nil); + + unsigned char *c_key = (unsigned char *)[d_key bytes]; + unsigned int idx = 22; //magic byte at offset 22 + + if (0x04 != c_key[idx++]) return nil; + + //calculate length of the key + unsigned int c_len = c_key[idx++]; + int det = c_len & 0x80; + if (!det) { + c_len = c_len & 0x7f; + } else { + int byteCount = c_len & 0x7f; + if (byteCount + idx > len) { + //rsa length field longer than buffer + return nil; + } + unsigned int accum = 0; + unsigned char *ptr = &c_key[idx]; + idx += byteCount; + while (byteCount) { + accum = (accum << 8) + *ptr; + ptr++; + byteCount--; + } + c_len = accum; + } + + // Now make a new NSData from this buffer + return [d_key subdataWithRange:NSMakeRange(idx, c_len)]; +} + ++ (SecKeyRef)addPublicKey:(NSString *)key_s { + NSString *key = [[key_s stringByReplacingOccurrencesOfString:@"-----BEGIN RSA PUBLIC KEY-----\n" withString:@"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A"] stringByReplacingOccurrencesOfString:@"-----END RSA PUBLIC KEY-----" withString:@"-----END PUBLIC KEY-----"]; + NSRange spos = [key rangeOfString:@"-----BEGIN PUBLIC KEY-----"]; + NSRange epos = [key rangeOfString:@"-----END PUBLIC KEY-----"]; + if(spos.location != NSNotFound && epos.location != NSNotFound){ + NSUInteger s = spos.location + spos.length; + NSUInteger e = epos.location; + NSRange range = NSMakeRange(s, e-s); + key = [key substringWithRange:range]; + } + key = [key stringByReplacingOccurrencesOfString:@"\r" withString:@""]; + key = [key stringByReplacingOccurrencesOfString:@"\n" withString:@""]; + key = [key stringByReplacingOccurrencesOfString:@"\t" withString:@""]; + key = [key stringByReplacingOccurrencesOfString:@" " withString:@""]; + + // This will be base64 encoded, decode it. + NSData *data = base64_decode(key); + data = [MTRsa stripPublicKeyHeader:data]; + if(!data){ + return nil; + } + + //a tag to read/write keychain storage + NSString *tag = @"RSAUtil_PubKey"; + NSData *d_tag = [NSData dataWithBytes:[tag UTF8String] length:[tag length]]; + + // Delete any old lingering key with the same tag + NSMutableDictionary *publicKey = [[NSMutableDictionary alloc] init]; + [publicKey setObject:(__bridge id) kSecClassKey forKey:(__bridge id)kSecClass]; + [publicKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + [publicKey setObject:d_tag forKey:(__bridge id)kSecAttrApplicationTag]; + SecItemDelete((__bridge CFDictionaryRef)publicKey); + + // Add persistent version of the key to system keychain + [publicKey setObject:data forKey:(__bridge id)kSecValueData]; + [publicKey setObject:(__bridge id) kSecAttrKeyClassPublic forKey:(__bridge id) + kSecAttrKeyClass]; + [publicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id) + kSecReturnPersistentRef]; + + CFTypeRef persistKey = nil; + OSStatus status = SecItemAdd((__bridge CFDictionaryRef)publicKey, &persistKey); + if (persistKey != nil){ + CFRelease(persistKey); + } + if ((status != noErr) && (status != errSecDuplicateItem)) { + return nil; + } + + [publicKey removeObjectForKey:(__bridge id)kSecValueData]; + [publicKey removeObjectForKey:(__bridge id)kSecReturnPersistentRef]; + [publicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef]; + [publicKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + + // Now fetch the SecKeyRef version of the key + SecKeyRef keyRef = nil; + status = SecItemCopyMatching((__bridge CFDictionaryRef)publicKey, (CFTypeRef *)&keyRef); + if(status != noErr){ + return nil; + } + return keyRef; +} + ++ (SecKeyRef)addPrivateKey:(NSString *)key{ + NSRange spos; + NSRange epos; + spos = [key rangeOfString:@"-----BEGIN RSA PRIVATE KEY-----"]; + if(spos.length > 0){ + epos = [key rangeOfString:@"-----END RSA PRIVATE KEY-----"]; + }else{ + spos = [key rangeOfString:@"-----BEGIN PRIVATE KEY-----"]; + epos = [key rangeOfString:@"-----END PRIVATE KEY-----"]; + } + if(spos.location != NSNotFound && epos.location != NSNotFound){ + NSUInteger s = spos.location + spos.length; + NSUInteger e = epos.location; + NSRange range = NSMakeRange(s, e-s); + key = [key substringWithRange:range]; + } + key = [key stringByReplacingOccurrencesOfString:@"\r" withString:@""]; + key = [key stringByReplacingOccurrencesOfString:@"\n" withString:@""]; + key = [key stringByReplacingOccurrencesOfString:@"\t" withString:@""]; + key = [key stringByReplacingOccurrencesOfString:@" " withString:@""]; + + // This will be base64 encoded, decode it. + NSData *data = base64_decode(key); + data = [MTRsa stripPrivateKeyHeader:data]; + if(!data){ + return nil; + } + + //a tag to read/write keychain storage + NSString *tag = @"RSAUtil_PrivKey"; + NSData *d_tag = [NSData dataWithBytes:[tag UTF8String] length:[tag length]]; + + // Delete any old lingering key with the same tag + NSMutableDictionary *privateKey = [[NSMutableDictionary alloc] init]; + [privateKey setObject:(__bridge id) kSecClassKey forKey:(__bridge id)kSecClass]; + [privateKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + [privateKey setObject:d_tag forKey:(__bridge id)kSecAttrApplicationTag]; + SecItemDelete((__bridge CFDictionaryRef)privateKey); + + // Add persistent version of the key to system keychain + [privateKey setObject:data forKey:(__bridge id)kSecValueData]; + [privateKey setObject:(__bridge id) kSecAttrKeyClassPrivate forKey:(__bridge id) + kSecAttrKeyClass]; + [privateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id) + kSecReturnPersistentRef]; + + CFTypeRef persistKey = nil; + OSStatus status = SecItemAdd((__bridge CFDictionaryRef)privateKey, &persistKey); + if (persistKey != nil){ + CFRelease(persistKey); + } + if ((status != noErr) && (status != errSecDuplicateItem)) { + return nil; + } + + [privateKey removeObjectForKey:(__bridge id)kSecValueData]; + [privateKey removeObjectForKey:(__bridge id)kSecReturnPersistentRef]; + [privateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef]; + [privateKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + + // Now fetch the SecKeyRef version of the key + SecKeyRef keyRef = nil; + status = SecItemCopyMatching((__bridge CFDictionaryRef)privateKey, (CFTypeRef *)&keyRef); + if(status != noErr){ + return nil; + } + return keyRef; +} + +/* START: Encryption & Decryption with RSA private key */ + ++ (NSData *)encryptData:(NSData *)data withKeyRef:(SecKeyRef) keyRef{ + const uint8_t *srcbuf = (const uint8_t *)[data bytes]; + size_t srclen = (size_t)data.length; + + size_t block_size = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t); + void *outbuf = malloc(block_size); + size_t src_block_size = block_size; + + NSMutableData *ret = [[NSMutableData alloc] init]; + for(int idx=0; idx src_block_size){ + data_len = src_block_size; + } + + size_t outlen = block_size; + OSStatus status = noErr; + status = SecKeyEncrypt(keyRef, + kSecPaddingNone, + srcbuf + idx, + data_len, + outbuf, + &outlen + ); + if (status != 0) { + NSLog(@"SecKeyEncrypt fail. Error Code: %d", status); + ret = nil; + break; + }else{ + [ret appendBytes:outbuf length:outlen]; + } + } + + free(outbuf); + CFRelease(keyRef); + return ret; +} + ++ (NSString *)encryptString:(NSString *)str privateKey:(NSString *)privKey{ + NSData *data = [MTRsa encryptData:[str dataUsingEncoding:NSUTF8StringEncoding] privateKey:privKey]; + NSString *ret = base64_encode_data(data); + return ret; +} + ++ (NSData *)encryptData:(NSData *)data privateKey:(NSString *)privKey{ + if(!data || !privKey){ + return nil; + } + SecKeyRef keyRef = [MTRsa addPrivateKey:privKey]; + if(!keyRef){ + return nil; + } + return [MTRsa encryptData:data withKeyRef:keyRef]; +} + ++ (NSData *)decryptData:(NSData *)data withKeyRef:(SecKeyRef) keyRef{ + const uint8_t *srcbuf = (const uint8_t *)[data bytes]; + size_t srclen = (size_t)data.length; + + size_t block_size = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t); + UInt8 *outbuf = malloc(block_size); + size_t src_block_size = block_size; + + NSMutableData *ret = [[NSMutableData alloc] init]; + for(int idx=0; idx src_block_size){ + data_len = src_block_size; + } + + size_t outlen = block_size; + OSStatus status = noErr; + status = SecKeyDecrypt(keyRef, + kSecPaddingNone, + srcbuf + idx, + data_len, + outbuf, + &outlen + ); + if (status != 0) { + NSLog(@"SecKeyEncrypt fail. Error Code: %d", status); + ret = nil; + break; + }else{ + //the actual decrypted data is in the middle, locate it! + int idxFirstZero = -1; + int idxNextZero = (int)outlen; + for ( int i = 0; i < outlen; i++ ) { + if ( outbuf[i] == 0 ) { + if ( idxFirstZero < 0 ) { + idxFirstZero = i; + } else { + idxNextZero = i; + break; + } + } + } + + [ret appendBytes:&outbuf[idxFirstZero+1] length:idxNextZero-idxFirstZero-1]; + } + } + + free(outbuf); + CFRelease(keyRef); + return ret; +} + + ++ (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey{ + NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters]; + data = [MTRsa decryptData:data privateKey:privKey]; + NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return ret; +} + ++ (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey{ + if(!data || !privKey){ + return nil; + } + SecKeyRef keyRef = [MTRsa addPrivateKey:privKey]; + if(!keyRef){ + return nil; + } + return [MTRsa decryptData:data withKeyRef:keyRef]; +} + +/* END: Encryption & Decryption with RSA private key */ + +/* START: Encryption & Decryption with RSA public key */ + ++ (NSString *)encryptString:(NSString *)str publicKey:(NSString *)pubKey{ + NSData *data = [MTRsa encryptData:[str dataUsingEncoding:NSUTF8StringEncoding] publicKey:pubKey]; + NSString *ret = base64_encode_data(data); + return ret; +} + ++ (NSData *)encryptData:(NSData *)data publicKey:(NSString *)pubKey{ + if(!data || !pubKey){ + return nil; + } + SecKeyRef keyRef = [MTRsa addPublicKey:pubKey]; + if(!keyRef){ + return nil; + } + return [MTRsa encryptData:data withKeyRef:keyRef]; +} + ++ (NSString *)decryptString:(NSString *)str publicKey:(NSString *)pubKey{ + NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters]; + data = [MTRsa decryptData:data publicKey:pubKey]; + NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return ret; +} + ++ (NSData *)decryptData:(NSData *)data publicKey:(NSString *)pubKey{ + if(!data || !pubKey){ + return nil; + } + SecKeyRef keyRef = [MTRsa addPublicKey:pubKey]; + if(!keyRef){ + return nil; + } + return [MTRsa decryptData:data withKeyRef:keyRef]; +} + +/* END: Encryption & Decryption with RSA public key */ + +@end diff --git a/MTSignal.h b/MTSignal.h new file mode 100644 index 0000000000..a21766aca3 --- /dev/null +++ b/MTSignal.h @@ -0,0 +1,62 @@ +#import + +#import "MTSubscriber.h" + +@class MTQueue; + +@interface MTSignal : NSObject +{ +@public + id (^_generator)(MTSubscriber *); +} + +- (instancetype)initWithGenerator:(id (^)(MTSubscriber *))generator; + +- (id)startWithNext:(void (^)(id next))next error:(void (^)(id error))error completed:(void (^)())completed; +- (id)startWithNext:(void (^)(id next))next; +- (id)startWithNext:(void (^)(id next))next completed:(void (^)())completed; + ++ (MTSignal *)single:(id)next; ++ (MTSignal *)fail:(id)error; ++ (MTSignal *)never; ++ (MTSignal *)complete; + +- (MTSignal *)then:(MTSignal *)signal; + +- (MTSignal *)delay:(NSTimeInterval)seconds onQueue:(MTQueue *)queue; +- (MTSignal *)timeout:(NSTimeInterval)seconds onQueue:(MTQueue *)queue orSignal:(MTSignal *)signal; + +- (MTSignal *)catch:(MTSignal *(^)(id error))f; + ++ (MTSignal *)mergeSignals:(NSArray *)signals; + +- (MTSignal *)restart; + +- (MTSignal *)take:(NSUInteger)count; + +- (MTSignal *)switchToLatest; + +- (MTSignal *)map:(id (^)(id))f; +- (MTSignal *)filter:(bool (^)(id))f; +- (MTSignal *)mapToSignal:(MTSignal *(^)(id))f; + +- (MTSignal *)onDispose:(void (^)())f; + +- (MTSignal *)deliverOn:(MTQueue *)queue; +- (MTSignal *)startOn:(MTQueue *)queue; + +- (MTSignal *)take:(NSUInteger)count; +- (MTSignal *)takeLast; + +- (MTSignal *)reduceLeft:(id)value with:(id (^)(id, id))f; + +@end + +@interface MTPipe : NSObject + +@property (nonatomic, copy, readonly) MTSignal *(^signalProducer)(); +@property (nonatomic, copy, readonly) void (^sink)(id); + +- (instancetype)initWithReplay:(bool)replay; + +@end diff --git a/MTSignal.m b/MTSignal.m new file mode 100644 index 0000000000..b42001442e --- /dev/null +++ b/MTSignal.m @@ -0,0 +1,817 @@ +#import "MTSignal.h" + +#if defined(MtProtoKitDynamicFramework) +# import +#elif defined(MtProtoKitMacFramework) +# import +#else +# import +#endif + +#import + +@interface MTSubscriberDisposable : NSObject +{ + MTSubscriber *_subscriber; + id _disposable; +} + +@end + +@implementation MTSubscriberDisposable + +- (instancetype)initWithSubscriber:(MTSubscriber *)subscriber disposable:(id)disposable +{ + self = [super init]; + if (self != nil) + { + _subscriber = subscriber; + _disposable = disposable; + } + return self; +} + +- (void)dispose +{ + [_subscriber _markTerminatedWithoutDisposal]; + [_disposable dispose]; +} + +@end + +@interface MTSignal_ValueContainer : NSObject + +@property (nonatomic, strong, readonly) id value; + +@end + +@implementation MTSignal_ValueContainer + +- (instancetype)initWithValue:(id)value { + self = [super init]; + if (self != nil) { + _value = value; + } + return self; +} + +@end + +@interface MTSignalQueueState : NSObject +{ + OSSpinLock _lock; + bool _executingSignal; + bool _terminated; + + id _disposable; + MTMetaDisposable *_currentDisposable; + MTSubscriber *_subscriber; + + NSMutableArray *_queuedSignals; + bool _queueMode; +} + +@end + +@implementation MTSignalQueueState + +- (instancetype)initWithSubscriber:(MTSubscriber *)subscriber queueMode:(bool)queueMode +{ + self = [super init]; + if (self != nil) + { + _subscriber = subscriber; + _currentDisposable = [[MTMetaDisposable alloc] init]; + _queuedSignals = queueMode ? [[NSMutableArray alloc] init] : nil; + _queueMode = queueMode; + } + return self; +} + +- (void)beginWithDisposable:(id)disposable +{ + _disposable = disposable; +} + +- (void)enqueueSignal:(MTSignal *)signal +{ + bool startSignal = false; + OSSpinLockLock(&_lock); + if (_queueMode && _executingSignal) + { + [_queuedSignals addObject:signal]; + } + else + { + _executingSignal = true; + startSignal = true; + } + OSSpinLockUnlock(&_lock); + + if (startSignal) + { + __weak MTSignalQueueState *weakSelf = self; + id disposable = [signal startWithNext:^(id next) + { + [_subscriber putNext:next]; + } error:^(id error) + { + [_subscriber putError:error]; + } completed:^ + { + __strong MTSignalQueueState *strongSelf = weakSelf; + if (strongSelf != nil) { + [strongSelf headCompleted]; + } + }]; + + [_currentDisposable setDisposable:disposable]; + } +} + +- (void)headCompleted +{ + MTSignal *nextSignal = nil; + + bool terminated = false; + OSSpinLockLock(&_lock); + _executingSignal = false; + + if (_queueMode) + { + if (_queuedSignals.count != 0) + { + nextSignal = _queuedSignals[0]; + [_queuedSignals removeObjectAtIndex:0]; + _executingSignal = true; + } + else + terminated = _terminated; + } + else + terminated = _terminated; + OSSpinLockUnlock(&_lock); + + if (terminated) + [_subscriber putCompletion]; + else if (nextSignal != nil) + { + __weak MTSignalQueueState *weakSelf = self; + id disposable = [nextSignal startWithNext:^(id next) + { + [_subscriber putNext:next]; + } error:^(id error) + { + [_subscriber putError:error]; + } completed:^ + { + __strong MTSignalQueueState *strongSelf = weakSelf; + if (strongSelf != nil) { + [strongSelf headCompleted]; + } +}]; + + [_currentDisposable setDisposable:disposable]; + } +} + +- (void)beginCompletion +{ + bool executingSignal = false; + OSSpinLockLock(&_lock); + executingSignal = _executingSignal; + _terminated = true; + OSSpinLockUnlock(&_lock); + + if (!executingSignal) + [_subscriber putCompletion]; +} + +- (void)dispose +{ + [_currentDisposable dispose]; + [_disposable dispose]; +} + +@end + +@implementation MTSignal + +- (instancetype)initWithGenerator:(id (^)(MTSubscriber *))generator +{ + self = [super init]; + if (self != nil) + { + _generator = [generator copy]; + } + return self; +} + +- (id)startWithNext:(void (^)(id next))next error:(void (^)(id error))error completed:(void (^)())completed +{ + MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:error completed:completed]; + id disposable = _generator(subscriber); + [subscriber _assignDisposable:disposable]; + return [[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable]; +} + +- (id)startWithNext:(void (^)(id next))next +{ + MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:nil completed:nil]; + id disposable = _generator(subscriber); + [subscriber _assignDisposable:disposable]; + return [[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable]; +} + +- (id)startWithNext:(void (^)(id next))next completed:(void (^)())completed +{ + MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:nil completed:completed]; + id disposable = _generator(subscriber); + [subscriber _assignDisposable:disposable]; + return [[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable]; +} + ++ (MTSignal *)single:(id)next +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + [subscriber putNext:next]; + [subscriber putCompletion]; + return nil; + }]; +} + ++ (MTSignal *)fail:(id)error +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + [subscriber putError:error]; + return nil; + }]; +} + ++ (MTSignal *)never +{ + return [[MTSignal alloc] initWithGenerator:^id (__unused MTSubscriber *subscriber) + { + return nil; + }]; +} + ++ (MTSignal *)complete +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + [subscriber putCompletion]; + return nil; + }]; +} + +- (MTSignal *)then:(MTSignal *)signal +{ + return [[MTSignal alloc] initWithGenerator:^(MTSubscriber *subscriber) + { + MTDisposableSet *compositeDisposable = [[MTDisposableSet alloc] init]; + + MTMetaDisposable *currentDisposable = [[MTMetaDisposable alloc] init]; + [compositeDisposable add:currentDisposable]; + + [currentDisposable setDisposable:[self startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [compositeDisposable add:[signal startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + }]]; + + return compositeDisposable; + }]; +} + +- (MTSignal *)delay:(NSTimeInterval)seconds onQueue:(MTQueue *)queue +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; + + MTTimer *timer = [[MTTimer alloc] initWithTimeout:seconds repeat:false completion:^ + { + [disposable setDisposable:[self startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + } queue:queue.nativeQueue]; + + [timer start]; + + [disposable setDisposable:[[MTBlockDisposable alloc] initWithBlock:^ + { + [timer invalidate]; + }]]; + + return disposable; + }]; +} + +- (MTSignal *)timeout:(NSTimeInterval)seconds onQueue:(MTQueue *)queue orSignal:(MTSignal *)signal +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; + + MTTimer *timer = [[MTTimer alloc] initWithTimeout:seconds repeat:false completion:^ + { + [disposable setDisposable:[signal startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + } queue:queue.nativeQueue]; + [timer start]; + + [disposable setDisposable:[self startWithNext:^(id next) + { + [timer invalidate]; + [subscriber putNext:next]; + } error:^(id error) + { + [timer invalidate]; + [subscriber putError:error]; + } completed:^ + { + [timer invalidate]; + [subscriber putCompletion]; + }]]; + + return disposable; + }]; +} + +- (MTSignal *)catch:(MTSignal *(^)(id error))f +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + MTDisposableSet *disposable = [[MTDisposableSet alloc] init]; + + [disposable add:[self startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + MTSignal *signal = f(error); + [disposable add:[signal startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + + return disposable; + }]; +} + ++ (MTSignal *)mergeSignals:(NSArray *)signals +{ + if (signals.count == 0) + return [MTSignal complete]; + + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) + { + MTDisposableSet *disposables = [[MTDisposableSet alloc] init]; + MTAtomic *completedStates = [[MTAtomic alloc] initWithValue:[[NSSet alloc] init]]; + + NSInteger index = -1; + NSUInteger count = signals.count; + for (MTSignal *signal in signals) + { + index++; + + id disposable = [signal startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + NSSet *set = [completedStates modify:^id(NSSet *set) + { + return [set setByAddingObject:@(index)]; + }]; + if (set.count == count) + [subscriber putCompletion]; + }]; + + [disposables add:disposable]; + } + + return disposables; + }]; +}; + +static dispatch_block_t recursiveBlock(void (^block)(dispatch_block_t recurse)) +{ + return ^ + { + block(recursiveBlock(block)); + }; +} + +- (MTSignal *)restart +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + MTAtomic *shouldRestart = [[MTAtomic alloc] initWithValue:@true]; + + MTMetaDisposable *currentDisposable = [[MTMetaDisposable alloc] init]; + + void (^start)() = recursiveBlock(^(dispatch_block_t recurse) + { + NSNumber *currentShouldRestart = [shouldRestart with:^id(NSNumber *current) + { + return current; + }]; + + if ([currentShouldRestart boolValue]) + { + id disposable = [self startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + recurse(); + }]; + [currentDisposable setDisposable:disposable]; + } + }); + + start(); + + return [[MTBlockDisposable alloc] initWithBlock:^ + { + [currentDisposable dispose]; + + [shouldRestart modify:^id(__unused id current) + { + return @false; + }]; + }]; + }]; +} + +- (MTSignal *)take:(NSUInteger)count +{ + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) + { + MTAtomic *counter = [[MTAtomic alloc] initWithValue:@(0)]; + return [self startWithNext:^(id next) + { + __block bool passthrough = false; + __block bool complete = false; + [counter modify:^id(NSNumber *currentCount) + { + NSUInteger updatedCount = [currentCount unsignedIntegerValue] + 1; + if (updatedCount <= count) + passthrough = true; + if (updatedCount == count) + complete = true; + return @(updatedCount); + }]; + + if (passthrough) + [subscriber putNext:next]; + if (complete) + [subscriber putCompletion]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]; + }]; +} + +- (MTSignal *)switchToLatest +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + MTSignalQueueState *state = [[MTSignalQueueState alloc] initWithSubscriber:subscriber queueMode:false]; + + [state beginWithDisposable:[self startWithNext:^(id next) + { + [state enqueueSignal:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [state beginCompletion]; + }]]; + + return state; + }]; +} + +- (MTSignal *)map:(id (^)(id))f { + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + return [self startWithNext:^(id next) + { + [subscriber putNext:f(next)]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]; + }]; +} + +- (MTSignal *)filter:(bool (^)(id))f +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + return [self startWithNext:^(id next) + { + if (f(next)) + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]; + }]; +} + +- (MTSignal *)mapToSignal:(MTSignal *(^)(id))f +{ + return [[self map:f] switchToLatest]; +} + +- (MTSignal *)onDispose:(void (^)())f +{ + return [[MTSignal alloc] initWithGenerator:^(MTSubscriber *subscriber) + { + MTDisposableSet *compositeDisposable = [[MTDisposableSet alloc] init]; + + [compositeDisposable add:[self startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + + [compositeDisposable add:[[MTBlockDisposable alloc] initWithBlock:^ + { + f(); + }]]; + + return compositeDisposable; + }]; +} + +- (MTSignal *)deliverOn:(MTQueue *)queue +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + return [self startWithNext:^(id next) + { + [queue dispatchOnQueue:^ + { + [subscriber putNext:next]; + }]; + } error:^(id error) + { + [queue dispatchOnQueue:^ + { + [subscriber putError:error]; + }]; + } completed:^ + { + [queue dispatchOnQueue:^ + { + [subscriber putCompletion]; + }]; + }]; + }]; +} + +- (MTSignal *)startOn:(MTQueue *)queue +{ + return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) + { + __block bool isCancelled = false; + MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; + [disposable setDisposable:[[MTBlockDisposable alloc] initWithBlock:^ + { + isCancelled = true; + }]]; + + [queue dispatchOnQueue:^ + { + if (!isCancelled) + { + [disposable setDisposable:[self startWithNext:^(id next) + { + [subscriber putNext:next]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + [subscriber putCompletion]; + }]]; + } + }]; + + return disposable; + }]; +} + +- (MTSignal *)takeLast +{ + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) + { + MTAtomic *last = [[MTAtomic alloc] initWithValue:nil]; + return [self startWithNext:^(id next) + { + [last swap:[[MTSignal_ValueContainer alloc] initWithValue:next]]; + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + MTSignal_ValueContainer *value = [last with:^id(id value) { + return value; + }]; + if (value != nil) + { + [subscriber putNext:value.value]; + } + [subscriber putCompletion]; + }]; + }]; +} + +- (MTSignal *)reduceLeft:(id)value with:(id (^)(id, id))f +{ + return [[MTSignal alloc] initWithGenerator:^(MTSubscriber *subscriber) + { + __block id intermediateResult = value; + + return [self startWithNext:^(id next) + { + intermediateResult = f(intermediateResult, next); + } error:^(id error) + { + [subscriber putError:error]; + } completed:^ + { + if (intermediateResult != nil) + [subscriber putNext:intermediateResult]; + [subscriber putCompletion]; + }]; + }]; +} + +@end + +@interface MTPipeReplayState : NSObject + +@property (nonatomic, readonly) bool hasReceivedValue; +@property (nonatomic, strong, readonly) id recentValue; + +@end + +@implementation MTPipeReplayState + +- (instancetype)initWithReceivedValue:(bool)receivedValue recentValue:(id)recentValue +{ + self = [super init]; + if (self != nil) + { + _hasReceivedValue = receivedValue; + _recentValue = recentValue; + } + return self; +} + +@end + +@implementation MTPipe + +- (instancetype)init +{ + return [self initWithReplay:false]; +} + +- (instancetype)initWithReplay:(bool)replay +{ + self = [super init]; + if (self != nil) + { + MTAtomic *subscribers = [[MTAtomic alloc] initWithValue:[[MTBag alloc] init]]; + MTAtomic *replayState = replay ? [[MTAtomic alloc] initWithValue:[[MTPipeReplayState alloc] initWithReceivedValue:false recentValue:nil]] : nil; + + _signalProducer = [^MTSignal * + { + return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) + { + __block NSUInteger index = 0; + [subscribers with:^id(MTBag *bag) + { + index = [bag addItem:[^(id next) + { + [subscriber putNext:next]; + } copy]]; + return nil; + }]; + + if (replay) + { + [replayState with:^id(MTPipeReplayState *state) + { + if (state.hasReceivedValue) + [subscriber putNext:state.recentValue]; + return nil; + }]; + } + + return [[MTBlockDisposable alloc] initWithBlock:^ + { + [subscribers with:^id(MTBag *bag) + { + [bag removeItem:index]; + return nil; + }]; + }]; + }]; + } copy]; + + _sink = [^(id next) + { + NSArray *items = [subscribers with:^id(MTBag *bag) + { + return [bag copyItems]; + }]; + + for (void (^item)(id) in items) + { + item(next); + } + + if (replay) + { + [replayState modify:^id(__unused MTPipeReplayState *state) + { + return [[MTPipeReplayState alloc] initWithReceivedValue:true recentValue:next]; + }]; + } + } copy]; + } + return self; +} + +@end diff --git a/MTSubscriber.h b/MTSubscriber.h new file mode 100644 index 0000000000..3997534632 --- /dev/null +++ b/MTSubscriber.h @@ -0,0 +1,18 @@ +#import + +#import "MTDisposable.h" + +@interface MTSubscriber : NSObject +{ +} + +- (instancetype)initWithNext:(void (^)(id))next error:(void (^)(id))error completed:(void (^)())completed; + +- (void)_assignDisposable:(id)disposable; +- (void)_markTerminatedWithoutDisposal; + +- (void)putNext:(id)next; +- (void)putError:(id)error; +- (void)putCompletion; + +@end diff --git a/MTSubscriber.m b/MTSubscriber.m new file mode 100644 index 0000000000..9091b99ff3 --- /dev/null +++ b/MTSubscriber.m @@ -0,0 +1,144 @@ +#import "MTSubscriber.h" + +#import + +@interface MTSubscriberBlocks : NSObject { +@public + void (^_next)(id); + void (^_error)(id); + void (^_completed)(); +} + +@end + +@implementation MTSubscriberBlocks + +- (instancetype)initWithNext:(void (^)(id))next error:(void (^)(id))error completed:(void (^)())completed { + self = [super init]; + if (self != nil) { + _next = [next copy]; + _error = [error copy]; + _completed = [completed copy]; + } + return self; +} + +@end + +@interface MTSubscriber () +{ +@protected + OSSpinLock _lock; + bool _terminated; + id _disposable; + MTSubscriberBlocks *_blocks; +} + +@end + +@implementation MTSubscriber + +- (instancetype)initWithNext:(void (^)(id))next error:(void (^)(id))error completed:(void (^)())completed +{ + self = [super init]; + if (self != nil) + { + _blocks = [[MTSubscriberBlocks alloc] initWithNext:next error:error completed:completed]; + } + return self; +} + +- (void)_assignDisposable:(id)disposable +{ + if (_terminated) + [disposable dispose]; + else + _disposable = disposable; +} + +- (void)_markTerminatedWithoutDisposal +{ + OSSpinLockLock(&_lock); + MTSubscriberBlocks *blocks = nil; + if (!_terminated) + { + blocks = _blocks; + _blocks = nil; + + _terminated = true; + } + OSSpinLockUnlock(&_lock); + + if (blocks) { + blocks = nil; + } +} + +- (void)putNext:(id)next +{ + MTSubscriberBlocks *blocks = nil; + + OSSpinLockLock(&_lock); + if (!_terminated) { + blocks = _blocks; + } + OSSpinLockUnlock(&_lock); + + if (blocks && blocks->_next) { + blocks->_next(next); + } +} + +- (void)putError:(id)error +{ + bool shouldDispose = false; + MTSubscriberBlocks *blocks = nil; + + OSSpinLockLock(&_lock); + if (!_terminated) + { + blocks = _blocks; + _blocks = nil; + + shouldDispose = true; + _terminated = true; + } + OSSpinLockUnlock(&_lock); + + if (blocks && blocks->_error) { + blocks->_error(error); + } + + if (shouldDispose) + [self->_disposable dispose]; +} + +- (void)putCompletion +{ + bool shouldDispose = false; + MTSubscriberBlocks *blocks = nil; + + OSSpinLockLock(&_lock); + if (!_terminated) + { + blocks = _blocks; + _blocks = nil; + + shouldDispose = true; + _terminated = true; + } + OSSpinLockUnlock(&_lock); + + if (blocks && blocks->_completed) + blocks->_completed(); + + if (shouldDispose) + [self->_disposable dispose]; +} + +- (void)dispose +{ + [self->_disposable dispose]; +} + +@end diff --git a/MtProtoKit.xcodeproj/project.pbxproj b/MtProtoKit.xcodeproj/project.pbxproj index 1f2ac2f772..f4b5cff2d8 100644 --- a/MtProtoKit.xcodeproj/project.pbxproj +++ b/MtProtoKit.xcodeproj/project.pbxproj @@ -12,13 +12,73 @@ D00354701C173CB9006610DA /* SSignalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0580ABE1B0F3E7100E8235B /* SSignalKit.framework */; }; D00354721C173CD0006610DA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D00354711C173CD0006610DA /* libz.tbd */; }; D00354741C173CD9006610DA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D00354731C173CD9006610DA /* SystemConfiguration.framework */; }; - D0580ABF1B0F3E7100E8235B /* SSignalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0580ABE1B0F3E7100E8235B /* SSignalKit.framework */; }; + D010DB7D1D70ABEE0012AD96 /* MTRsa.h in Headers */ = {isa = PBXBuildFile; fileRef = D010DB7B1D70ABEE0012AD96 /* MTRsa.h */; }; + D010DB7E1D70ABEE0012AD96 /* MTRsa.m in Sources */ = {isa = PBXBuildFile; fileRef = D010DB7C1D70ABEE0012AD96 /* MTRsa.m */; }; + D010DB811D70B3B90012AD96 /* MTAes.h in Headers */ = {isa = PBXBuildFile; fileRef = D010DB7F1D70B3B90012AD96 /* MTAes.h */; }; + D010DB821D70B3B90012AD96 /* MTAes.m in Sources */ = {isa = PBXBuildFile; fileRef = D010DB801D70B3B90012AD96 /* MTAes.m */; }; + D020FAFA1D994E3100F279AA /* MTHttpRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D020FAF81D994E3100F279AA /* MTHttpRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D020FAFB1D994E3100F279AA /* MTHttpRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D020FAF81D994E3100F279AA /* MTHttpRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D020FAFC1D994E3100F279AA /* MTHttpRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D020FAF81D994E3100F279AA /* MTHttpRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D020FAFD1D994E3100F279AA /* MTHttpRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D020FAF91D994E3100F279AA /* MTHttpRequestOperation.m */; }; + D020FAFE1D994E3100F279AA /* MTHttpRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D020FAF91D994E3100F279AA /* MTHttpRequestOperation.m */; }; + D020FAFF1D994E3100F279AA /* MTHttpRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D020FAF91D994E3100F279AA /* MTHttpRequestOperation.m */; }; D0580AC21B0F3E9C00E8235B /* MTDiscoverConnectionSignals.h in Headers */ = {isa = PBXBuildFile; fileRef = D0580AC01B0F3E9C00E8235B /* MTDiscoverConnectionSignals.h */; }; D0580AC31B0F3E9C00E8235B /* MTDiscoverConnectionSignals.m in Sources */ = {isa = PBXBuildFile; fileRef = D0580AC11B0F3E9C00E8235B /* MTDiscoverConnectionSignals.m */; }; D079AB9C1AF39B8000076F59 /* MtProtoKitMac.h in Headers */ = {isa = PBXBuildFile; fileRef = D079AB9B1AF39B8000076F59 /* MtProtoKitMac.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D079ABB01AF39BA400076F59 /* MTProtoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A31D18B158AE00C65116 /* MTProtoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; D09A59581B582EFF00FC3724 /* MTFileBasedKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = D09A59561B582EFF00FC3724 /* MTFileBasedKeychain.h */; settings = {ATTRIBUTES = (Public, ); }; }; D09A59591B582EFF00FC3724 /* MTFileBasedKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = D09A59571B582EFF00FC3724 /* MTFileBasedKeychain.m */; }; + D0B0DF5D1DD7E75B003BA12D /* MTBag.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B0DF5C1DD7E75B003BA12D /* MTBag.m */; }; + D0B0DF5E1DD7E75B003BA12D /* MTBag.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B0DF5C1DD7E75B003BA12D /* MTBag.m */; }; + D0B0DF5F1DD7E75B003BA12D /* MTBag.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B0DF5C1DD7E75B003BA12D /* MTBag.m */; }; + D0B0DF611DD7E7A2003BA12D /* MTBag.h in Headers */ = {isa = PBXBuildFile; fileRef = D0B0DF601DD7E768003BA12D /* MTBag.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0B0DF621DD7E7A3003BA12D /* MTBag.h in Headers */ = {isa = PBXBuildFile; fileRef = D0B0DF601DD7E768003BA12D /* MTBag.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0B0DF631DD7E7A4003BA12D /* MTBag.h in Headers */ = {isa = PBXBuildFile; fileRef = D0B0DF601DD7E768003BA12D /* MTBag.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0B418751D7E04B7004562A4 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0B418741D7E04B7004562A4 /* CFNetwork.framework */; }; + D0B418771D7E04C3004562A4 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0B418761D7E04C3004562A4 /* SystemConfiguration.framework */; }; + D0B418791D7E04CB004562A4 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0B418781D7E04CB004562A4 /* Security.framework */; }; + D0B4187B1D7E04CF004562A4 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D0B4187A1D7E04CF004562A4 /* libz.tbd */; }; + D0B4187D1D7E04EB004562A4 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0B4187C1D7E04EB004562A4 /* libcrypto.a */; }; + D0C932231E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C932211E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0C932241E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C932211E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0C932251E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C932211E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0C932261E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C932221E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m */; }; + D0C932271E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C932221E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m */; }; + D0C932281E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C932221E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m */; }; + D0C9322B1E095E280074F044 /* MTNetworkUsageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C932291E095E280074F044 /* MTNetworkUsageManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0C9322C1E095E280074F044 /* MTNetworkUsageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C932291E095E280074F044 /* MTNetworkUsageManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0C9322D1E095E280074F044 /* MTNetworkUsageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C932291E095E280074F044 /* MTNetworkUsageManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0C9322E1E095E280074F044 /* MTNetworkUsageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C9322A1E095E280074F044 /* MTNetworkUsageManager.m */; }; + D0C9322F1E095E280074F044 /* MTNetworkUsageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C9322A1E095E280074F044 /* MTNetworkUsageManager.m */; }; + D0C932301E095E280074F044 /* MTNetworkUsageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C9322A1E095E280074F044 /* MTNetworkUsageManager.m */; }; + D0CAF2CB1D75E24C0011F558 /* MTSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2C91D75E24C0011F558 /* MTSignal.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2CC1D75E24C0011F558 /* MTSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2CA1D75E24C0011F558 /* MTSignal.m */; }; + D0CAF2CD1D75E2570011F558 /* MTSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2C91D75E24C0011F558 /* MTSignal.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2CE1D75E2580011F558 /* MTSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2C91D75E24C0011F558 /* MTSignal.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2CF1D75E25B0011F558 /* MTSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2CA1D75E24C0011F558 /* MTSignal.m */; }; + D0CAF2D01D75E25B0011F558 /* MTSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2CA1D75E24C0011F558 /* MTSignal.m */; }; + D0CAF2D31D75E26D0011F558 /* MTSubscriber.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2D11D75E26D0011F558 /* MTSubscriber.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2D41D75E26D0011F558 /* MTSubscriber.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2D21D75E26D0011F558 /* MTSubscriber.m */; }; + D0CAF2D71D75E2840011F558 /* MTDisposable.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2D51D75E2840011F558 /* MTDisposable.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2D81D75E2840011F558 /* MTDisposable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2D61D75E2840011F558 /* MTDisposable.m */; }; + D0CAF2D91D75E3160011F558 /* MTSubscriber.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2D11D75E26D0011F558 /* MTSubscriber.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2DA1D75E3160011F558 /* MTSubscriber.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2D11D75E26D0011F558 /* MTSubscriber.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2DB1D75E31A0011F558 /* MTDisposable.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2D51D75E2840011F558 /* MTDisposable.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2DC1D75E31B0011F558 /* MTDisposable.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2D51D75E2840011F558 /* MTDisposable.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2DD1D75E31E0011F558 /* MTDisposable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2D61D75E2840011F558 /* MTDisposable.m */; }; + D0CAF2DE1D75E31E0011F558 /* MTSubscriber.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2D21D75E26D0011F558 /* MTSubscriber.m */; }; + D0CAF2DF1D75E31F0011F558 /* MTDisposable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2D61D75E2840011F558 /* MTDisposable.m */; }; + D0CAF2E01D75E31F0011F558 /* MTSubscriber.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2D21D75E26D0011F558 /* MTSubscriber.m */; }; + D0CAF2E31D75E7F30011F558 /* MTAtomic.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2E11D75E7F30011F558 /* MTAtomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2E41D75E7F30011F558 /* MTAtomic.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2E21D75E7F30011F558 /* MTAtomic.m */; }; + D0CAF2E51D75EA790011F558 /* MTAtomic.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2E11D75E7F30011F558 /* MTAtomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2E61D75EA7A0011F558 /* MTAtomic.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CAF2E11D75E7F30011F558 /* MTAtomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CAF2E71D75EA7E0011F558 /* MTAtomic.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2E21D75E7F30011F558 /* MTAtomic.m */; }; + D0CAF2E81D75EA7E0011F558 /* MTAtomic.m in Sources */ = {isa = PBXBuildFile; fileRef = D0CAF2E21D75E7F30011F558 /* MTAtomic.m */; }; + D0CAF2EC1D75F4520011F558 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CAF2EB1D75F4520011F558 /* Security.framework */; }; + D0CAF2ED1D75F4570011F558 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D00354731C173CD9006610DA /* SystemConfiguration.framework */; }; + D0CAF2EF1D75F4E20011F558 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CAF2EE1D75F4E20011F558 /* UIKit.framework */; }; + D0CAF2F11D75F4EA0011F558 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CAF2F01D75F4EA0011F558 /* CFNetwork.framework */; }; + D0CAF2FD1D7628FD0011F558 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CD990F1D75C16100F41187 /* libcrypto.a */; }; D0CB05FC1ADC4483005E298F /* MtProtoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CB05FB1ADC4483005E298F /* MtProtoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0CB06101ADC44B7005E298F /* MTTime.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DBD23418B2DA1E00631ADC /* MTTime.m */; }; D0CB06111ADC44B7005E298F /* MTTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84D818AFE81C007F1076 /* MTTimer.m */; }; @@ -42,7 +102,7 @@ D0CB06231ADC4558005E298F /* MTContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A839E18AFB75B007F1076 /* MTContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0CB06241ADC455C005E298F /* MTContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A839C18AFB75B007F1076 /* MTContext.m */; }; D0CB06251ADC4562005E298F /* MTTransportScheme.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33418B161B600C65116 /* MTTransportScheme.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D0CB06281ADC456A005E298F /* MTDiscoverDatacenterAddressAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D518AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CB06281ADC456A005E298F /* MTDiscoverDatacenterAddressAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D518AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.h */; }; D0CB06291ADC456E005E298F /* MTDiscoverDatacenterAddressAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83D418AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.m */; }; D0CB062A1ADC4575005E298F /* MTDatacenterTransferAuthAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A839F18AFB75B007F1076 /* MTDatacenterTransferAuthAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0CB062B1ADC4575005E298F /* MTDatacenterAuthAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83A018AFB75B007F1076 /* MTDatacenterAuthAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -94,11 +154,11 @@ D0CB06591ADC45CE005E298F /* MTTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38518B164F800C65116 /* MTTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0CB065A1ADC45CE005E298F /* MTTransportTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38718B164F800C65116 /* MTTransportTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0CB065B1ADC45CE005E298F /* MTTcpTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39918B1650400C65116 /* MTTcpTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D0CB065C1ADC45CE005E298F /* MTTcpConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39518B1650400C65116 /* MTTcpConnection.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D0CB065D1ADC45CE005E298F /* MTTcpConnectionBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39718B1650400C65116 /* MTTcpConnectionBehaviour.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CB065C1ADC45CE005E298F /* MTTcpConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39518B1650400C65116 /* MTTcpConnection.h */; }; + D0CB065D1ADC45CE005E298F /* MTTcpConnectionBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39718B1650400C65116 /* MTTcpConnectionBehaviour.h */; }; D0CB065E1ADC45CE005E298F /* MTHttpTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A718B1650F00C65116 /* MTHttpTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D0CB065F1ADC45CE005E298F /* MTHttpWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A918B1650F00C65116 /* MTHttpWorker.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D0CB06601ADC45CE005E298F /* MTHttpWorkerBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3AB18B1650F00C65116 /* MTHttpWorkerBehaviour.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CB065F1ADC45CE005E298F /* MTHttpWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A918B1650F00C65116 /* MTHttpWorker.h */; }; + D0CB06601ADC45CE005E298F /* MTHttpWorkerBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3AB18B1650F00C65116 /* MTHttpWorkerBehaviour.h */; }; D0CB06611ADC45DA005E298F /* MTNetworkAvailability.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38418B164F800C65116 /* MTNetworkAvailability.m */; }; D0CB06621ADC45DA005E298F /* MTTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38618B164F800C65116 /* MTTransport.m */; }; D0CB06631ADC45DA005E298F /* MTTransportTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38818B164F800C65116 /* MTTransportTransaction.m */; }; @@ -109,13 +169,321 @@ D0CB06681ADC45DA005E298F /* MTHttpWorker.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3AA18B1650F00C65116 /* MTHttpWorker.m */; }; D0CB06691ADC45DA005E298F /* MTHttpWorkerBehaviour.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3AC18B1650F00C65116 /* MTHttpWorkerBehaviour.m */; }; D0CB066A1ADC4846005E298F /* MTResendMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A37D18B164E600C65116 /* MTResendMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D0CB066B1ADC48C4005E298F /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D063A2F718B14A9400C65116 /* libcrypto.a */; }; D0CB066C1ADC49FA005E298F /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84F818AFF259007F1076 /* GCDAsyncSocket.m */; }; D0CB066D1ADC49FF005E298F /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A851818AFF2F8007F1076 /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; D0CB066E1ADC49FF005E298F /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84EA18AFF259007F1076 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; D0CB066F1ADC49FF005E298F /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84EC18AFF259007F1076 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; D0CB06701ADC49FF005E298F /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84F518AFF259007F1076 /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; D0CB06711ADC4A50005E298F /* MTTransportScheme.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33518B161B600C65116 /* MTTransportScheme.m */; }; + D0CD97D21D74B91400F41187 /* MTTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 93DBD23318B2D9AA00631ADC /* MTTime.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97D31D74B91700F41187 /* MTTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 93DBD23318B2D9AA00631ADC /* MTTime.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97D41D74B91B00F41187 /* MTTime.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DBD23418B2DA1E00631ADC /* MTTime.m */; }; + D0CD97D51D74B91C00F41187 /* MTTime.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DBD23418B2DA1E00631ADC /* MTTime.m */; }; + D0CD97D61D74B91E00F41187 /* MTTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A84D918AFE81D007F1076 /* MTTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97D71D74B92000F41187 /* MTTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A84D918AFE81D007F1076 /* MTTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97D81D74B93100F41187 /* MTTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84D818AFE81C007F1076 /* MTTimer.m */; }; + D0CD97D91D74B93100F41187 /* MTLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84DB18AFE81D007F1076 /* MTLogging.m */; }; + D0CD97DA1D74B93100F41187 /* MTEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84DC18AFE81D007F1076 /* MTEncryption.m */; }; + D0CD97DB1D74B93100F41187 /* MTQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84A018AFCF8E007F1076 /* MTQueue.m */; }; + D0CD97DC1D74B93100F41187 /* MTOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D0503AD918B027F80074C3FE /* MTOutputStream.m */; }; + D0CD97DD1D74B93100F41187 /* MTInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D0503ADD18B029480074C3FE /* MTInputStream.m */; }; + D0CD97DE1D74B93100F41187 /* MTRsa.m in Sources */ = {isa = PBXBuildFile; fileRef = D010DB7C1D70ABEE0012AD96 /* MTRsa.m */; }; + D0CD97DF1D74B93100F41187 /* MTAes.m in Sources */ = {isa = PBXBuildFile; fileRef = D010DB801D70B3B90012AD96 /* MTAes.m */; }; + D0CD97E01D74B93300F41187 /* MTTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84D818AFE81C007F1076 /* MTTimer.m */; }; + D0CD97E11D74B93300F41187 /* MTLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84DB18AFE81D007F1076 /* MTLogging.m */; }; + D0CD97E21D74B93300F41187 /* MTEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84DC18AFE81D007F1076 /* MTEncryption.m */; }; + D0CD97E31D74B93300F41187 /* MTQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84A018AFCF8E007F1076 /* MTQueue.m */; }; + D0CD97E41D74B93300F41187 /* MTOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D0503AD918B027F80074C3FE /* MTOutputStream.m */; }; + D0CD97E51D74B93300F41187 /* MTInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D0503ADD18B029480074C3FE /* MTInputStream.m */; }; + D0CD97E61D74B93300F41187 /* MTRsa.m in Sources */ = {isa = PBXBuildFile; fileRef = D010DB7C1D70ABEE0012AD96 /* MTRsa.m */; }; + D0CD97E71D74B93300F41187 /* MTAes.m in Sources */ = {isa = PBXBuildFile; fileRef = D010DB801D70B3B90012AD96 /* MTAes.m */; }; + D0CD97E81D74B94300F41187 /* MTLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A84DA18AFE81D007F1076 /* MTLogging.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97E91D74B94300F41187 /* MTEncryption.h in Headers */ = {isa = PBXBuildFile; fileRef = D0254CC518B10404009452AA /* MTEncryption.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97EA1D74B94300F41187 /* MTInternalId.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D118AFB75B007F1076 /* MTInternalId.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97EB1D74B94300F41187 /* MTQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A849F18AFCF8E007F1076 /* MTQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97EC1D74B94300F41187 /* MTOutputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = D0503AD818B027F80074C3FE /* MTOutputStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97ED1D74B94300F41187 /* MTInputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = D0503ADC18B029480074C3FE /* MTInputStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97EE1D74B94300F41187 /* MTLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A84DA18AFE81D007F1076 /* MTLogging.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97EF1D74B94300F41187 /* MTEncryption.h in Headers */ = {isa = PBXBuildFile; fileRef = D0254CC518B10404009452AA /* MTEncryption.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97F01D74B94300F41187 /* MTInternalId.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D118AFB75B007F1076 /* MTInternalId.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97F11D74B94300F41187 /* MTQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A849F18AFCF8E007F1076 /* MTQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97F21D74B94300F41187 /* MTOutputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = D0503AD818B027F80074C3FE /* MTOutputStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97F31D74B94300F41187 /* MTInputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = D0503ADC18B029480074C3FE /* MTInputStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97F61D74B94B00F41187 /* MTRsa.h in Headers */ = {isa = PBXBuildFile; fileRef = D010DB7B1D70ABEE0012AD96 /* MTRsa.h */; }; + D0CD97F71D74B94B00F41187 /* MTAes.h in Headers */ = {isa = PBXBuildFile; fileRef = D010DB7F1D70B3B90012AD96 /* MTAes.h */; }; + D0CD97F81D74B94B00F41187 /* MTRsa.h in Headers */ = {isa = PBXBuildFile; fileRef = D010DB7B1D70ABEE0012AD96 /* MTRsa.h */; }; + D0CD97F91D74B94B00F41187 /* MTAes.h in Headers */ = {isa = PBXBuildFile; fileRef = D010DB7F1D70B3B90012AD96 /* MTAes.h */; }; + D0CD97FA1D74B95000F41187 /* MTSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83B518AFB75B007F1076 /* MTSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97FB1D74B95100F41187 /* MTSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83B518AFB75B007F1076 /* MTSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD97FC1D74B96300F41187 /* MTBadMsgNotificationMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0041ADD983C007D9ED6 /* MTBadMsgNotificationMessage.h */; }; + D0CD97FD1D74B96300F41187 /* MTBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0061ADD983C007D9ED6 /* MTBuffer.h */; }; + D0CD97FE1D74B96300F41187 /* MTBufferReader.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0081ADD983C007D9ED6 /* MTBufferReader.h */; }; + D0CD97FF1D74B96300F41187 /* MTDestroySessionResponseMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A00A1ADD983C007D9ED6 /* MTDestroySessionResponseMessage.h */; }; + D0CD98001D74B96300F41187 /* MTDropRpcResultMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A00C1ADD983C007D9ED6 /* MTDropRpcResultMessage.h */; }; + D0CD98011D74B96400F41187 /* MTBadMsgNotificationMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0041ADD983C007D9ED6 /* MTBadMsgNotificationMessage.h */; }; + D0CD98021D74B96400F41187 /* MTBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0061ADD983C007D9ED6 /* MTBuffer.h */; }; + D0CD98031D74B96400F41187 /* MTBufferReader.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0081ADD983C007D9ED6 /* MTBufferReader.h */; }; + D0CD98041D74B96400F41187 /* MTDestroySessionResponseMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A00A1ADD983C007D9ED6 /* MTDestroySessionResponseMessage.h */; }; + D0CD98051D74B96400F41187 /* MTDropRpcResultMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A00C1ADD983C007D9ED6 /* MTDropRpcResultMessage.h */; }; + D0CD98061D74B96C00F41187 /* MTBadMsgNotificationMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0051ADD983C007D9ED6 /* MTBadMsgNotificationMessage.m */; }; + D0CD98071D74B96C00F41187 /* MTBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0071ADD983C007D9ED6 /* MTBuffer.m */; }; + D0CD98081D74B96C00F41187 /* MTBufferReader.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0091ADD983C007D9ED6 /* MTBufferReader.m */; }; + D0CD98091D74B96C00F41187 /* MTDestroySessionResponseMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A00B1ADD983C007D9ED6 /* MTDestroySessionResponseMessage.m */; }; + D0CD980A1D74B96C00F41187 /* MTDropRpcResultMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A00D1ADD983C007D9ED6 /* MTDropRpcResultMessage.m */; }; + D0CD980B1D74B96C00F41187 /* MTBadMsgNotificationMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0051ADD983C007D9ED6 /* MTBadMsgNotificationMessage.m */; }; + D0CD980C1D74B96C00F41187 /* MTBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0071ADD983C007D9ED6 /* MTBuffer.m */; }; + D0CD980D1D74B96C00F41187 /* MTBufferReader.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0091ADD983C007D9ED6 /* MTBufferReader.m */; }; + D0CD980E1D74B96C00F41187 /* MTDestroySessionResponseMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A00B1ADD983C007D9ED6 /* MTDestroySessionResponseMessage.m */; }; + D0CD980F1D74B96C00F41187 /* MTDropRpcResultMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A00D1ADD983C007D9ED6 /* MTDropRpcResultMessage.m */; }; + D0CD98101D74B96F00F41187 /* MTExportedAuthorizationData.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A00E1ADD983C007D9ED6 /* MTExportedAuthorizationData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98111D74B97000F41187 /* MTExportedAuthorizationData.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A00E1ADD983C007D9ED6 /* MTExportedAuthorizationData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98121D74B99400F41187 /* MTFutureSaltsMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0101ADD983C007D9ED6 /* MTFutureSaltsMessage.h */; }; + D0CD98131D74B99400F41187 /* MTInternalMessageParser.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0121ADD983C007D9ED6 /* MTInternalMessageParser.h */; }; + D0CD98141D74B99400F41187 /* MTMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0141ADD983C007D9ED6 /* MTMessage.h */; }; + D0CD98151D74B99400F41187 /* MTMsgAllInfoMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0161ADD983C007D9ED6 /* MTMsgAllInfoMessage.h */; }; + D0CD98161D74B99400F41187 /* MTMsgContainerMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0181ADD983C007D9ED6 /* MTMsgContainerMessage.h */; }; + D0CD98171D74B99400F41187 /* MTMsgDetailedInfoMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A01A1ADD983C007D9ED6 /* MTMsgDetailedInfoMessage.h */; }; + D0CD98181D74B99400F41187 /* MTMsgResendReqMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A01C1ADD983C007D9ED6 /* MTMsgResendReqMessage.h */; }; + D0CD98191D74B99400F41187 /* MTMsgsAckMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A01E1ADD983C007D9ED6 /* MTMsgsAckMessage.h */; }; + D0CD981A1D74B99400F41187 /* MTMsgsStateInfoMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0201ADD983C007D9ED6 /* MTMsgsStateInfoMessage.h */; }; + D0CD981B1D74B99400F41187 /* MTMsgsStateReqMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0221ADD983C007D9ED6 /* MTMsgsStateReqMessage.h */; }; + D0CD981C1D74B99400F41187 /* MTNewSessionCreatedMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0241ADD983C007D9ED6 /* MTNewSessionCreatedMessage.h */; }; + D0CD981D1D74B99400F41187 /* MTPingMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0261ADD983C007D9ED6 /* MTPingMessage.h */; }; + D0CD981E1D74B99400F41187 /* MTPongMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0281ADD983C007D9ED6 /* MTPongMessage.h */; }; + D0CD981F1D74B99400F41187 /* MTResPqMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A02A1ADD983C007D9ED6 /* MTResPqMessage.h */; }; + D0CD98201D74B99500F41187 /* MTFutureSaltsMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0101ADD983C007D9ED6 /* MTFutureSaltsMessage.h */; }; + D0CD98211D74B99500F41187 /* MTInternalMessageParser.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0121ADD983C007D9ED6 /* MTInternalMessageParser.h */; }; + D0CD98221D74B99500F41187 /* MTMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0141ADD983C007D9ED6 /* MTMessage.h */; }; + D0CD98231D74B99500F41187 /* MTMsgAllInfoMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0161ADD983C007D9ED6 /* MTMsgAllInfoMessage.h */; }; + D0CD98241D74B99500F41187 /* MTMsgContainerMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0181ADD983C007D9ED6 /* MTMsgContainerMessage.h */; }; + D0CD98251D74B99500F41187 /* MTMsgDetailedInfoMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A01A1ADD983C007D9ED6 /* MTMsgDetailedInfoMessage.h */; }; + D0CD98261D74B99500F41187 /* MTMsgResendReqMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A01C1ADD983C007D9ED6 /* MTMsgResendReqMessage.h */; }; + D0CD98271D74B99500F41187 /* MTMsgsAckMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A01E1ADD983C007D9ED6 /* MTMsgsAckMessage.h */; }; + D0CD98281D74B99500F41187 /* MTMsgsStateInfoMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0201ADD983C007D9ED6 /* MTMsgsStateInfoMessage.h */; }; + D0CD98291D74B99500F41187 /* MTMsgsStateReqMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0221ADD983C007D9ED6 /* MTMsgsStateReqMessage.h */; }; + D0CD982A1D74B99500F41187 /* MTNewSessionCreatedMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0241ADD983C007D9ED6 /* MTNewSessionCreatedMessage.h */; }; + D0CD982B1D74B99500F41187 /* MTPingMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0261ADD983C007D9ED6 /* MTPingMessage.h */; }; + D0CD982C1D74B99500F41187 /* MTPongMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0281ADD983C007D9ED6 /* MTPongMessage.h */; }; + D0CD982D1D74B99500F41187 /* MTResPqMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A02A1ADD983C007D9ED6 /* MTResPqMessage.h */; }; + D0CD982E1D74B9AA00F41187 /* MTExportedAuthorizationData.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A00F1ADD983C007D9ED6 /* MTExportedAuthorizationData.m */; }; + D0CD982F1D74B9AA00F41187 /* MTFutureSaltsMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0111ADD983C007D9ED6 /* MTFutureSaltsMessage.m */; }; + D0CD98301D74B9AA00F41187 /* MTInternalMessageParser.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0131ADD983C007D9ED6 /* MTInternalMessageParser.m */; }; + D0CD98311D74B9AA00F41187 /* MTMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0151ADD983C007D9ED6 /* MTMessage.m */; }; + D0CD98321D74B9AA00F41187 /* MTMsgAllInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0171ADD983C007D9ED6 /* MTMsgAllInfoMessage.m */; }; + D0CD98331D74B9AA00F41187 /* MTMsgContainerMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0191ADD983C007D9ED6 /* MTMsgContainerMessage.m */; }; + D0CD98341D74B9AA00F41187 /* MTMsgDetailedInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A01B1ADD983C007D9ED6 /* MTMsgDetailedInfoMessage.m */; }; + D0CD98351D74B9AA00F41187 /* MTMsgResendReqMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A01D1ADD983C007D9ED6 /* MTMsgResendReqMessage.m */; }; + D0CD98361D74B9AA00F41187 /* MTMsgsAckMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A01F1ADD983C007D9ED6 /* MTMsgsAckMessage.m */; }; + D0CD98371D74B9AA00F41187 /* MTMsgsStateInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0211ADD983C007D9ED6 /* MTMsgsStateInfoMessage.m */; }; + D0CD98381D74B9AA00F41187 /* MTMsgsStateReqMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0231ADD983C007D9ED6 /* MTMsgsStateReqMessage.m */; }; + D0CD98391D74B9AA00F41187 /* MTNewSessionCreatedMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0251ADD983C007D9ED6 /* MTNewSessionCreatedMessage.m */; }; + D0CD983A1D74B9AA00F41187 /* MTPingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0271ADD983C007D9ED6 /* MTPingMessage.m */; }; + D0CD983B1D74B9AA00F41187 /* MTPongMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0291ADD983C007D9ED6 /* MTPongMessage.m */; }; + D0CD983C1D74B9AA00F41187 /* MTResPqMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A02B1ADD983C007D9ED6 /* MTResPqMessage.m */; }; + D0CD983D1D74B9AA00F41187 /* MTExportedAuthorizationData.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A00F1ADD983C007D9ED6 /* MTExportedAuthorizationData.m */; }; + D0CD983E1D74B9AA00F41187 /* MTFutureSaltsMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0111ADD983C007D9ED6 /* MTFutureSaltsMessage.m */; }; + D0CD983F1D74B9AA00F41187 /* MTInternalMessageParser.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0131ADD983C007D9ED6 /* MTInternalMessageParser.m */; }; + D0CD98401D74B9AA00F41187 /* MTMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0151ADD983C007D9ED6 /* MTMessage.m */; }; + D0CD98411D74B9AA00F41187 /* MTMsgAllInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0171ADD983C007D9ED6 /* MTMsgAllInfoMessage.m */; }; + D0CD98421D74B9AA00F41187 /* MTMsgContainerMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0191ADD983C007D9ED6 /* MTMsgContainerMessage.m */; }; + D0CD98431D74B9AA00F41187 /* MTMsgDetailedInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A01B1ADD983C007D9ED6 /* MTMsgDetailedInfoMessage.m */; }; + D0CD98441D74B9AA00F41187 /* MTMsgResendReqMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A01D1ADD983C007D9ED6 /* MTMsgResendReqMessage.m */; }; + D0CD98451D74B9AA00F41187 /* MTMsgsAckMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A01F1ADD983C007D9ED6 /* MTMsgsAckMessage.m */; }; + D0CD98461D74B9AA00F41187 /* MTMsgsStateInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0211ADD983C007D9ED6 /* MTMsgsStateInfoMessage.m */; }; + D0CD98471D74B9AA00F41187 /* MTMsgsStateReqMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0231ADD983C007D9ED6 /* MTMsgsStateReqMessage.m */; }; + D0CD98481D74B9AA00F41187 /* MTNewSessionCreatedMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0251ADD983C007D9ED6 /* MTNewSessionCreatedMessage.m */; }; + D0CD98491D74B9AA00F41187 /* MTPingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0271ADD983C007D9ED6 /* MTPingMessage.m */; }; + D0CD984A1D74B9AA00F41187 /* MTPongMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0291ADD983C007D9ED6 /* MTPongMessage.m */; }; + D0CD984B1D74B9AA00F41187 /* MTResPqMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A02B1ADD983C007D9ED6 /* MTResPqMessage.m */; }; + D0CD984C1D74B9AD00F41187 /* MTRpcError.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A02C1ADD983C007D9ED6 /* MTRpcError.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD984D1D74B9AE00F41187 /* MTRpcError.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A02C1ADD983C007D9ED6 /* MTRpcError.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD984E1D74B9B700F41187 /* MTRpcError.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A02D1ADD983C007D9ED6 /* MTRpcError.m */; }; + D0CD984F1D74B9B700F41187 /* MTRpcResultMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A02F1ADD983C007D9ED6 /* MTRpcResultMessage.m */; }; + D0CD98501D74B9B700F41187 /* MTServerDhInnerDataMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0311ADD983C007D9ED6 /* MTServerDhInnerDataMessage.m */; }; + D0CD98511D74B9B700F41187 /* MTServerDhParamsMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0331ADD983C007D9ED6 /* MTServerDhParamsMessage.m */; }; + D0CD98521D74B9B700F41187 /* MTSetClientDhParamsResponseMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0351ADD983C007D9ED6 /* MTSetClientDhParamsResponseMessage.m */; }; + D0CD98531D74B9B700F41187 /* MTRpcError.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A02D1ADD983C007D9ED6 /* MTRpcError.m */; }; + D0CD98541D74B9B700F41187 /* MTRpcResultMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A02F1ADD983C007D9ED6 /* MTRpcResultMessage.m */; }; + D0CD98551D74B9B700F41187 /* MTServerDhInnerDataMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0311ADD983C007D9ED6 /* MTServerDhInnerDataMessage.m */; }; + D0CD98561D74B9B700F41187 /* MTServerDhParamsMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0331ADD983C007D9ED6 /* MTServerDhParamsMessage.m */; }; + D0CD98571D74B9B700F41187 /* MTSetClientDhParamsResponseMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0351ADD983C007D9ED6 /* MTSetClientDhParamsResponseMessage.m */; }; + D0CD98581D74B9BF00F41187 /* MTRpcResultMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A02E1ADD983C007D9ED6 /* MTRpcResultMessage.h */; }; + D0CD98591D74B9BF00F41187 /* MTServerDhInnerDataMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0301ADD983C007D9ED6 /* MTServerDhInnerDataMessage.h */; }; + D0CD985A1D74B9BF00F41187 /* MTServerDhParamsMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0321ADD983C007D9ED6 /* MTServerDhParamsMessage.h */; }; + D0CD985B1D74B9BF00F41187 /* MTSetClientDhParamsResponseMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0341ADD983C007D9ED6 /* MTSetClientDhParamsResponseMessage.h */; }; + D0CD985C1D74B9BF00F41187 /* MTRpcResultMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A02E1ADD983C007D9ED6 /* MTRpcResultMessage.h */; }; + D0CD985D1D74B9BF00F41187 /* MTServerDhInnerDataMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0301ADD983C007D9ED6 /* MTServerDhInnerDataMessage.h */; }; + D0CD985E1D74B9BF00F41187 /* MTServerDhParamsMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0321ADD983C007D9ED6 /* MTServerDhParamsMessage.h */; }; + D0CD985F1D74B9BF00F41187 /* MTSetClientDhParamsResponseMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0341ADD983C007D9ED6 /* MTSetClientDhParamsResponseMessage.h */; }; + D0CD98601D74B9D000F41187 /* MTKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83C018AFB75B007F1076 /* MTKeychain.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98611D74B9D000F41187 /* MTKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83C018AFB75B007F1076 /* MTKeychain.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98621D74B9D500F41187 /* MTKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83A318AFB75B007F1076 /* MTKeychain.m */; }; + D0CD98631D74B9D500F41187 /* MTKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83A318AFB75B007F1076 /* MTKeychain.m */; }; + D0CD98641D74B9D700F41187 /* MTFileBasedKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = D09A59561B582EFF00FC3724 /* MTFileBasedKeychain.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98651D74B9D800F41187 /* MTFileBasedKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = D09A59561B582EFF00FC3724 /* MTFileBasedKeychain.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98661D74B9DD00F41187 /* MTFileBasedKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = D09A59571B582EFF00FC3724 /* MTFileBasedKeychain.m */; }; + D0CD98671D74B9DD00F41187 /* MTFileBasedKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = D09A59571B582EFF00FC3724 /* MTFileBasedKeychain.m */; }; + D0CD98681D74B9E200F41187 /* MTContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A839E18AFB75B007F1076 /* MTContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98691D74B9E300F41187 /* MTContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A839E18AFB75B007F1076 /* MTContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD986A1D74B9E900F41187 /* MTContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A839C18AFB75B007F1076 /* MTContext.m */; }; + D0CD986B1D74B9E900F41187 /* MTContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A839C18AFB75B007F1076 /* MTContext.m */; }; + D0CD986C1D74B9EF00F41187 /* MTTransportScheme.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33418B161B600C65116 /* MTTransportScheme.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD986D1D74B9F000F41187 /* MTTransportScheme.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33418B161B600C65116 /* MTTransportScheme.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD986E1D74B9F400F41187 /* MTTransportScheme.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33518B161B600C65116 /* MTTransportScheme.m */; }; + D0CD986F1D74B9F500F41187 /* MTTransportScheme.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33518B161B600C65116 /* MTTransportScheme.m */; }; + D0CD98701D74B9F700F41187 /* MTDiscoverConnectionSignals.h in Headers */ = {isa = PBXBuildFile; fileRef = D0580AC01B0F3E9C00E8235B /* MTDiscoverConnectionSignals.h */; }; + D0CD98711D74B9F700F41187 /* MTDiscoverConnectionSignals.h in Headers */ = {isa = PBXBuildFile; fileRef = D0580AC01B0F3E9C00E8235B /* MTDiscoverConnectionSignals.h */; }; + D0CD98721D74B9F900F41187 /* MTDiscoverConnectionSignals.m in Sources */ = {isa = PBXBuildFile; fileRef = D0580AC11B0F3E9C00E8235B /* MTDiscoverConnectionSignals.m */; }; + D0CD98731D74B9F900F41187 /* MTDiscoverConnectionSignals.m in Sources */ = {isa = PBXBuildFile; fileRef = D0580AC11B0F3E9C00E8235B /* MTDiscoverConnectionSignals.m */; }; + D0CD98741D74BA0100F41187 /* MTDiscoverDatacenterAddressAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D518AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.h */; }; + D0CD98751D74BA0100F41187 /* MTDiscoverDatacenterAddressAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D518AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.h */; }; + D0CD98761D74BA0700F41187 /* MTDiscoverDatacenterAddressAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83D418AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.m */; }; + D0CD98771D74BA0700F41187 /* MTDiscoverDatacenterAddressAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83D418AFB75B007F1076 /* MTDiscoverDatacenterAddressAction.m */; }; + D0CD98781D74BA4100F41187 /* MTDatacenterTransferAuthAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A839F18AFB75B007F1076 /* MTDatacenterTransferAuthAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98791D74BA4100F41187 /* MTDatacenterAuthAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83A018AFB75B007F1076 /* MTDatacenterAuthAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD987A1D74BA4100F41187 /* MTDatacenterAuthMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D918AFB75B007F1076 /* MTDatacenterAuthMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD987B1D74BA4100F41187 /* MTDatacenterTransferAuthAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A839F18AFB75B007F1076 /* MTDatacenterTransferAuthAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD987C1D74BA4100F41187 /* MTDatacenterAuthAction.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83A018AFB75B007F1076 /* MTDatacenterAuthAction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD987D1D74BA4100F41187 /* MTDatacenterAuthMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83D918AFB75B007F1076 /* MTDatacenterAuthMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD987E1D74BA4900F41187 /* MTDatacenterTransferAuthAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A839D18AFB75B007F1076 /* MTDatacenterTransferAuthAction.m */; }; + D0CD987F1D74BA4900F41187 /* MTDatacenterAuthAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83CE18AFB75B007F1076 /* MTDatacenterAuthAction.m */; }; + D0CD98801D74BA4900F41187 /* MTDatacenterAuthMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83B018AFB75B007F1076 /* MTDatacenterAuthMessageService.m */; }; + D0CD98811D74BA4900F41187 /* MTDatacenterTransferAuthAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A839D18AFB75B007F1076 /* MTDatacenterTransferAuthAction.m */; }; + D0CD98821D74BA4900F41187 /* MTDatacenterAuthAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83CE18AFB75B007F1076 /* MTDatacenterAuthAction.m */; }; + D0CD98831D74BA4900F41187 /* MTDatacenterAuthMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83B018AFB75B007F1076 /* MTDatacenterAuthMessageService.m */; }; + D0CD98841D74BA5100F41187 /* MTDatacenterAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83CB18AFB75B007F1076 /* MTDatacenterAddress.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98851D74BA5100F41187 /* MTDatacenterAddressSet.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83CD18AFB75B007F1076 /* MTDatacenterAddressSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98861D74BA5100F41187 /* MTDatacenterAuthInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83C918AFB75B007F1076 /* MTDatacenterAuthInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98871D74BA5100F41187 /* MTDatacenterSaltInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83C718AFB75B007F1076 /* MTDatacenterSaltInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98881D74BA5100F41187 /* MTDatacenterAddressListData.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0691ADD987A007D9ED6 /* MTDatacenterAddressListData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98891D74BA5200F41187 /* MTDatacenterAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83CB18AFB75B007F1076 /* MTDatacenterAddress.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD988A1D74BA5200F41187 /* MTDatacenterAddressSet.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83CD18AFB75B007F1076 /* MTDatacenterAddressSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD988B1D74BA5200F41187 /* MTDatacenterAuthInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83C918AFB75B007F1076 /* MTDatacenterAuthInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD988C1D74BA5200F41187 /* MTDatacenterSaltInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D05A83C718AFB75B007F1076 /* MTDatacenterSaltInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD988D1D74BA5200F41187 /* MTDatacenterAddressListData.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0691ADD987A007D9ED6 /* MTDatacenterAddressListData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD988E1D74BA5900F41187 /* MTDatacenterAddress.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83CA18AFB75B007F1076 /* MTDatacenterAddress.m */; }; + D0CD988F1D74BA5900F41187 /* MTDatacenterAddressSet.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83CC18AFB75B007F1076 /* MTDatacenterAddressSet.m */; }; + D0CD98901D74BA5900F41187 /* MTDatacenterAuthInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83C818AFB75B007F1076 /* MTDatacenterAuthInfo.m */; }; + D0CD98911D74BA5900F41187 /* MTDatacenterSaltInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83C618AFB75B007F1076 /* MTDatacenterSaltInfo.m */; }; + D0CD98921D74BA5900F41187 /* MTDatacenterAddressListData.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A06A1ADD987A007D9ED6 /* MTDatacenterAddressListData.m */; }; + D0CD98931D74BA5A00F41187 /* MTDatacenterAddress.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83CA18AFB75B007F1076 /* MTDatacenterAddress.m */; }; + D0CD98941D74BA5A00F41187 /* MTDatacenterAddressSet.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83CC18AFB75B007F1076 /* MTDatacenterAddressSet.m */; }; + D0CD98951D74BA5A00F41187 /* MTDatacenterAuthInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83C818AFB75B007F1076 /* MTDatacenterAuthInfo.m */; }; + D0CD98961D74BA5A00F41187 /* MTDatacenterSaltInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A83C618AFB75B007F1076 /* MTDatacenterSaltInfo.m */; }; + D0CD98971D74BA5A00F41187 /* MTDatacenterAddressListData.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A06A1ADD987A007D9ED6 /* MTDatacenterAddressListData.m */; }; + D0CD98981D74BA6500F41187 /* MTProto.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32418B1618D00C65116 /* MTProto.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98991D74BA6500F41187 /* MTSessionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32618B1618D00C65116 /* MTSessionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD989A1D74BA6500F41187 /* MTTimeFixContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32818B1618D00C65116 /* MTTimeFixContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD989B1D74BA6500F41187 /* MTPreparedMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32218B1618D00C65116 /* MTPreparedMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD989C1D74BA6500F41187 /* MTOutgoingMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32018B1618D00C65116 /* MTOutgoingMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD989D1D74BA6500F41187 /* MTIncomingMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33618B161B600C65116 /* MTIncomingMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD989E1D74BA6500F41187 /* MTMessageEncryptionKey.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33818B161B600C65116 /* MTMessageEncryptionKey.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD989F1D74BA6500F41187 /* MTProto.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32418B1618D00C65116 /* MTProto.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A01D74BA6500F41187 /* MTSessionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32618B1618D00C65116 /* MTSessionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A11D74BA6500F41187 /* MTTimeFixContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32818B1618D00C65116 /* MTTimeFixContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A21D74BA6500F41187 /* MTPreparedMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32218B1618D00C65116 /* MTPreparedMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A31D74BA6500F41187 /* MTOutgoingMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A32018B1618D00C65116 /* MTOutgoingMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A41D74BA6500F41187 /* MTIncomingMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33618B161B600C65116 /* MTIncomingMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A51D74BA6500F41187 /* MTMessageEncryptionKey.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A33818B161B600C65116 /* MTMessageEncryptionKey.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98A61D74BA6E00F41187 /* MTProto.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32518B1618D00C65116 /* MTProto.m */; }; + D0CD98A71D74BA6E00F41187 /* MTSessionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32718B1618D00C65116 /* MTSessionInfo.m */; }; + D0CD98A81D74BA6E00F41187 /* MTTimeFixContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32918B1618D00C65116 /* MTTimeFixContext.m */; }; + D0CD98A91D74BA6F00F41187 /* MTPreparedMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32318B1618D00C65116 /* MTPreparedMessage.m */; }; + D0CD98AA1D74BA6F00F41187 /* MTOutgoingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32118B1618D00C65116 /* MTOutgoingMessage.m */; }; + D0CD98AB1D74BA6F00F41187 /* MTIncomingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33718B161B600C65116 /* MTIncomingMessage.m */; }; + D0CD98AC1D74BA6F00F41187 /* MTMessageEncryptionKey.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33918B161B600C65116 /* MTMessageEncryptionKey.m */; }; + D0CD98AD1D74BA6F00F41187 /* MTProto.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32518B1618D00C65116 /* MTProto.m */; }; + D0CD98AE1D74BA6F00F41187 /* MTSessionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32718B1618D00C65116 /* MTSessionInfo.m */; }; + D0CD98AF1D74BA6F00F41187 /* MTTimeFixContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32918B1618D00C65116 /* MTTimeFixContext.m */; }; + D0CD98B01D74BA6F00F41187 /* MTPreparedMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32318B1618D00C65116 /* MTPreparedMessage.m */; }; + D0CD98B11D74BA6F00F41187 /* MTOutgoingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A32118B1618D00C65116 /* MTOutgoingMessage.m */; }; + D0CD98B21D74BA6F00F41187 /* MTIncomingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33718B161B600C65116 /* MTIncomingMessage.m */; }; + D0CD98B31D74BA6F00F41187 /* MTMessageEncryptionKey.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A33918B161B600C65116 /* MTMessageEncryptionKey.m */; }; + D0CD98B41D74BA7500F41187 /* MTNetworkAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38318B164F800C65116 /* MTNetworkAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98B51D74BA7500F41187 /* MTTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38518B164F800C65116 /* MTTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98B61D74BA7500F41187 /* MTTransportTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38718B164F800C65116 /* MTTransportTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98B71D74BA7500F41187 /* MTNetworkAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38318B164F800C65116 /* MTNetworkAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98B81D74BA7500F41187 /* MTTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38518B164F800C65116 /* MTTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98B91D74BA7500F41187 /* MTTransportTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A38718B164F800C65116 /* MTTransportTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98BA1D74BA7C00F41187 /* MTNetworkAvailability.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38418B164F800C65116 /* MTNetworkAvailability.m */; }; + D0CD98BB1D74BA7C00F41187 /* MTTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38618B164F800C65116 /* MTTransport.m */; }; + D0CD98BC1D74BA7C00F41187 /* MTTransportTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38818B164F800C65116 /* MTTransportTransaction.m */; }; + D0CD98BD1D74BA7C00F41187 /* MTNetworkAvailability.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38418B164F800C65116 /* MTNetworkAvailability.m */; }; + D0CD98BE1D74BA7C00F41187 /* MTTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38618B164F800C65116 /* MTTransport.m */; }; + D0CD98BF1D74BA7C00F41187 /* MTTransportTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A38818B164F800C65116 /* MTTransportTransaction.m */; }; + D0CD98C01D74BA8200F41187 /* MTTcpTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39918B1650400C65116 /* MTTcpTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98C11D74BA8300F41187 /* MTTcpTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39918B1650400C65116 /* MTTcpTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98C31D74BA8A00F41187 /* MTTcpTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A39A18B1650400C65116 /* MTTcpTransport.m */; }; + D0CD98C41D74BA8A00F41187 /* MTTcpTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A39A18B1650400C65116 /* MTTcpTransport.m */; }; + D0CD98C51D74BA8D00F41187 /* MTTcpConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39518B1650400C65116 /* MTTcpConnection.h */; }; + D0CD98C61D74BA8D00F41187 /* MTTcpConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39518B1650400C65116 /* MTTcpConnection.h */; }; + D0CD98C71D74BA9000F41187 /* MTTcpConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A39618B1650400C65116 /* MTTcpConnection.m */; }; + D0CD98C81D74BA9100F41187 /* MTTcpConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A39618B1650400C65116 /* MTTcpConnection.m */; }; + D0CD98CA1D74BA9400F41187 /* MTTcpConnectionBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39718B1650400C65116 /* MTTcpConnectionBehaviour.h */; }; + D0CD98CB1D74BA9500F41187 /* MTTcpConnectionBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A39718B1650400C65116 /* MTTcpConnectionBehaviour.h */; }; + D0CD98CC1D74BA9700F41187 /* MTTcpConnectionBehaviour.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A39818B1650400C65116 /* MTTcpConnectionBehaviour.m */; }; + D0CD98CD1D74BA9700F41187 /* MTTcpConnectionBehaviour.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A39818B1650400C65116 /* MTTcpConnectionBehaviour.m */; }; + D0CD98CE1D74BA9B00F41187 /* MTHttpTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A718B1650F00C65116 /* MTHttpTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98CF1D74BA9B00F41187 /* MTHttpTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A718B1650F00C65116 /* MTHttpTransport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98D01D74BAA200F41187 /* MTHttpTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3A818B1650F00C65116 /* MTHttpTransport.m */; }; + D0CD98D11D74BAA200F41187 /* MTHttpTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3A818B1650F00C65116 /* MTHttpTransport.m */; }; + D0CD98D21D74BAA400F41187 /* MTHttpWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A918B1650F00C65116 /* MTHttpWorker.h */; }; + D0CD98D31D74BAA500F41187 /* MTHttpWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3A918B1650F00C65116 /* MTHttpWorker.h */; }; + D0CD98D41D74BAA800F41187 /* MTHttpWorker.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3AA18B1650F00C65116 /* MTHttpWorker.m */; }; + D0CD98D51D74BAA800F41187 /* MTHttpWorker.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3AA18B1650F00C65116 /* MTHttpWorker.m */; }; + D0CD98D61D74BAAA00F41187 /* MTHttpWorkerBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3AB18B1650F00C65116 /* MTHttpWorkerBehaviour.h */; }; + D0CD98D71D74BAAA00F41187 /* MTHttpWorkerBehaviour.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A3AB18B1650F00C65116 /* MTHttpWorkerBehaviour.h */; }; + D0CD98D81D74BAAD00F41187 /* MTHttpWorkerBehaviour.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3AC18B1650F00C65116 /* MTHttpWorkerBehaviour.m */; }; + D0CD98D91D74BAAD00F41187 /* MTHttpWorkerBehaviour.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A3AC18B1650F00C65116 /* MTHttpWorkerBehaviour.m */; }; + D0CD98DC1D74BAEA00F41187 /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A851818AFF2F8007F1076 /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98DD1D74BAEA00F41187 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84EA18AFF259007F1076 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98DE1D74BAEA00F41187 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84EC18AFF259007F1076 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98DF1D74BAEA00F41187 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84F518AFF259007F1076 /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98E01D74BAEB00F41187 /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A851818AFF2F8007F1076 /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98E11D74BAEB00F41187 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84EA18AFF259007F1076 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98E21D74BAEB00F41187 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84EC18AFF259007F1076 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98E31D74BAEB00F41187 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84F518AFF259007F1076 /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D0CD98E41D74BAF400F41187 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84F818AFF259007F1076 /* GCDAsyncSocket.m */; }; + D0CD98E51D74BAF400F41187 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = D05A84F818AFF259007F1076 /* GCDAsyncSocket.m */; }; + D0CD98E81D75C0BB00F41187 /* MTMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35018B1631900C65116 /* MTMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98E91D75C0BB00F41187 /* MTMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35018B1631900C65116 /* MTMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98EA1D75C0C100F41187 /* MTMessageTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35118B1631900C65116 /* MTMessageTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98EB1D75C0C100F41187 /* MTMessageTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35118B1631900C65116 /* MTMessageTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98EC1D75C0C500F41187 /* MTMessageTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A35218B1631900C65116 /* MTMessageTransaction.m */; }; + D0CD98ED1D75C0C500F41187 /* MTMessageTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A35218B1631900C65116 /* MTMessageTransaction.m */; }; + D0CD98EE1D75C0C900F41187 /* MTTimeSyncMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35918B164BA00C65116 /* MTTimeSyncMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98EF1D75C0CA00F41187 /* MTTimeSyncMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35918B164BA00C65116 /* MTTimeSyncMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98F01D75C0D200F41187 /* MTTimeSyncMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A35A18B164BA00C65116 /* MTTimeSyncMessageService.m */; }; + D0CD98F11D75C0D300F41187 /* MTTimeSyncMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A35A18B164BA00C65116 /* MTTimeSyncMessageService.m */; }; + D0CD98F21D75C0D700F41187 /* MTRequestMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36718B164D600C65116 /* MTRequestMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98F31D75C0D700F41187 /* MTRequestMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36718B164D600C65116 /* MTRequestMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98F41D75C0DD00F41187 /* MTRequestMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36818B164D600C65116 /* MTRequestMessageService.m */; }; + D0CD98F51D75C0DD00F41187 /* MTRequestMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36818B164D600C65116 /* MTRequestMessageService.m */; }; + D0CD98F61D75C0E400F41187 /* MTRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36318B164D600C65116 /* MTRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98F71D75C0E400F41187 /* MTRequestContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36518B164D600C65116 /* MTRequestContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98F81D75C0E400F41187 /* MTRequestErrorContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 93DBD22F18B2D72800631ADC /* MTRequestErrorContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98F91D75C0E400F41187 /* MTDropResponseContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36118B164D600C65116 /* MTDropResponseContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98FA1D75C0E400F41187 /* MTApiEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35F18B164D600C65116 /* MTApiEnvironment.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98FB1D75C0E500F41187 /* MTRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36318B164D600C65116 /* MTRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98FC1D75C0E500F41187 /* MTRequestContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36518B164D600C65116 /* MTRequestContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98FD1D75C0E500F41187 /* MTRequestErrorContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 93DBD22F18B2D72800631ADC /* MTRequestErrorContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98FE1D75C0E500F41187 /* MTDropResponseContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A36118B164D600C65116 /* MTDropResponseContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD98FF1D75C0E500F41187 /* MTApiEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A35F18B164D600C65116 /* MTApiEnvironment.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD99001D75C0ED00F41187 /* MTRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36418B164D600C65116 /* MTRequest.m */; }; + D0CD99011D75C0ED00F41187 /* MTRequestContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36618B164D600C65116 /* MTRequestContext.m */; }; + D0CD99021D75C0ED00F41187 /* MTRequestErrorContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DBD23018B2D72800631ADC /* MTRequestErrorContext.m */; }; + D0CD99031D75C0ED00F41187 /* MTDropResponseContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36218B164D600C65116 /* MTDropResponseContext.m */; }; + D0CD99041D75C0ED00F41187 /* MTApiEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36018B164D600C65116 /* MTApiEnvironment.m */; }; + D0CD99051D75C0ED00F41187 /* MTRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36418B164D600C65116 /* MTRequest.m */; }; + D0CD99061D75C0ED00F41187 /* MTRequestContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36618B164D600C65116 /* MTRequestContext.m */; }; + D0CD99071D75C0ED00F41187 /* MTRequestErrorContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DBD23018B2D72800631ADC /* MTRequestErrorContext.m */; }; + D0CD99081D75C0ED00F41187 /* MTDropResponseContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36218B164D600C65116 /* MTDropResponseContext.m */; }; + D0CD99091D75C0ED00F41187 /* MTApiEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A36018B164D600C65116 /* MTApiEnvironment.m */; }; + D0CD990A1D75C0F300F41187 /* MTResendMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A37D18B164E600C65116 /* MTResendMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD990B1D75C0F400F41187 /* MTResendMessageService.h in Headers */ = {isa = PBXBuildFile; fileRef = D063A37D18B164E600C65116 /* MTResendMessageService.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D0CD990C1D75C0F900F41187 /* MTResendMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A37E18B164E600C65116 /* MTResendMessageService.m */; }; + D0CD990D1D75C0F900F41187 /* MTResendMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = D063A37E18B164E600C65116 /* MTResendMessageService.m */; }; + D0CD990E1D75C12C00F41187 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D00354711C173CD0006610DA /* libz.tbd */; }; D0D1A0361ADD983C007D9ED6 /* MTBadMsgNotificationMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0041ADD983C007D9ED6 /* MTBadMsgNotificationMessage.h */; }; D0D1A0371ADD983C007D9ED6 /* MTBadMsgNotificationMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D1A0051ADD983C007D9ED6 /* MTBadMsgNotificationMessage.m */; }; D0D1A0381ADD983C007D9ED6 /* MTBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D1A0061ADD983C007D9ED6 /* MTBuffer.h */; }; @@ -171,6 +539,7 @@ D0D225101B4D817B0085E26D /* MtProtoKitDynamic.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D2250F1B4D817B0085E26D /* MtProtoKitDynamic.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0D225161B4D817B0085E26D /* MtProtoKitDynamic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0D2250B1B4D817B0085E26D /* MtProtoKitDynamic.framework */; }; D0D2251D1B4D817B0085E26D /* MtProtoKitDynamicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D2251C1B4D817B0085E26D /* MtProtoKitDynamicTests.m */; }; + D0D2689E1D7A055400C422DA /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CD990F1D75C16100F41187 /* libcrypto.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -200,81 +569,12 @@ D00354691C173BF0006610DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D00354711C173CD0006610DA /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; D00354731C173CD9006610DA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - D0254C2C18B103D4009452AA /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = ""; }; - D0254C2D18B103D4009452AA /* asn1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1.h; sourceTree = ""; }; - D0254C2E18B103D4009452AA /* asn1_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1_mac.h; sourceTree = ""; }; - D0254C2F18B103D4009452AA /* asn1t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1t.h; sourceTree = ""; }; - D0254C3018B103D4009452AA /* bio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bio.h; sourceTree = ""; }; - D0254C3118B103D4009452AA /* blowfish.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blowfish.h; sourceTree = ""; }; - D0254C3218B103D4009452AA /* bn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bn.h; sourceTree = ""; }; - D0254C3318B103D4009452AA /* buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = buffer.h; sourceTree = ""; }; - D0254C3418B103D4009452AA /* camellia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = camellia.h; sourceTree = ""; }; - D0254C3518B103D4009452AA /* cast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cast.h; sourceTree = ""; }; - D0254C3618B103D4009452AA /* cmac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cmac.h; sourceTree = ""; }; - D0254C3718B103D4009452AA /* cms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cms.h; sourceTree = ""; }; - D0254C3818B103D4009452AA /* comp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = comp.h; sourceTree = ""; }; - D0254C3918B103D4009452AA /* conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = conf.h; sourceTree = ""; }; - D0254C3A18B103D4009452AA /* conf_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = conf_api.h; sourceTree = ""; }; - D0254C3B18B103D4009452AA /* crypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypto.h; sourceTree = ""; }; - D0254C3C18B103D4009452AA /* des.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = des.h; sourceTree = ""; }; - D0254C3D18B103D4009452AA /* des_old.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = des_old.h; sourceTree = ""; }; - D0254C3E18B103D4009452AA /* dh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dh.h; sourceTree = ""; }; - D0254C3F18B103D4009452AA /* dsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dsa.h; sourceTree = ""; }; - D0254C4018B103D4009452AA /* dso.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dso.h; sourceTree = ""; }; - D0254C4118B103D4009452AA /* dtls1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dtls1.h; sourceTree = ""; }; - D0254C4218B103D4009452AA /* e_os2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = e_os2.h; sourceTree = ""; }; - D0254C4318B103D4009452AA /* ebcdic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ebcdic.h; sourceTree = ""; }; - D0254C4418B103D4009452AA /* ec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ec.h; sourceTree = ""; }; - D0254C4518B103D4009452AA /* ecdh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecdh.h; sourceTree = ""; }; - D0254C4618B103D4009452AA /* ecdsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecdsa.h; sourceTree = ""; }; - D0254C4718B103D4009452AA /* engine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = engine.h; sourceTree = ""; }; - D0254C4818B103D4009452AA /* err.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = err.h; sourceTree = ""; }; - D0254C4918B103D4009452AA /* evp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = evp.h; sourceTree = ""; }; - D0254C4A18B103D4009452AA /* hmac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hmac.h; sourceTree = ""; }; - D0254C4B18B103D4009452AA /* idea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = idea.h; sourceTree = ""; }; - D0254C4C18B103D4009452AA /* krb5_asn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = krb5_asn.h; sourceTree = ""; }; - D0254C4D18B103D4009452AA /* kssl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kssl.h; sourceTree = ""; }; - D0254C4E18B103D4009452AA /* lhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lhash.h; sourceTree = ""; }; - D0254C4F18B103D4009452AA /* md4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md4.h; sourceTree = ""; }; - D0254C5018B103D4009452AA /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = ""; }; - D0254C5118B103D4009452AA /* mdc2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mdc2.h; sourceTree = ""; }; - D0254C5218B103D4009452AA /* modes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modes.h; sourceTree = ""; }; - D0254C5318B103D4009452AA /* obj_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = obj_mac.h; sourceTree = ""; }; - D0254C5418B103D4009452AA /* objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = objects.h; sourceTree = ""; }; - D0254C5518B103D4009452AA /* ocsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ocsp.h; sourceTree = ""; }; - D0254C5618B103D4009452AA /* opensslconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opensslconf.h; sourceTree = ""; }; - D0254C5718B103D4009452AA /* opensslv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opensslv.h; sourceTree = ""; }; - D0254C5818B103D4009452AA /* ossl_typ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ossl_typ.h; sourceTree = ""; }; - D0254C5918B103D4009452AA /* pem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pem.h; sourceTree = ""; }; - D0254C5A18B103D4009452AA /* pem2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pem2.h; sourceTree = ""; }; - D0254C5B18B103D4009452AA /* pkcs12.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pkcs12.h; sourceTree = ""; }; - D0254C5C18B103D4009452AA /* pkcs7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pkcs7.h; sourceTree = ""; }; - D0254C5D18B103D4009452AA /* pqueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pqueue.h; sourceTree = ""; }; - D0254C5E18B103D4009452AA /* rand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rand.h; sourceTree = ""; }; - D0254C5F18B103D4009452AA /* rc2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rc2.h; sourceTree = ""; }; - D0254C6018B103D4009452AA /* rc4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rc4.h; sourceTree = ""; }; - D0254C6118B103D4009452AA /* ripemd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ripemd.h; sourceTree = ""; }; - D0254C6218B103D4009452AA /* rsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rsa.h; sourceTree = ""; }; - D0254C6318B103D4009452AA /* safestack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = safestack.h; sourceTree = ""; }; - D0254C6418B103D4009452AA /* seed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seed.h; sourceTree = ""; }; - D0254C6518B103D4009452AA /* sha.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sha.h; sourceTree = ""; }; - D0254C6618B103D4009452AA /* srp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = srp.h; sourceTree = ""; }; - D0254C6718B103D4009452AA /* srtp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = srtp.h; sourceTree = ""; }; - D0254C6818B103D4009452AA /* ssl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ssl.h; sourceTree = ""; }; - D0254C6918B103D4009452AA /* ssl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ssl2.h; sourceTree = ""; }; - D0254C6A18B103D4009452AA /* ssl23.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ssl23.h; sourceTree = ""; }; - D0254C6B18B103D4009452AA /* ssl3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ssl3.h; sourceTree = ""; }; - D0254C6C18B103D4009452AA /* stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stack.h; sourceTree = ""; }; - D0254C6D18B103D4009452AA /* symhacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = symhacks.h; sourceTree = ""; }; - D0254C6E18B103D4009452AA /* tls1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tls1.h; sourceTree = ""; }; - D0254C6F18B103D4009452AA /* ts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts.h; sourceTree = ""; }; - D0254C7018B103D4009452AA /* txt_db.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = txt_db.h; sourceTree = ""; }; - D0254C7118B103D4009452AA /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui.h; sourceTree = ""; }; - D0254C7218B103D4009452AA /* ui_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui_compat.h; sourceTree = ""; }; - D0254C7318B103D4009452AA /* whrlpool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = whrlpool.h; sourceTree = ""; }; - D0254C7418B103D4009452AA /* x509.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x509.h; sourceTree = ""; }; - D0254C7518B103D4009452AA /* x509_vfy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x509_vfy.h; sourceTree = ""; }; - D0254C7618B103D4009452AA /* x509v3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x509v3.h; sourceTree = ""; }; + D010DB7B1D70ABEE0012AD96 /* MTRsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRsa.h; sourceTree = ""; }; + D010DB7C1D70ABEE0012AD96 /* MTRsa.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRsa.m; sourceTree = ""; }; + D010DB7F1D70B3B90012AD96 /* MTAes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTAes.h; sourceTree = ""; }; + D010DB801D70B3B90012AD96 /* MTAes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTAes.m; sourceTree = ""; }; + D020FAF81D994E3100F279AA /* MTHttpRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTHttpRequestOperation.h; path = MTProtoKit/MTHttpRequestOperation.h; sourceTree = ""; }; + D020FAF91D994E3100F279AA /* MTHttpRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MTHttpRequestOperation.m; path = MTProtoKit/MTHttpRequestOperation.m; sourceTree = ""; }; D0254CC518B10404009452AA /* MTEncryption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTEncryption.h; path = MTProtoKit/MTEncryption.h; sourceTree = ""; }; D0503AD818B027F80074C3FE /* MTOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTOutputStream.h; path = MTProtoKit/MTOutputStream.h; sourceTree = ""; }; D0503AD918B027F80074C3FE /* MTOutputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MTOutputStream.m; path = MTProtoKit/MTOutputStream.m; sourceTree = ""; }; @@ -336,7 +636,6 @@ D05A84F818AFF259007F1076 /* GCDAsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCDAsyncSocket.m; sourceTree = ""; }; D05A851718AFF2F8007F1076 /* AFJSONUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONUtilities.h; sourceTree = ""; }; D05A851818AFF2F8007F1076 /* AFJSONUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONUtilities.m; sourceTree = ""; }; - D063A2F718B14A9400C65116 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libcrypto.a; sourceTree = ""; }; D063A2F918B14AB500C65116 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libcrypto.dylib; sourceTree = DEVELOPER_DIR; }; D063A31518B157F700C65116 /* MtProtoKit-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "MtProtoKit-Prefix.pch"; path = "MtProtoKitiOS/MtProtoKit-Prefix.pch"; sourceTree = SOURCE_ROOT; }; D063A31818B157F700C65116 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = ""; }; @@ -400,12 +699,35 @@ D079ABA81AF39B8000076F59 /* MtProtoKitMacTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MtProtoKitMacTests.m; sourceTree = ""; }; D09A59561B582EFF00FC3724 /* MTFileBasedKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTFileBasedKeychain.h; path = MTProtoKit/MTFileBasedKeychain.h; sourceTree = ""; }; D09A59571B582EFF00FC3724 /* MTFileBasedKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MTFileBasedKeychain.m; path = MTProtoKit/MTFileBasedKeychain.m; sourceTree = ""; }; - D0A44E4D18B24A6000B64FC6 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libcrypto.a; sourceTree = ""; }; + D0B0DF5C1DD7E75B003BA12D /* MTBag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTBag.m; sourceTree = ""; }; + D0B0DF601DD7E768003BA12D /* MTBag.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTBag.h; sourceTree = ""; }; + D0B418741D7E04B7004562A4 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; }; + D0B418761D7E04C3004562A4 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + D0B418781D7E04CB004562A4 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + D0B4187A1D7E04CF004562A4 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; + D0B4187C1D7E04EB004562A4 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = openssl/OSX/libcrypto.a; sourceTree = ""; }; + D0C932211E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTNetworkUsageCalculationInfo.h; sourceTree = ""; }; + D0C932221E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTNetworkUsageCalculationInfo.m; sourceTree = ""; }; + D0C932291E095E280074F044 /* MTNetworkUsageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTNetworkUsageManager.h; sourceTree = ""; }; + D0C9322A1E095E280074F044 /* MTNetworkUsageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTNetworkUsageManager.m; sourceTree = ""; }; + D0CAF2C91D75E24C0011F558 /* MTSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTSignal.h; sourceTree = ""; }; + D0CAF2CA1D75E24C0011F558 /* MTSignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTSignal.m; sourceTree = ""; }; + D0CAF2D11D75E26D0011F558 /* MTSubscriber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTSubscriber.h; sourceTree = ""; }; + D0CAF2D21D75E26D0011F558 /* MTSubscriber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTSubscriber.m; sourceTree = ""; }; + D0CAF2D51D75E2840011F558 /* MTDisposable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTDisposable.h; sourceTree = ""; }; + D0CAF2D61D75E2840011F558 /* MTDisposable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTDisposable.m; sourceTree = ""; }; + D0CAF2E11D75E7F30011F558 /* MTAtomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTAtomic.h; sourceTree = ""; }; + D0CAF2E21D75E7F30011F558 /* MTAtomic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTAtomic.m; sourceTree = ""; }; + D0CAF2EB1D75F4520011F558 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + D0CAF2EE1D75F4E20011F558 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + D0CAF2F01D75F4EA0011F558 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; D0CB05F71ADC4483005E298F /* MtProtoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MtProtoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D0CB05FA1ADC4483005E298F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D0CB05FB1ADC4483005E298F /* MtProtoKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MtProtoKit.h; sourceTree = ""; }; D0CB06071ADC4483005E298F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D0CB06081ADC4483005E298F /* MtProtoKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MtProtoKitTests.m; sourceTree = ""; }; + D0CD98E61D75BFAE00F41187 /* SSignalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SSignalKit.framework; path = "../SSignalKit/build/Debug-iphoneos/SSignalKit.framework"; sourceTree = ""; }; + D0CD990F1D75C16100F41187 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = openssl/iOS/libcrypto.a; sourceTree = ""; }; D0D1A0041ADD983C007D9ED6 /* MTBadMsgNotificationMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTBadMsgNotificationMessage.h; path = MTProtoKit/MTBadMsgNotificationMessage.h; sourceTree = ""; }; D0D1A0051ADD983C007D9ED6 /* MTBadMsgNotificationMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MTBadMsgNotificationMessage.m; path = MTProtoKit/MTBadMsgNotificationMessage.m; sourceTree = ""; }; D0D1A0061ADD983C007D9ED6 /* MTBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTBuffer.h; path = MTProtoKit/MTBuffer.h; sourceTree = ""; }; @@ -465,6 +787,7 @@ D0D225151B4D817B0085E26D /* MtProtoKitDynamicTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MtProtoKitDynamicTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D0D2251B1B4D817B0085E26D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D0D2251C1B4D817B0085E26D /* MtProtoKitDynamicTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MtProtoKitDynamicTests.m; sourceTree = ""; }; + D0E1D6731CBC20BA00B04029 /* SSignalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SSignalKit.framework; path = "../../../../Library/Developer/Xcode/DerivedData/Telegram-iOS-diblohvjozhgaifjcniwdlixlilx/Build/Products/Debug-iphonesimulator/SSignalKit.framework"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -483,6 +806,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D0B4187D1D7E04EB004562A4 /* libcrypto.a in Frameworks */, + D0B4187B1D7E04CF004562A4 /* libz.tbd in Frameworks */, + D0B418791D7E04CB004562A4 /* Security.framework in Frameworks */, + D0B418771D7E04C3004562A4 /* SystemConfiguration.framework in Frameworks */, + D0B418751D7E04B7004562A4 /* CFNetwork.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -490,8 +818,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D0580ABF1B0F3E7100E8235B /* SSignalKit.framework in Frameworks */, - D0CB066B1ADC48C4005E298F /* libcrypto.a in Frameworks */, + D0D2689E1D7A055400C422DA /* libcrypto.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -499,6 +826,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D0CAF2FD1D7628FD0011F558 /* libcrypto.a in Frameworks */, + D0CAF2F11D75F4EA0011F558 /* CFNetwork.framework in Frameworks */, + D0CAF2EF1D75F4E20011F558 /* UIKit.framework in Frameworks */, + D0CAF2ED1D75F4570011F558 /* SystemConfiguration.framework in Frameworks */, + D0CAF2EC1D75F4520011F558 /* Security.framework in Frameworks */, + D0CD990E1D75C12C00F41187 /* libz.tbd in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -533,98 +866,6 @@ path = MtProtoKitStabilityTests; sourceTree = ""; }; - D0254C2918B103D4009452AA /* openssl */ = { - isa = PBXGroup; - children = ( - D0A44E4C18B24A6000B64FC6 /* OSX */, - D063A2F618B14A9400C65116 /* iOS */, - D0254C2B18B103D4009452AA /* openssl */, - ); - path = openssl; - sourceTree = ""; - }; - D0254C2B18B103D4009452AA /* openssl */ = { - isa = PBXGroup; - children = ( - D0254C2C18B103D4009452AA /* aes.h */, - D0254C2D18B103D4009452AA /* asn1.h */, - D0254C2E18B103D4009452AA /* asn1_mac.h */, - D0254C2F18B103D4009452AA /* asn1t.h */, - D0254C3018B103D4009452AA /* bio.h */, - D0254C3118B103D4009452AA /* blowfish.h */, - D0254C3218B103D4009452AA /* bn.h */, - D0254C3318B103D4009452AA /* buffer.h */, - D0254C3418B103D4009452AA /* camellia.h */, - D0254C3518B103D4009452AA /* cast.h */, - D0254C3618B103D4009452AA /* cmac.h */, - D0254C3718B103D4009452AA /* cms.h */, - D0254C3818B103D4009452AA /* comp.h */, - D0254C3918B103D4009452AA /* conf.h */, - D0254C3A18B103D4009452AA /* conf_api.h */, - D0254C3B18B103D4009452AA /* crypto.h */, - D0254C3C18B103D4009452AA /* des.h */, - D0254C3D18B103D4009452AA /* des_old.h */, - D0254C3E18B103D4009452AA /* dh.h */, - D0254C3F18B103D4009452AA /* dsa.h */, - D0254C4018B103D4009452AA /* dso.h */, - D0254C4118B103D4009452AA /* dtls1.h */, - D0254C4218B103D4009452AA /* e_os2.h */, - D0254C4318B103D4009452AA /* ebcdic.h */, - D0254C4418B103D4009452AA /* ec.h */, - D0254C4518B103D4009452AA /* ecdh.h */, - D0254C4618B103D4009452AA /* ecdsa.h */, - D0254C4718B103D4009452AA /* engine.h */, - D0254C4818B103D4009452AA /* err.h */, - D0254C4918B103D4009452AA /* evp.h */, - D0254C4A18B103D4009452AA /* hmac.h */, - D0254C4B18B103D4009452AA /* idea.h */, - D0254C4C18B103D4009452AA /* krb5_asn.h */, - D0254C4D18B103D4009452AA /* kssl.h */, - D0254C4E18B103D4009452AA /* lhash.h */, - D0254C4F18B103D4009452AA /* md4.h */, - D0254C5018B103D4009452AA /* md5.h */, - D0254C5118B103D4009452AA /* mdc2.h */, - D0254C5218B103D4009452AA /* modes.h */, - D0254C5318B103D4009452AA /* obj_mac.h */, - D0254C5418B103D4009452AA /* objects.h */, - D0254C5518B103D4009452AA /* ocsp.h */, - D0254C5618B103D4009452AA /* opensslconf.h */, - D0254C5718B103D4009452AA /* opensslv.h */, - D0254C5818B103D4009452AA /* ossl_typ.h */, - D0254C5918B103D4009452AA /* pem.h */, - D0254C5A18B103D4009452AA /* pem2.h */, - D0254C5B18B103D4009452AA /* pkcs12.h */, - D0254C5C18B103D4009452AA /* pkcs7.h */, - D0254C5D18B103D4009452AA /* pqueue.h */, - D0254C5E18B103D4009452AA /* rand.h */, - D0254C5F18B103D4009452AA /* rc2.h */, - D0254C6018B103D4009452AA /* rc4.h */, - D0254C6118B103D4009452AA /* ripemd.h */, - D0254C6218B103D4009452AA /* rsa.h */, - D0254C6318B103D4009452AA /* safestack.h */, - D0254C6418B103D4009452AA /* seed.h */, - D0254C6518B103D4009452AA /* sha.h */, - D0254C6618B103D4009452AA /* srp.h */, - D0254C6718B103D4009452AA /* srtp.h */, - D0254C6818B103D4009452AA /* ssl.h */, - D0254C6918B103D4009452AA /* ssl2.h */, - D0254C6A18B103D4009452AA /* ssl23.h */, - D0254C6B18B103D4009452AA /* ssl3.h */, - D0254C6C18B103D4009452AA /* stack.h */, - D0254C6D18B103D4009452AA /* symhacks.h */, - D0254C6E18B103D4009452AA /* tls1.h */, - D0254C6F18B103D4009452AA /* ts.h */, - D0254C7018B103D4009452AA /* txt_db.h */, - D0254C7118B103D4009452AA /* ui.h */, - D0254C7218B103D4009452AA /* ui_compat.h */, - D0254C7318B103D4009452AA /* whrlpool.h */, - D0254C7418B103D4009452AA /* x509.h */, - D0254C7518B103D4009452AA /* x509_vfy.h */, - D0254C7618B103D4009452AA /* x509v3.h */, - ); - path = openssl; - sourceTree = ""; - }; D05A830918AFB3F9007F1076 = { isa = PBXGroup; children = ( @@ -660,6 +901,17 @@ D05A831618AFB3F9007F1076 /* Frameworks */ = { isa = PBXGroup; children = ( + D0B4187C1D7E04EB004562A4 /* libcrypto.a */, + D0B4187A1D7E04CF004562A4 /* libz.tbd */, + D0B418781D7E04CB004562A4 /* Security.framework */, + D0B418761D7E04C3004562A4 /* SystemConfiguration.framework */, + D0B418741D7E04B7004562A4 /* CFNetwork.framework */, + D0CAF2F01D75F4EA0011F558 /* CFNetwork.framework */, + D0CAF2EE1D75F4E20011F558 /* UIKit.framework */, + D0CAF2EB1D75F4520011F558 /* Security.framework */, + D0CD990F1D75C16100F41187 /* libcrypto.a */, + D0CD98E61D75BFAE00F41187 /* SSignalKit.framework */, + D0E1D6731CBC20BA00B04029 /* SSignalKit.framework */, D00354731C173CD9006610DA /* SystemConfiguration.framework */, D00354711C173CD0006610DA /* libz.tbd */, D0580ABE1B0F3E7100E8235B /* SSignalKit.framework */, @@ -743,6 +995,7 @@ D05A842B18AFB770007F1076 /* Utils */ = { isa = PBXGroup; children = ( + D0CD99111D75C5D100F41187 /* Signals */, 93DBD23318B2D9AA00631ADC /* MTTime.h */, 93DBD23418B2DA1E00631ADC /* MTTime.m */, D05A84D918AFE81D007F1076 /* MTTimer.h */, @@ -758,6 +1011,16 @@ D0503AD918B027F80074C3FE /* MTOutputStream.m */, D0503ADC18B029480074C3FE /* MTInputStream.h */, D0503ADD18B029480074C3FE /* MTInputStream.m */, + D010DB7B1D70ABEE0012AD96 /* MTRsa.h */, + D010DB7C1D70ABEE0012AD96 /* MTRsa.m */, + D010DB7F1D70B3B90012AD96 /* MTAes.h */, + D010DB801D70B3B90012AD96 /* MTAes.m */, + D020FAF81D994E3100F279AA /* MTHttpRequestOperation.h */, + D020FAF91D994E3100F279AA /* MTHttpRequestOperation.m */, + D0C932211E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h */, + D0C932221E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m */, + D0C932291E095E280074F044 /* MTNetworkUsageManager.h */, + D0C9322A1E095E280074F044 /* MTNetworkUsageManager.m */, ); name = Utils; sourceTree = ""; @@ -964,7 +1227,6 @@ D05A84E718AFF0EE007F1076 /* Third Party */ = { isa = PBXGroup; children = ( - D0254C2918B103D4009452AA /* openssl */, D05A84E818AFF259007F1076 /* AFNetworking */, D05A84F618AFF259007F1076 /* AsyncSocket */, ); @@ -998,14 +1260,6 @@ path = thirdparty/AsyncSocket; sourceTree = ""; }; - D063A2F618B14A9400C65116 /* iOS */ = { - isa = PBXGroup; - children = ( - D063A2F718B14A9400C65116 /* libcrypto.a */, - ); - path = iOS; - sourceTree = ""; - }; D063A31618B157F700C65116 /* en.lproj */ = { isa = PBXGroup; children = ( @@ -1049,14 +1303,6 @@ name = "Supporting Files"; sourceTree = ""; }; - D0A44E4C18B24A6000B64FC6 /* OSX */ = { - isa = PBXGroup; - children = ( - D0A44E4D18B24A6000B64FC6 /* libcrypto.a */, - ); - path = OSX; - sourceTree = ""; - }; D0CB05F81ADC4483005E298F /* MtProtoKit */ = { isa = PBXGroup; children = ( @@ -1091,6 +1337,23 @@ name = "Supporting Files"; sourceTree = ""; }; + D0CD99111D75C5D100F41187 /* Signals */ = { + isa = PBXGroup; + children = ( + D0B0DF601DD7E768003BA12D /* MTBag.h */, + D0B0DF5C1DD7E75B003BA12D /* MTBag.m */, + D0CAF2E11D75E7F30011F558 /* MTAtomic.h */, + D0CAF2E21D75E7F30011F558 /* MTAtomic.m */, + D0CAF2D51D75E2840011F558 /* MTDisposable.h */, + D0CAF2D61D75E2840011F558 /* MTDisposable.m */, + D0CAF2D11D75E26D0011F558 /* MTSubscriber.h */, + D0CAF2D21D75E26D0011F558 /* MTSubscriber.m */, + D0CAF2C91D75E24C0011F558 /* MTSignal.h */, + D0CAF2CA1D75E24C0011F558 /* MTSignal.m */, + ); + name = Signals; + sourceTree = ""; + }; D0D1A0681ADD9844007D9ED6 /* Messages */ = { isa = PBXGroup; children = ( @@ -1189,8 +1452,91 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + D0CD97FD1D74B96300F41187 /* MTBuffer.h in Headers */, + D0CD98D61D74BAAA00F41187 /* MTHttpWorkerBehaviour.h in Headers */, + D0CD98131D74B99400F41187 /* MTInternalMessageParser.h in Headers */, + D0CD98EE1D75C0C900F41187 /* MTTimeSyncMessageService.h in Headers */, + D0CD989F1D74BA6500F41187 /* MTProto.h in Headers */, + D0CD98F21D75C0D700F41187 /* MTRequestMessageService.h in Headers */, + D0CD97D21D74B91400F41187 /* MTTime.h in Headers */, + D0CD98151D74B99400F41187 /* MTMsgAllInfoMessage.h in Headers */, + D0CD98A31D74BA6500F41187 /* MTOutgoingMessage.h in Headers */, + D0CD97F81D74B94B00F41187 /* MTRsa.h in Headers */, + D0CD98C01D74BA8200F41187 /* MTTcpTransport.h in Headers */, + D0CD98CA1D74BA9400F41187 /* MTTcpConnectionBehaviour.h in Headers */, + D0CD981F1D74B99400F41187 /* MTResPqMessage.h in Headers */, + D0CD98E81D75C0BB00F41187 /* MTMessageService.h in Headers */, + D0B0DF621DD7E7A3003BA12D /* MTBag.h in Headers */, + D0CD98681D74B9E200F41187 /* MTContext.h in Headers */, + D0CD985B1D74B9BF00F41187 /* MTSetClientDhParamsResponseMessage.h in Headers */, + D0CD98741D74BA0100F41187 /* MTDiscoverDatacenterAddressAction.h in Headers */, + D0CD98EA1D75C0C100F41187 /* MTMessageTransaction.h in Headers */, + D0CD98B41D74BA7500F41187 /* MTNetworkAvailability.h in Headers */, + D0CD98A21D74BA6500F41187 /* MTPreparedMessage.h in Headers */, + D0CD98F91D75C0E400F41187 /* MTDropResponseContext.h in Headers */, + D0CD986C1D74B9EF00F41187 /* MTTransportScheme.h in Headers */, + D0CD984D1D74B9AE00F41187 /* MTRpcError.h in Headers */, + D0CD98171D74B99400F41187 /* MTMsgDetailedInfoMessage.h in Headers */, + D0CD98A41D74BA6500F41187 /* MTIncomingMessage.h in Headers */, + D0CD97FC1D74B96300F41187 /* MTBadMsgNotificationMessage.h in Headers */, + D0CD98121D74B99400F41187 /* MTFutureSaltsMessage.h in Headers */, + D0CD985A1D74B9BF00F41187 /* MTServerDhParamsMessage.h in Headers */, + D0CAF2E51D75EA790011F558 /* MTAtomic.h in Headers */, + D0CD98A11D74BA6500F41187 /* MTTimeFixContext.h in Headers */, + D0CD97FE1D74B96300F41187 /* MTBufferReader.h in Headers */, + D0CD97FF1D74B96300F41187 /* MTDestroySessionResponseMessage.h in Headers */, + D0CD97FA1D74B95000F41187 /* MTSerialization.h in Headers */, + D0CD98641D74B9D700F41187 /* MTFileBasedKeychain.h in Headers */, + D0CD98A01D74BA6500F41187 /* MTSessionInfo.h in Headers */, + D0CD97D61D74B91E00F41187 /* MTTimer.h in Headers */, + D0CD98F81D75C0E400F41187 /* MTRequestErrorContext.h in Headers */, + D0CD98A51D74BA6500F41187 /* MTMessageEncryptionKey.h in Headers */, + D0CD981D1D74B99400F41187 /* MTPingMessage.h in Headers */, + D0CD97F91D74B94B00F41187 /* MTAes.h in Headers */, + D0CD98581D74B9BF00F41187 /* MTRpcResultMessage.h in Headers */, D079AB9C1AF39B8000076F59 /* MtProtoKitMac.h in Headers */, - D079ABB01AF39BA400076F59 /* MTProtoKit.h in Headers */, + D0CD98161D74B99400F41187 /* MTMsgContainerMessage.h in Headers */, + D0CD981A1D74B99400F41187 /* MTMsgsStateInfoMessage.h in Headers */, + D0CD98191D74B99400F41187 /* MTMsgsAckMessage.h in Headers */, + D0CD98FA1D75C0E400F41187 /* MTApiEnvironment.h in Headers */, + D0CD98881D74BA5100F41187 /* MTDatacenterAddressListData.h in Headers */, + D0CD98591D74B9BF00F41187 /* MTServerDhInnerDataMessage.h in Headers */, + D0CD98601D74B9D000F41187 /* MTKeychain.h in Headers */, + D0CD98181D74B99400F41187 /* MTMsgResendReqMessage.h in Headers */, + D0CD97E81D74B94300F41187 /* MTLogging.h in Headers */, + D0CD98F61D75C0E400F41187 /* MTRequest.h in Headers */, + D0CAF2D91D75E3160011F558 /* MTSubscriber.h in Headers */, + D0CD98D21D74BAA400F41187 /* MTHttpWorker.h in Headers */, + D0CD981B1D74B99400F41187 /* MTMsgsStateReqMessage.h in Headers */, + D0C9322C1E095E280074F044 /* MTNetworkUsageManager.h in Headers */, + D0CD98101D74B96F00F41187 /* MTExportedAuthorizationData.h in Headers */, + D0CD98F71D75C0E400F41187 /* MTRequestContext.h in Headers */, + D0CD98871D74BA5100F41187 /* MTDatacenterSaltInfo.h in Headers */, + D0CD98CE1D74BA9B00F41187 /* MTHttpTransport.h in Headers */, + D0CD97ED1D74B94300F41187 /* MTInputStream.h in Headers */, + D0CD98141D74B99400F41187 /* MTMessage.h in Headers */, + D0CD987A1D74BA4100F41187 /* MTDatacenterAuthMessageService.h in Headers */, + D0CD98861D74BA5100F41187 /* MTDatacenterAuthInfo.h in Headers */, + D0CD98B51D74BA7500F41187 /* MTTransport.h in Headers */, + D0CD97EC1D74B94300F41187 /* MTOutputStream.h in Headers */, + D0CD98701D74B9F700F41187 /* MTDiscoverConnectionSignals.h in Headers */, + D0CD97E91D74B94300F41187 /* MTEncryption.h in Headers */, + D0C932241E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h in Headers */, + D0CD97EB1D74B94300F41187 /* MTQueue.h in Headers */, + D0CD98001D74B96300F41187 /* MTDropRpcResultMessage.h in Headers */, + D0CD98791D74BA4100F41187 /* MTDatacenterAuthAction.h in Headers */, + D0CD981C1D74B99400F41187 /* MTNewSessionCreatedMessage.h in Headers */, + D0CD98781D74BA4100F41187 /* MTDatacenterTransferAuthAction.h in Headers */, + D0CD990A1D75C0F300F41187 /* MTResendMessageService.h in Headers */, + D020FAFB1D994E3100F279AA /* MTHttpRequestOperation.h in Headers */, + D0CD98841D74BA5100F41187 /* MTDatacenterAddress.h in Headers */, + D0CD97EA1D74B94300F41187 /* MTInternalId.h in Headers */, + D0CAF2DB1D75E31A0011F558 /* MTDisposable.h in Headers */, + D0CD98851D74BA5100F41187 /* MTDatacenterAddressSet.h in Headers */, + D0CD98B61D74BA7500F41187 /* MTTransportTransaction.h in Headers */, + D0CD981E1D74B99400F41187 /* MTPongMessage.h in Headers */, + D0CD98C51D74BA8D00F41187 /* MTTcpConnection.h in Headers */, + D0CAF2CD1D75E2570011F558 /* MTSignal.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1200,6 +1546,7 @@ files = ( D0D1A0381ADD983C007D9ED6 /* MTBuffer.h in Headers */, D0CB06181ADC4541005E298F /* MTTime.h in Headers */, + D0CAF2E31D75E7F30011F558 /* MTAtomic.h in Headers */, D0D1A0581ADD983C007D9ED6 /* MTPingMessage.h in Headers */, D0CB064E1ADC45B1005E298F /* MTDropResponseContext.h in Headers */, D0D1A06B1ADD987A007D9ED6 /* MTDatacenterAddressListData.h in Headers */, @@ -1207,12 +1554,15 @@ D0D1A03A1ADD983C007D9ED6 /* MTBufferReader.h in Headers */, D0CB065C1ADC45CE005E298F /* MTTcpConnection.h in Headers */, D0D1A0501ADD983C007D9ED6 /* MTMsgsAckMessage.h in Headers */, + D0CAF2CB1D75E24C0011F558 /* MTSignal.h in Headers */, D0CB06461ADC45A2005E298F /* MTMessageService.h in Headers */, + D0B0DF611DD7E7A2003BA12D /* MTBag.h in Headers */, D0D1A0601ADD983C007D9ED6 /* MTRpcResultMessage.h in Headers */, D0D1A0461ADD983C007D9ED6 /* MTMessage.h in Headers */, D0D1A0441ADD983C007D9ED6 /* MTInternalMessageParser.h in Headers */, D0D1A05A1ADD983C007D9ED6 /* MTPongMessage.h in Headers */, D0D1A0481ADD983C007D9ED6 /* MTMsgAllInfoMessage.h in Headers */, + D0CAF2D71D75E2840011F558 /* MTDisposable.h in Headers */, D0CB062A1ADC4575005E298F /* MTDatacenterTransferAuthAction.h in Headers */, D0CB064F1ADC45B1005E298F /* MTApiEnvironment.h in Headers */, D0CB06191ADC4541005E298F /* MTTimer.h in Headers */, @@ -1227,6 +1577,7 @@ D0CB06601ADC45CE005E298F /* MTHttpWorkerBehaviour.h in Headers */, D0CB06211ADC454C005E298F /* MTKeychain.h in Headers */, D0580AC21B0F3E9C00E8235B /* MTDiscoverConnectionSignals.h in Headers */, + D0C932231E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h in Headers */, D0CB065F1ADC45CE005E298F /* MTHttpWorker.h in Headers */, D0CB063B1ADC4591005E298F /* MTPreparedMessage.h in Headers */, D0CB065E1ADC45CE005E298F /* MTHttpTransport.h in Headers */, @@ -1238,15 +1589,18 @@ D0CB064A1ADC45B1005E298F /* MTRequestMessageService.h in Headers */, D0D1A0561ADD983C007D9ED6 /* MTNewSessionCreatedMessage.h in Headers */, D0CB061A1ADC4541005E298F /* MTLogging.h in Headers */, + D0CAF2D31D75E26D0011F558 /* MTSubscriber.h in Headers */, D0CB065A1ADC45CE005E298F /* MTTransportTransaction.h in Headers */, D0CB06281ADC456A005E298F /* MTDiscoverDatacenterAddressAction.h in Headers */, D0CB06591ADC45CE005E298F /* MTTransport.h in Headers */, D0CB061F1ADC4541005E298F /* MTInputStream.h in Headers */, D0CB063D1ADC4591005E298F /* MTIncomingMessage.h in Headers */, + D010DB7D1D70ABEE0012AD96 /* MTRsa.h in Headers */, D0CB06251ADC4562005E298F /* MTTransportScheme.h in Headers */, D0D1A05C1ADD983C007D9ED6 /* MTResPqMessage.h in Headers */, D0D1A03E1ADD983C007D9ED6 /* MTDropRpcResultMessage.h in Headers */, D0D1A05E1ADD983C007D9ED6 /* MTRpcError.h in Headers */, + D0C9322B1E095E280074F044 /* MTNetworkUsageManager.h in Headers */, D0CB063A1ADC4591005E298F /* MTTimeFixContext.h in Headers */, D0CB065D1ADC45CE005E298F /* MTTcpConnectionBehaviour.h in Headers */, D09A59581B582EFF00FC3724 /* MTFileBasedKeychain.h in Headers */, @@ -1254,6 +1608,7 @@ D0D1A03C1ADD983C007D9ED6 /* MTDestroySessionResponseMessage.h in Headers */, D0CB061E1ADC4541005E298F /* MTOutputStream.h in Headers */, D0CB06301ADC4583005E298F /* MTDatacenterAddress.h in Headers */, + D020FAFA1D994E3100F279AA /* MTHttpRequestOperation.h in Headers */, D0CB065B1ADC45CE005E298F /* MTTcpTransport.h in Headers */, D0CB061B1ADC4541005E298F /* MTEncryption.h in Headers */, D0D1A0661ADD983C007D9ED6 /* MTSetClientDhParamsResponseMessage.h in Headers */, @@ -1272,6 +1627,7 @@ D0D1A0521ADD983C007D9ED6 /* MTMsgsStateInfoMessage.h in Headers */, D0D1A0421ADD983C007D9ED6 /* MTFutureSaltsMessage.h in Headers */, D0CB064B1ADC45B1005E298F /* MTRequest.h in Headers */, + D010DB811D70B3B90012AD96 /* MTAes.h in Headers */, D0CB062C1ADC4575005E298F /* MTDatacenterAuthMessageService.h in Headers */, D0CB061C1ADC4541005E298F /* MTInternalId.h in Headers */, ); @@ -1281,7 +1637,91 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + D0CD98021D74B96400F41187 /* MTBuffer.h in Headers */, + D0CD98D71D74BAAA00F41187 /* MTHttpWorkerBehaviour.h in Headers */, + D0CD98211D74B99500F41187 /* MTInternalMessageParser.h in Headers */, + D0CD98EF1D75C0CA00F41187 /* MTTimeSyncMessageService.h in Headers */, + D0CD98981D74BA6500F41187 /* MTProto.h in Headers */, + D0CD98F31D75C0D700F41187 /* MTRequestMessageService.h in Headers */, + D0CD97D31D74B91700F41187 /* MTTime.h in Headers */, + D0CD98231D74B99500F41187 /* MTMsgAllInfoMessage.h in Headers */, + D0CD989C1D74BA6500F41187 /* MTOutgoingMessage.h in Headers */, + D0CD97F61D74B94B00F41187 /* MTRsa.h in Headers */, + D0CD98C11D74BA8300F41187 /* MTTcpTransport.h in Headers */, + D0CD98CB1D74BA9500F41187 /* MTTcpConnectionBehaviour.h in Headers */, + D0CD982D1D74B99500F41187 /* MTResPqMessage.h in Headers */, + D0CD98E91D75C0BB00F41187 /* MTMessageService.h in Headers */, + D0B0DF631DD7E7A4003BA12D /* MTBag.h in Headers */, + D0CD98691D74B9E300F41187 /* MTContext.h in Headers */, + D0CD985F1D74B9BF00F41187 /* MTSetClientDhParamsResponseMessage.h in Headers */, + D0CD98751D74BA0100F41187 /* MTDiscoverDatacenterAddressAction.h in Headers */, + D0CD98EB1D75C0C100F41187 /* MTMessageTransaction.h in Headers */, + D0CD98B71D74BA7500F41187 /* MTNetworkAvailability.h in Headers */, + D0CD989B1D74BA6500F41187 /* MTPreparedMessage.h in Headers */, + D0CD98FE1D75C0E500F41187 /* MTDropResponseContext.h in Headers */, + D0CD986D1D74B9F000F41187 /* MTTransportScheme.h in Headers */, + D0CD984C1D74B9AD00F41187 /* MTRpcError.h in Headers */, + D0CD98251D74B99500F41187 /* MTMsgDetailedInfoMessage.h in Headers */, + D0CD989D1D74BA6500F41187 /* MTIncomingMessage.h in Headers */, + D0CD98011D74B96400F41187 /* MTBadMsgNotificationMessage.h in Headers */, + D0CD98201D74B99500F41187 /* MTFutureSaltsMessage.h in Headers */, + D0CD985E1D74B9BF00F41187 /* MTServerDhParamsMessage.h in Headers */, + D0CAF2E61D75EA7A0011F558 /* MTAtomic.h in Headers */, + D0CD989A1D74BA6500F41187 /* MTTimeFixContext.h in Headers */, + D0CD98031D74B96400F41187 /* MTBufferReader.h in Headers */, + D0CD98041D74B96400F41187 /* MTDestroySessionResponseMessage.h in Headers */, + D0CD97FB1D74B95100F41187 /* MTSerialization.h in Headers */, + D0CD98651D74B9D800F41187 /* MTFileBasedKeychain.h in Headers */, + D0CD98991D74BA6500F41187 /* MTSessionInfo.h in Headers */, + D0CD97D71D74B92000F41187 /* MTTimer.h in Headers */, + D0CD98FD1D75C0E500F41187 /* MTRequestErrorContext.h in Headers */, + D0CD989E1D74BA6500F41187 /* MTMessageEncryptionKey.h in Headers */, + D0CD982B1D74B99500F41187 /* MTPingMessage.h in Headers */, + D0CD97F71D74B94B00F41187 /* MTAes.h in Headers */, + D0CD985C1D74B9BF00F41187 /* MTRpcResultMessage.h in Headers */, D0D225101B4D817B0085E26D /* MtProtoKitDynamic.h in Headers */, + D0CD98241D74B99500F41187 /* MTMsgContainerMessage.h in Headers */, + D0CD98281D74B99500F41187 /* MTMsgsStateInfoMessage.h in Headers */, + D0CD98271D74B99500F41187 /* MTMsgsAckMessage.h in Headers */, + D0CD98FF1D75C0E500F41187 /* MTApiEnvironment.h in Headers */, + D0CD988D1D74BA5200F41187 /* MTDatacenterAddressListData.h in Headers */, + D0CD985D1D74B9BF00F41187 /* MTServerDhInnerDataMessage.h in Headers */, + D0CD98611D74B9D000F41187 /* MTKeychain.h in Headers */, + D0CD98261D74B99500F41187 /* MTMsgResendReqMessage.h in Headers */, + D0CD97EE1D74B94300F41187 /* MTLogging.h in Headers */, + D0CD98FB1D75C0E500F41187 /* MTRequest.h in Headers */, + D0CAF2DA1D75E3160011F558 /* MTSubscriber.h in Headers */, + D0CD98D31D74BAA500F41187 /* MTHttpWorker.h in Headers */, + D0CD98291D74B99500F41187 /* MTMsgsStateReqMessage.h in Headers */, + D0C9322D1E095E280074F044 /* MTNetworkUsageManager.h in Headers */, + D0CD98111D74B97000F41187 /* MTExportedAuthorizationData.h in Headers */, + D0CD98FC1D75C0E500F41187 /* MTRequestContext.h in Headers */, + D0CD988C1D74BA5200F41187 /* MTDatacenterSaltInfo.h in Headers */, + D0CD98CF1D74BA9B00F41187 /* MTHttpTransport.h in Headers */, + D0CD97F31D74B94300F41187 /* MTInputStream.h in Headers */, + D0CD98221D74B99500F41187 /* MTMessage.h in Headers */, + D0CD987D1D74BA4100F41187 /* MTDatacenterAuthMessageService.h in Headers */, + D0CD988B1D74BA5200F41187 /* MTDatacenterAuthInfo.h in Headers */, + D0CD98B81D74BA7500F41187 /* MTTransport.h in Headers */, + D0CD97F21D74B94300F41187 /* MTOutputStream.h in Headers */, + D0CD98711D74B9F700F41187 /* MTDiscoverConnectionSignals.h in Headers */, + D0CD97EF1D74B94300F41187 /* MTEncryption.h in Headers */, + D0C932251E095D6A0074F044 /* MTNetworkUsageCalculationInfo.h in Headers */, + D0CD97F11D74B94300F41187 /* MTQueue.h in Headers */, + D0CD98051D74B96400F41187 /* MTDropRpcResultMessage.h in Headers */, + D0CD987C1D74BA4100F41187 /* MTDatacenterAuthAction.h in Headers */, + D0CD982A1D74B99500F41187 /* MTNewSessionCreatedMessage.h in Headers */, + D0CD987B1D74BA4100F41187 /* MTDatacenterTransferAuthAction.h in Headers */, + D0CD990B1D75C0F400F41187 /* MTResendMessageService.h in Headers */, + D020FAFC1D994E3100F279AA /* MTHttpRequestOperation.h in Headers */, + D0CD98891D74BA5200F41187 /* MTDatacenterAddress.h in Headers */, + D0CD97F01D74B94300F41187 /* MTInternalId.h in Headers */, + D0CAF2DC1D75E31B0011F558 /* MTDisposable.h in Headers */, + D0CD988A1D74BA5200F41187 /* MTDatacenterAddressSet.h in Headers */, + D0CD98B91D74BA7500F41187 /* MTTransportTransaction.h in Headers */, + D0CD982C1D74B99500F41187 /* MTPongMessage.h in Headers */, + D0CD98C61D74BA8D00F41187 /* MTTcpConnection.h in Headers */, + D0CAF2CE1D75E2580011F558 /* MTSignal.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1384,7 +1824,7 @@ D05A830A18AFB3F9007F1076 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = Telegram; TargetAttributes = { D00354641C173BF0006610DA = { @@ -1395,9 +1835,13 @@ }; D0CB05F61ADC4483005E298F = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0820; + ProvisioningStyle = Manual; }; D0D2250A1B4D817B0085E26D = { CreatedOnToolsVersion = 6.4; + DevelopmentTeam = X834Q8SBVP; + ProvisioningStyle = Manual; }; D0D225141B4D817B0085E26D = { CreatedOnToolsVersion = 6.4; @@ -1476,6 +1920,92 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D0CD98DC1D74BAEA00F41187 /* AFJSONUtilities.m in Sources */, + D0CD99021D75C0ED00F41187 /* MTRequestErrorContext.m in Sources */, + D0CD98371D74B9AA00F41187 /* MTMsgsStateInfoMessage.m in Sources */, + D0CD99011D75C0ED00F41187 /* MTRequestContext.m in Sources */, + D0CAF2DE1D75E31E0011F558 /* MTSubscriber.m in Sources */, + D0CD984E1D74B9B700F41187 /* MTRpcError.m in Sources */, + D0CD98361D74B9AA00F41187 /* MTMsgsAckMessage.m in Sources */, + D0CD97E71D74B93300F41187 /* MTAes.m in Sources */, + D0CD98EC1D75C0C500F41187 /* MTMessageTransaction.m in Sources */, + D0CD98C71D74BA9000F41187 /* MTTcpConnection.m in Sources */, + D0CD98621D74B9D500F41187 /* MTKeychain.m in Sources */, + D0CD987F1D74BA4900F41187 /* MTDatacenterAuthAction.m in Sources */, + D0CD98911D74BA5900F41187 /* MTDatacenterSaltInfo.m in Sources */, + D0CD98761D74BA0700F41187 /* MTDiscoverDatacenterAddressAction.m in Sources */, + D0CD98CC1D74BA9700F41187 /* MTTcpConnectionBehaviour.m in Sources */, + D0CD983A1D74B9AA00F41187 /* MTPingMessage.m in Sources */, + D0CD97E31D74B93300F41187 /* MTQueue.m in Sources */, + D0CAF2DD1D75E31E0011F558 /* MTDisposable.m in Sources */, + D0CD98D41D74BAA800F41187 /* MTHttpWorker.m in Sources */, + D0CD987E1D74BA4900F41187 /* MTDatacenterTransferAuthAction.m in Sources */, + D0CD988F1D74BA5900F41187 /* MTDatacenterAddressSet.m in Sources */, + D0CD98091D74B96C00F41187 /* MTDestroySessionResponseMessage.m in Sources */, + D0CD982E1D74B9AA00F41187 /* MTExportedAuthorizationData.m in Sources */, + D0CD986E1D74B9F400F41187 /* MTTransportScheme.m in Sources */, + D0CD98D81D74BAAD00F41187 /* MTHttpWorkerBehaviour.m in Sources */, + D0CD98A71D74BA6E00F41187 /* MTSessionInfo.m in Sources */, + D0CD98BA1D74BA7C00F41187 /* MTNetworkAvailability.m in Sources */, + D0CD990C1D75C0F900F41187 /* MTResendMessageService.m in Sources */, + D0CD97E61D74B93300F41187 /* MTRsa.m in Sources */, + D0CD98921D74BA5900F41187 /* MTDatacenterAddressListData.m in Sources */, + D0CD98071D74B96C00F41187 /* MTBuffer.m in Sources */, + D0CD97E01D74B93300F41187 /* MTTimer.m in Sources */, + D0CD98671D74B9DD00F41187 /* MTFileBasedKeychain.m in Sources */, + D0CD986A1D74B9E900F41187 /* MTContext.m in Sources */, + D0CD98DE1D74BAEA00F41187 /* AFHTTPRequestOperation.m in Sources */, + D0CD98081D74B96C00F41187 /* MTBufferReader.m in Sources */, + D0CD98341D74B9AA00F41187 /* MTMsgDetailedInfoMessage.m in Sources */, + D0CD984F1D74B9B700F41187 /* MTRpcResultMessage.m in Sources */, + D020FAFE1D994E3100F279AA /* MTHttpRequestOperation.m in Sources */, + D0CD98391D74B9AA00F41187 /* MTNewSessionCreatedMessage.m in Sources */, + D0CD98381D74B9AA00F41187 /* MTMsgsStateReqMessage.m in Sources */, + D0C9322F1E095E280074F044 /* MTNetworkUsageManager.m in Sources */, + D0CD98801D74BA4900F41187 /* MTDatacenterAuthMessageService.m in Sources */, + D0CD98AA1D74BA6F00F41187 /* MTOutgoingMessage.m in Sources */, + D0CD98E41D74BAF400F41187 /* GCDAsyncSocket.m in Sources */, + D0CAF2E81D75EA7E0011F558 /* MTAtomic.m in Sources */, + D0CD98901D74BA5900F41187 /* MTDatacenterAuthInfo.m in Sources */, + D0CD97E51D74B93300F41187 /* MTInputStream.m in Sources */, + D0CD98BB1D74BA7C00F41187 /* MTTransport.m in Sources */, + D0CD982F1D74B9AA00F41187 /* MTFutureSaltsMessage.m in Sources */, + D0CD98A61D74BA6E00F41187 /* MTProto.m in Sources */, + D0CD98331D74B9AA00F41187 /* MTMsgContainerMessage.m in Sources */, + D0CD980A1D74B96C00F41187 /* MTDropRpcResultMessage.m in Sources */, + D0CD98511D74B9B700F41187 /* MTServerDhParamsMessage.m in Sources */, + D0CD97E21D74B93300F41187 /* MTEncryption.m in Sources */, + D0CD97E11D74B93300F41187 /* MTLogging.m in Sources */, + D0CD98AB1D74BA6F00F41187 /* MTIncomingMessage.m in Sources */, + D0CD98501D74B9B700F41187 /* MTServerDhInnerDataMessage.m in Sources */, + D0CD99031D75C0ED00F41187 /* MTDropResponseContext.m in Sources */, + D0CD983B1D74B9AA00F41187 /* MTPongMessage.m in Sources */, + D0CD98BC1D74BA7C00F41187 /* MTTransportTransaction.m in Sources */, + D0CD98F41D75C0DD00F41187 /* MTRequestMessageService.m in Sources */, + D0CD98A81D74BA6E00F41187 /* MTTimeFixContext.m in Sources */, + D0CD98721D74B9F900F41187 /* MTDiscoverConnectionSignals.m in Sources */, + D0CD98061D74B96C00F41187 /* MTBadMsgNotificationMessage.m in Sources */, + D0CD98311D74B9AA00F41187 /* MTMessage.m in Sources */, + D0CD99001D75C0ED00F41187 /* MTRequest.m in Sources */, + D0CD98DD1D74BAEA00F41187 /* AFHTTPClient.m in Sources */, + D0CD98F01D75C0D200F41187 /* MTTimeSyncMessageService.m in Sources */, + D0CD98A91D74BA6F00F41187 /* MTPreparedMessage.m in Sources */, + D0B0DF5E1DD7E75B003BA12D /* MTBag.m in Sources */, + D0CD99041D75C0ED00F41187 /* MTApiEnvironment.m in Sources */, + D0CD983C1D74B9AA00F41187 /* MTResPqMessage.m in Sources */, + D0CD98C41D74BA8A00F41187 /* MTTcpTransport.m in Sources */, + D0CD98AC1D74BA6F00F41187 /* MTMessageEncryptionKey.m in Sources */, + D0CD98301D74B9AA00F41187 /* MTInternalMessageParser.m in Sources */, + D0CD98DF1D74BAEA00F41187 /* AFURLConnectionOperation.m in Sources */, + D0CD98321D74B9AA00F41187 /* MTMsgAllInfoMessage.m in Sources */, + D0CD97D51D74B91C00F41187 /* MTTime.m in Sources */, + D0CD98351D74B9AA00F41187 /* MTMsgResendReqMessage.m in Sources */, + D0CD97E41D74B93300F41187 /* MTOutputStream.m in Sources */, + D0CD988E1D74BA5900F41187 /* MTDatacenterAddress.m in Sources */, + D0CD98D01D74BAA200F41187 /* MTHttpTransport.m in Sources */, + D0CD98521D74B9B700F41187 /* MTSetClientDhParamsResponseMessage.m in Sources */, + D0C932271E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m in Sources */, + D0CAF2CF1D75E25B0011F558 /* MTSignal.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1501,6 +2031,7 @@ D0CB062E1ADC457B005E298F /* MTDatacenterAuthAction.m in Sources */, D0CB06441ADC4599005E298F /* MTIncomingMessage.m in Sources */, D0D1A0511ADD983C007D9ED6 /* MTMsgsAckMessage.m in Sources */, + D010DB821D70B3B90012AD96 /* MTAes.m in Sources */, D0CB066F1ADC49FF005E298F /* AFHTTPRequestOperation.m in Sources */, D0D1A06C1ADD987A007D9ED6 /* MTDatacenterAddressListData.m in Sources */, D09A59591B582EFF00FC3724 /* MTFileBasedKeychain.m in Sources */, @@ -1520,17 +2051,22 @@ D0D1A0391ADD983C007D9ED6 /* MTBuffer.m in Sources */, D0D1A0591ADD983C007D9ED6 /* MTPingMessage.m in Sources */, D0CB06361ADC4588005E298F /* MTDatacenterAuthInfo.m in Sources */, + D020FAFD1D994E3100F279AA /* MTHttpRequestOperation.m in Sources */, D0CB062D1ADC457B005E298F /* MTDatacenterTransferAuthAction.m in Sources */, D0D1A04F1ADD983C007D9ED6 /* MTMsgResendReqMessage.m in Sources */, + D0C9322E1E095E280074F044 /* MTNetworkUsageManager.m in Sources */, D0D1A0371ADD983C007D9ED6 /* MTBadMsgNotificationMessage.m in Sources */, D0CB06691ADC45DA005E298F /* MTHttpWorkerBehaviour.m in Sources */, D0CB066E1ADC49FF005E298F /* AFHTTPClient.m in Sources */, + D0CAF2E41D75E7F30011F558 /* MTAtomic.m in Sources */, D0CB06611ADC45DA005E298F /* MTNetworkAvailability.m in Sources */, D0D1A0611ADD983C007D9ED6 /* MTRpcResultMessage.m in Sources */, D0CB06131ADC44B7005E298F /* MTEncryption.m in Sources */, + D0CAF2D41D75E26D0011F558 /* MTSubscriber.m in Sources */, D0CB06531ADC45BA005E298F /* MTRequestContext.m in Sources */, D0D1A03F1ADD983C007D9ED6 /* MTDropRpcResultMessage.m in Sources */, D0D1A0651ADD983C007D9ED6 /* MTServerDhParamsMessage.m in Sources */, + D0CAF2D81D75E2840011F558 /* MTDisposable.m in Sources */, D0CB06541ADC45BA005E298F /* MTRequestErrorContext.m in Sources */, D0D1A05B1ADD983C007D9ED6 /* MTPongMessage.m in Sources */, D0CB06241ADC455C005E298F /* MTContext.m in Sources */, @@ -1547,6 +2083,7 @@ D0CB06401ADC4599005E298F /* MTSessionInfo.m in Sources */, D0CB06411ADC4599005E298F /* MTTimeFixContext.m in Sources */, D0CB06291ADC456E005E298F /* MTDiscoverDatacenterAddressAction.m in Sources */, + D0B0DF5D1DD7E75B003BA12D /* MTBag.m in Sources */, D0D1A0551ADD983C007D9ED6 /* MTMsgsStateReqMessage.m in Sources */, D0D1A0411ADD983C007D9ED6 /* MTExportedAuthorizationData.m in Sources */, D0CB06571ADC45BA005E298F /* MTResendMessageService.m in Sources */, @@ -1557,8 +2094,11 @@ D0D1A03D1ADD983C007D9ED6 /* MTDestroySessionResponseMessage.m in Sources */, D0CB06151ADC44B7005E298F /* MTOutputStream.m in Sources */, D0D1A0491ADD983C007D9ED6 /* MTMsgAllInfoMessage.m in Sources */, + D010DB7E1D70ABEE0012AD96 /* MTRsa.m in Sources */, D0D1A0631ADD983C007D9ED6 /* MTServerDhInnerDataMessage.m in Sources */, D0D1A0571ADD983C007D9ED6 /* MTNewSessionCreatedMessage.m in Sources */, + D0C932261E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m in Sources */, + D0CAF2CC1D75E24C0011F558 /* MTSignal.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1566,6 +2106,92 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D0CD98E01D74BAEB00F41187 /* AFJSONUtilities.m in Sources */, + D0CD99071D75C0ED00F41187 /* MTRequestErrorContext.m in Sources */, + D0CD98461D74B9AA00F41187 /* MTMsgsStateInfoMessage.m in Sources */, + D0CD99061D75C0ED00F41187 /* MTRequestContext.m in Sources */, + D0CAF2E01D75E31F0011F558 /* MTSubscriber.m in Sources */, + D0CD98531D74B9B700F41187 /* MTRpcError.m in Sources */, + D0CD98451D74B9AA00F41187 /* MTMsgsAckMessage.m in Sources */, + D0CD97DF1D74B93100F41187 /* MTAes.m in Sources */, + D0CD98ED1D75C0C500F41187 /* MTMessageTransaction.m in Sources */, + D0CD98C81D74BA9100F41187 /* MTTcpConnection.m in Sources */, + D0CD98631D74B9D500F41187 /* MTKeychain.m in Sources */, + D0CD98821D74BA4900F41187 /* MTDatacenterAuthAction.m in Sources */, + D0CD98961D74BA5A00F41187 /* MTDatacenterSaltInfo.m in Sources */, + D0CD98771D74BA0700F41187 /* MTDiscoverDatacenterAddressAction.m in Sources */, + D0CD98CD1D74BA9700F41187 /* MTTcpConnectionBehaviour.m in Sources */, + D0CD98491D74B9AA00F41187 /* MTPingMessage.m in Sources */, + D0CD97DB1D74B93100F41187 /* MTQueue.m in Sources */, + D0CAF2DF1D75E31F0011F558 /* MTDisposable.m in Sources */, + D0CD98D51D74BAA800F41187 /* MTHttpWorker.m in Sources */, + D0CD98811D74BA4900F41187 /* MTDatacenterTransferAuthAction.m in Sources */, + D0CD98941D74BA5A00F41187 /* MTDatacenterAddressSet.m in Sources */, + D0CD980E1D74B96C00F41187 /* MTDestroySessionResponseMessage.m in Sources */, + D0CD983D1D74B9AA00F41187 /* MTExportedAuthorizationData.m in Sources */, + D0CD986F1D74B9F500F41187 /* MTTransportScheme.m in Sources */, + D0CD98D91D74BAAD00F41187 /* MTHttpWorkerBehaviour.m in Sources */, + D0CD98AE1D74BA6F00F41187 /* MTSessionInfo.m in Sources */, + D0CD98BD1D74BA7C00F41187 /* MTNetworkAvailability.m in Sources */, + D0CD990D1D75C0F900F41187 /* MTResendMessageService.m in Sources */, + D0CD97DE1D74B93100F41187 /* MTRsa.m in Sources */, + D0CD98971D74BA5A00F41187 /* MTDatacenterAddressListData.m in Sources */, + D0CD980C1D74B96C00F41187 /* MTBuffer.m in Sources */, + D0CD97D81D74B93100F41187 /* MTTimer.m in Sources */, + D0CD98661D74B9DD00F41187 /* MTFileBasedKeychain.m in Sources */, + D0CD986B1D74B9E900F41187 /* MTContext.m in Sources */, + D0CD98E21D74BAEB00F41187 /* AFHTTPRequestOperation.m in Sources */, + D0CD980D1D74B96C00F41187 /* MTBufferReader.m in Sources */, + D0CD98431D74B9AA00F41187 /* MTMsgDetailedInfoMessage.m in Sources */, + D0CD98541D74B9B700F41187 /* MTRpcResultMessage.m in Sources */, + D020FAFF1D994E3100F279AA /* MTHttpRequestOperation.m in Sources */, + D0CD98481D74B9AA00F41187 /* MTNewSessionCreatedMessage.m in Sources */, + D0CD98471D74B9AA00F41187 /* MTMsgsStateReqMessage.m in Sources */, + D0C932301E095E280074F044 /* MTNetworkUsageManager.m in Sources */, + D0CD98831D74BA4900F41187 /* MTDatacenterAuthMessageService.m in Sources */, + D0CD98B11D74BA6F00F41187 /* MTOutgoingMessage.m in Sources */, + D0CD98E51D74BAF400F41187 /* GCDAsyncSocket.m in Sources */, + D0CAF2E71D75EA7E0011F558 /* MTAtomic.m in Sources */, + D0CD98951D74BA5A00F41187 /* MTDatacenterAuthInfo.m in Sources */, + D0CD97DD1D74B93100F41187 /* MTInputStream.m in Sources */, + D0CD98BE1D74BA7C00F41187 /* MTTransport.m in Sources */, + D0CD983E1D74B9AA00F41187 /* MTFutureSaltsMessage.m in Sources */, + D0CD98AD1D74BA6F00F41187 /* MTProto.m in Sources */, + D0CD98421D74B9AA00F41187 /* MTMsgContainerMessage.m in Sources */, + D0CD980F1D74B96C00F41187 /* MTDropRpcResultMessage.m in Sources */, + D0CD98561D74B9B700F41187 /* MTServerDhParamsMessage.m in Sources */, + D0CD97DA1D74B93100F41187 /* MTEncryption.m in Sources */, + D0CD97D91D74B93100F41187 /* MTLogging.m in Sources */, + D0CD98B21D74BA6F00F41187 /* MTIncomingMessage.m in Sources */, + D0CD98551D74B9B700F41187 /* MTServerDhInnerDataMessage.m in Sources */, + D0CD99081D75C0ED00F41187 /* MTDropResponseContext.m in Sources */, + D0CD984A1D74B9AA00F41187 /* MTPongMessage.m in Sources */, + D0CD98BF1D74BA7C00F41187 /* MTTransportTransaction.m in Sources */, + D0CD98F51D75C0DD00F41187 /* MTRequestMessageService.m in Sources */, + D0CD98AF1D74BA6F00F41187 /* MTTimeFixContext.m in Sources */, + D0CD98731D74B9F900F41187 /* MTDiscoverConnectionSignals.m in Sources */, + D0CD980B1D74B96C00F41187 /* MTBadMsgNotificationMessage.m in Sources */, + D0CD98401D74B9AA00F41187 /* MTMessage.m in Sources */, + D0CD99051D75C0ED00F41187 /* MTRequest.m in Sources */, + D0CD98E11D74BAEB00F41187 /* AFHTTPClient.m in Sources */, + D0CD98F11D75C0D300F41187 /* MTTimeSyncMessageService.m in Sources */, + D0CD98B01D74BA6F00F41187 /* MTPreparedMessage.m in Sources */, + D0B0DF5F1DD7E75B003BA12D /* MTBag.m in Sources */, + D0CD99091D75C0ED00F41187 /* MTApiEnvironment.m in Sources */, + D0CD984B1D74B9AA00F41187 /* MTResPqMessage.m in Sources */, + D0CD98C31D74BA8A00F41187 /* MTTcpTransport.m in Sources */, + D0CD98B31D74BA6F00F41187 /* MTMessageEncryptionKey.m in Sources */, + D0CD983F1D74B9AA00F41187 /* MTInternalMessageParser.m in Sources */, + D0CD98E31D74BAEB00F41187 /* AFURLConnectionOperation.m in Sources */, + D0CD98411D74B9AA00F41187 /* MTMsgAllInfoMessage.m in Sources */, + D0CD97D41D74B91B00F41187 /* MTTime.m in Sources */, + D0CD98441D74B9AA00F41187 /* MTMsgResendReqMessage.m in Sources */, + D0CD97DC1D74B93100F41187 /* MTOutputStream.m in Sources */, + D0CD98931D74BA5A00F41187 /* MTDatacenterAddress.m in Sources */, + D0CD98D11D74BAA200F41187 /* MTHttpTransport.m in Sources */, + D0CD98571D74B9B700F41187 /* MTSetClientDhParamsResponseMessage.m in Sources */, + D0C932281E095D6A0074F044 /* MTNetworkUsageCalculationInfo.m in Sources */, + D0CAF2D01D75E25B0011F558 /* MTSignal.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1665,17 +2291,24 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_MODULES_AUTOLINK = NO; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1689,7 +2322,8 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 7.1; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; SDKROOT = iphoneos; }; name = Debug; @@ -1702,17 +2336,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_MODULES_AUTOLINK = NO; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -1720,6 +2360,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 7.1; + PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; @@ -1743,13 +2384,20 @@ "DEBUG=1", "$(inherited)", ); + HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/openssl"; INFOPLIST_FILE = MtProtoKitMac/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/OSX", + ); + MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = "-DMtProtoKitMacFramework=1"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -1773,12 +2421,19 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_VERSION = A; GCC_NO_COMMON_BLOCKS = YES; + HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/openssl"; INFOPLIST_FILE = MtProtoKitMac/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/OSX", + ); + MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; + OTHER_CFLAGS = "-DMtProtoKitMacFramework=1"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -1787,12 +2442,222 @@ }; name = Release; }; + D096C2D21CC3C664006D814E /* Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_MODULES_AUTOLINK = NO; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Hockeyapp; + }; + D096C2D31CC3C664006D814E /* Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_BITCODE = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Telegraph-dzhgyeoibunjpxfckifwvbawfdmi/Build/Products/Debug-iphoneos", + ); + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "MtProtoKitiOS/MtProtoKit-Prefix.pch"; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(PROJECT_DIR)/openssl", + ); + INFOPLIST_FILE = MtProtoKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/iOS", + ); + MACH_O_TYPE = staticlib; + MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-lz"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_MODULE_NAME = MtProtoKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = X834Q8SBVP/; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Hockeyapp; + }; + D096C2D41CC3C664006D814E /* Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_UNREACHABLE_CODE = YES; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_VERSION = A; + GCC_NO_COMMON_BLOCKS = YES; + HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/openssl"; + INFOPLIST_FILE = MtProtoKitMac/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/OSX", + ); + MACH_O_TYPE = mh_dylib; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_CFLAGS = "-DMtProtoKitMacFramework=1"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Hockeyapp; + }; + D096C2D51CC3C664006D814E /* Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DEPLOYMENT_POSTPROCESSING = NO; + DEVELOPMENT_TEAM = X834Q8SBVP; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/openssl"; + INFOPLIST_FILE = MtProtoKitDynamic/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/iOS", + ); + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_CFLAGS = "-DMtProtoKitDynamicFramework=1"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SEPARATE_STRIP = NO; + SKIP_INSTALL = YES; + STRIPFLAGS = ""; + STRIP_STYLE = debugging; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Hockeyapp; + }; + D096C2D61CC3C664006D814E /* Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_UNREACHABLE_CODE = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = MtProtoKitDynamicTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Hockeyapp; + }; + D096C2D71CC3C664006D814E /* Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_UNREACHABLE_CODE = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = MtProtoKitStabilityTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = org.telegram.MtProtoKitStabilityTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Hockeyapp; + }; D0CB060A1ADC4483005E298F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_MODULES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; @@ -1819,7 +2684,7 @@ ); INFOPLIST_FILE = MtProtoKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -1827,9 +2692,15 @@ ); MACH_O_TYPE = staticlib; MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-lz"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_MODULE_NAME = MtProtoKit; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = X834Q8SBVP/; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1839,10 +2710,11 @@ D0CB060B1ADC4483005E298F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_MODULES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; @@ -1865,7 +2737,7 @@ ); INFOPLIST_FILE = MtProtoKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -1873,9 +2745,14 @@ ); MACH_O_TYPE = staticlib; MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-lz"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_MODULE_NAME = MtProtoKit; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = X834Q8SBVP/; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1885,11 +2762,16 @@ D0D2251E1B4D817B0085E26D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_WARN_UNREACHABLE_CODE = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; + DEPLOYMENT_POSTPROCESSING = NO; + DEVELOPMENT_TEAM = X834Q8SBVP; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1899,14 +2781,25 @@ "DEBUG=1", "$(inherited)", ); + HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/openssl"; INFOPLIST_FILE = MtProtoKitDynamic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.4; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/iOS", + ); MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = "-DMtProtoKitDynamicFramework=1"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SEPARATE_STRIP = NO; SKIP_INSTALL = YES; + STRIPFLAGS = ""; + STRIP_STYLE = debugging; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1916,24 +2809,39 @@ D0D2251F1B4D817B0085E26D /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_WARN_UNREACHABLE_CODE = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; + DEPLOYMENT_POSTPROCESSING = NO; + DEVELOPMENT_TEAM = X834Q8SBVP; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; + HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/openssl"; INFOPLIST_FILE = MtProtoKitDynamic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.4; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/openssl/iOS", + ); MTL_ENABLE_DEBUG_INFO = NO; + OTHER_CFLAGS = "-DMtProtoKitDynamicFramework=1"; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SEPARATE_STRIP = NO; SKIP_INSTALL = YES; + STRIPFLAGS = ""; + STRIP_STYLE = debugging; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1961,6 +2869,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -1982,6 +2891,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "org.telegram.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -1994,14 +2904,17 @@ buildConfigurations = ( D003546D1C173BF0006610DA /* Debug */, D003546E1C173BF0006610DA /* Release */, + D096C2D71CC3C664006D814E /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; D05A830D18AFB3F9007F1076 /* Build configuration list for PBXProject "MtProtoKit" */ = { isa = XCConfigurationList; buildConfigurations = ( D05A833A18AFB3F9007F1076 /* Debug */, D05A833B18AFB3F9007F1076 /* Release */, + D096C2D21CC3C664006D814E /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -2011,6 +2924,7 @@ buildConfigurations = ( D079ABAA1AF39B8000076F59 /* Debug */, D079ABAB1AF39B8000076F59 /* Release */, + D096C2D41CC3C664006D814E /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -2020,6 +2934,7 @@ buildConfigurations = ( D0CB060A1ADC4483005E298F /* Debug */, D0CB060B1ADC4483005E298F /* Release */, + D096C2D31CC3C664006D814E /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -2029,6 +2944,7 @@ buildConfigurations = ( D0D2251E1B4D817B0085E26D /* Debug */, D0D2251F1B4D817B0085E26D /* Release */, + D096C2D51CC3C664006D814E /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -2038,6 +2954,7 @@ buildConfigurations = ( D0D225201B4D817B0085E26D /* Debug */, D0D225211B4D817B0085E26D /* Release */, + D096C2D61CC3C664006D814E /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/MtProtoKitDynamic/Info.plist b/MtProtoKitDynamic/Info.plist index f6228f96e7..d3de8eefb6 100644 --- a/MtProtoKitDynamic/Info.plist +++ b/MtProtoKitDynamic/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.telegram.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/MtProtoKitDynamic/MtProtoKitDynamic.h b/MtProtoKitDynamic/MtProtoKitDynamic.h index d044d8de89..462ddc06e6 100644 --- a/MtProtoKitDynamic/MtProtoKitDynamic.h +++ b/MtProtoKitDynamic/MtProtoKitDynamic.h @@ -14,6 +14,60 @@ FOUNDATION_EXPORT double MtProtoKitDynamicVersionNumber; //! Project version string for MtProtoKitDynamic. FOUNDATION_EXPORT const unsigned char MtProtoKitDynamicVersionString[]; -// In this header, you should import all the public headers of your framework using statements like #import - +#ifndef MtProtoKitDynamicFramework +# define MtProtoKitDynamicFramework 1 +#endif +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import diff --git a/MtProtoKitDynamicTests/Info.plist b/MtProtoKitDynamicTests/Info.plist index 29dacae6b5..ba72822e87 100644 --- a/MtProtoKitDynamicTests/Info.plist +++ b/MtProtoKitDynamicTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.telegram.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/MtProtoKitMac/Info.plist b/MtProtoKitMac/Info.plist index 10172f8a1d..fb8e650960 100644 --- a/MtProtoKitMac/Info.plist +++ b/MtProtoKitMac/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.telegram.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/MtProtoKitMac/MtProtoKitMac.h b/MtProtoKitMac/MtProtoKitMac.h index 54099b1d89..eb0d20e02b 100644 --- a/MtProtoKitMac/MtProtoKitMac.h +++ b/MtProtoKitMac/MtProtoKitMac.h @@ -14,6 +14,60 @@ FOUNDATION_EXPORT double MtProtoKitMacVersionNumber; //! Project version string for MtProtoKitMac. FOUNDATION_EXPORT const unsigned char MtProtoKitMacVersionString[]; -// In this header, you should import all the public headers of your framework using statements like #import - +#ifndef MtProtoKitMacFramework +# define MtProtoKitMacFramework 1 +#endif +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import diff --git a/MtProtoKitOSX/MtProtoKitOSX-Prefix.pch b/MtProtoKitOSX/MtProtoKitOSX-Prefix.pch index bff8e7de91..2d9f72e2f7 100644 --- a/MtProtoKitOSX/MtProtoKitOSX-Prefix.pch +++ b/MtProtoKitOSX/MtProtoKitOSX-Prefix.pch @@ -8,4 +8,3 @@ #import #endif -#import diff --git a/MtProtoKitiOS/MtProtoKit-Prefix.pch b/MtProtoKitiOS/MtProtoKit-Prefix.pch index 023f7f37dd..1bcc23b7ad 100644 --- a/MtProtoKitiOS/MtProtoKit-Prefix.pch +++ b/MtProtoKitiOS/MtProtoKit-Prefix.pch @@ -8,4 +8,3 @@ #import #endif -#import diff --git a/build/MtProtoKit.build/Debug/MtProtoKit OSX.build/dgph b/build/MtProtoKit.build/Debug/MtProtoKit OSX.build/dgph deleted file mode 100644 index f82cc6cfe4..0000000000 Binary files a/build/MtProtoKit.build/Debug/MtProtoKit OSX.build/dgph and /dev/null differ diff --git a/openssl/iOS/libcrypto.a b/openssl/iOS/libcrypto.a index cb8625e581..16b472ba08 100644 Binary files a/openssl/iOS/libcrypto.a and b/openssl/iOS/libcrypto.a differ diff --git a/openssl/openssl/aes.h b/openssl/openssl/aes.h index 87bf60f6f2..faa66c4914 100644 --- a/openssl/openssl/aes.h +++ b/openssl/openssl/aes.h @@ -1,4 +1,4 @@ -/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ +/* crypto/aes/aes.h */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * diff --git a/openssl/openssl/async.h b/openssl/openssl/async.h new file mode 100644 index 0000000000..5b2e496dbd --- /dev/null +++ b/openssl/openssl/async.h @@ -0,0 +1,98 @@ +/* + * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include + +#ifndef HEADER_ASYNC_H +# define HEADER_ASYNC_H + +#if defined(_WIN32) +# if defined(BASETYPES) || defined(_WINDEF_H) +/* application has to include to use this */ +#define OSSL_ASYNC_FD HANDLE +#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE +# endif +#else +#define OSSL_ASYNC_FD int +#define OSSL_BAD_ASYNC_FD -1 +#endif + + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct async_job_st ASYNC_JOB; +typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; + +#define ASYNC_ERR 0 +#define ASYNC_NO_JOBS 1 +#define ASYNC_PAUSE 2 +#define ASYNC_FINISH 3 + +int ASYNC_init_thread(size_t max_size, size_t init_size); +void ASYNC_cleanup_thread(void); + +#ifdef OSSL_ASYNC_FD +ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); +void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); +int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, + OSSL_ASYNC_FD fd, + void *custom_data, + void (*cleanup)(ASYNC_WAIT_CTX *, const void *, + OSSL_ASYNC_FD, void *)); +int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, + OSSL_ASYNC_FD *fd, void **custom_data); +int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, + size_t *numfds); +int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, + size_t *numaddfds, OSSL_ASYNC_FD *delfd, + size_t *numdelfds); +int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); +#endif + +int ASYNC_is_capable(void); + +int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, + int (*func)(void *), void *args, size_t size); +int ASYNC_pause_job(void); + +ASYNC_JOB *ASYNC_get_current_job(void); +ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); +void ASYNC_block_pause(void); +void ASYNC_unblock_pause(void); + +/* BEGIN ERROR CODES */ +/* + * The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +int ERR_load_ASYNC_strings(void); + +/* Error codes for the ASYNC functions. */ + +/* Function codes. */ +# define ASYNC_F_ASYNC_CTX_NEW 100 +# define ASYNC_F_ASYNC_INIT_THREAD 101 +# define ASYNC_F_ASYNC_JOB_NEW 102 +# define ASYNC_F_ASYNC_PAUSE_JOB 103 +# define ASYNC_F_ASYNC_START_FUNC 104 +# define ASYNC_F_ASYNC_START_JOB 105 + +/* Reason codes. */ +# define ASYNC_R_FAILED_TO_SET_POOL 101 +# define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 +# define ASYNC_R_INIT_FAILED 105 +# define ASYNC_R_INVALID_POOL_SIZE 103 + +# ifdef __cplusplus +} +# endif +#endif diff --git a/openssl/openssl/bio.h b/openssl/openssl/bio.h index f78796b069..6790aed28e 100644 --- a/openssl/openssl/bio.h +++ b/openssl/openssl/bio.h @@ -479,11 +479,11 @@ struct bio_dgram_sctp_prinfo { # define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) # define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) # define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) -# define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0) +# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL) # define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) -/* BIO_s_accept_socket() */ +/* BIO_s_accept() */ # define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) # define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) /* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ @@ -496,6 +496,7 @@ struct bio_dgram_sctp_prinfo { # define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) # define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) +/* BIO_s_accept() and BIO_s_connect() */ # define BIO_do_connect(b) BIO_do_handshake(b) # define BIO_do_accept(b) BIO_do_handshake(b) # define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) @@ -515,12 +516,15 @@ struct bio_dgram_sctp_prinfo { # define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) # define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) +/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */ # define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) # define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) +/* BIO_s_file() */ # define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) # define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) +/* BIO_s_fd() and BIO_s_file() */ # define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) # define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) @@ -685,7 +689,7 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret); BIO_METHOD *BIO_s_mem(void); -BIO *BIO_new_mem_buf(void *buf, int len); +BIO *BIO_new_mem_buf(const void *buf, int len); BIO_METHOD *BIO_s_socket(void); BIO_METHOD *BIO_s_connect(void); BIO_METHOD *BIO_s_accept(void); diff --git a/openssl/openssl/bn.h b/openssl/openssl/bn.h index 5696965e9a..86264ae631 100644 --- a/openssl/openssl/bn.h +++ b/openssl/openssl/bn.h @@ -125,6 +125,7 @@ #ifndef HEADER_BN_H # define HEADER_BN_H +# include # include # ifndef OPENSSL_NO_FP_API # include /* FILE */ @@ -721,8 +722,17 @@ const BIGNUM *BN_get0_nist_prime_521(void); /* library internal functions */ -# define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ - (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) +# define bn_expand(a,bits) \ + ( \ + bits > (INT_MAX - BN_BITS2 + 1) ? \ + NULL \ + : \ + (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \ + (a) \ + : \ + bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \ + ) + # define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) BIGNUM *bn_expand2(BIGNUM *a, int words); # ifndef OPENSSL_NO_DEPRECATED diff --git a/openssl/openssl/buffer.h b/openssl/openssl/buffer.h index c343dd772f..efd240a5f9 100644 --- a/openssl/openssl/buffer.h +++ b/openssl/openssl/buffer.h @@ -86,7 +86,13 @@ int BUF_MEM_grow(BUF_MEM *str, size_t len); int BUF_MEM_grow_clean(BUF_MEM *str, size_t len); size_t BUF_strnlen(const char *str, size_t maxlen); char *BUF_strdup(const char *str); + +/* + * Like strndup, but in addition, explicitly guarantees to never read past the + * first |siz| bytes of |str|. + */ char *BUF_strndup(const char *str, size_t siz); + void *BUF_memdup(const void *data, size_t siz); void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); diff --git a/openssl/openssl/camellia.h b/openssl/openssl/camellia.h index 9be7c0fd99..45e8d25b1d 100644 --- a/openssl/openssl/camellia.h +++ b/openssl/openssl/camellia.h @@ -1,4 +1,4 @@ -/* crypto/camellia/camellia.h -*- mode:C; c-file-style: "eay" -*- */ +/* crypto/camellia/camellia.h */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * diff --git a/openssl/openssl/comp.h b/openssl/openssl/comp.h index 406c428aae..60a073404e 100644 --- a/openssl/openssl/comp.h +++ b/openssl/openssl/comp.h @@ -4,6 +4,10 @@ # include +# ifdef OPENSSL_NO_COMP +# error COMP is disabled. +# endif + #ifdef __cplusplus extern "C" { #endif diff --git a/openssl/openssl/crypto.h b/openssl/openssl/crypto.h index c450d7a3c3..6c644ce12a 100644 --- a/openssl/openssl/crypto.h +++ b/openssl/openssl/crypto.h @@ -628,7 +628,7 @@ void OPENSSL_init(void); * into a defined order as the return value when a != b is undefined, other * than to be non-zero. */ -int CRYPTO_memcmp(const void *a, const void *b, size_t len); +int CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len); /* BEGIN ERROR CODES */ /* diff --git a/openssl/openssl/ct.h b/openssl/openssl/ct.h new file mode 100644 index 0000000000..6c63265257 --- /dev/null +++ b/openssl/openssl/ct.h @@ -0,0 +1,518 @@ +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef HEADER_CT_H +# define HEADER_CT_H + +# include + +# ifndef OPENSSL_NO_CT +# include +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + + +/* Minimum RSA key size, from RFC6962 */ +# define SCT_MIN_RSA_BITS 2048 + +/* All hashes are SHA256 in v1 of Certificate Transparency */ +# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH + +typedef enum { + CT_LOG_ENTRY_TYPE_NOT_SET = -1, + CT_LOG_ENTRY_TYPE_X509 = 0, + CT_LOG_ENTRY_TYPE_PRECERT = 1 +} ct_log_entry_type_t; + +typedef enum { + SCT_VERSION_NOT_SET = -1, + SCT_VERSION_V1 = 0 +} sct_version_t; + +typedef enum { + SCT_SOURCE_UNKNOWN, + SCT_SOURCE_TLS_EXTENSION, + SCT_SOURCE_X509V3_EXTENSION, + SCT_SOURCE_OCSP_STAPLED_RESPONSE +} sct_source_t; + +typedef enum { + SCT_VALIDATION_STATUS_NOT_SET, + SCT_VALIDATION_STATUS_UNKNOWN_LOG, + SCT_VALIDATION_STATUS_VALID, + SCT_VALIDATION_STATUS_INVALID, + SCT_VALIDATION_STATUS_UNVERIFIED, + SCT_VALIDATION_STATUS_UNKNOWN_VERSION +} sct_validation_status_t; + +DEFINE_STACK_OF(SCT) +DEFINE_STACK_OF(CTLOG) + +/****************************************** + * CT policy evaluation context functions * + ******************************************/ + +/* + * Creates a new, empty policy evaluation context. + * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished + * with the CT_POLICY_EVAL_CTX. + */ +CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void); + +/* Deletes a policy evaluation context and anything it owns. */ +void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx); + +/* Gets the peer certificate that the SCTs are for */ +X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx); + +/* + * Sets the certificate associated with the received SCTs. + * Increments the reference count of cert. + * Returns 1 on success, 0 otherwise. + */ +int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert); + +/* Gets the issuer of the aforementioned certificate */ +X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx); + +/* + * Sets the issuer of the certificate associated with the received SCTs. + * Increments the reference count of issuer. + * Returns 1 on success, 0 otherwise. + */ +int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer); + +/* Gets the CT logs that are trusted sources of SCTs */ +const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx); + +/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */ +void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, + CTLOG_STORE *log_store); + +/***************** + * SCT functions * + *****************/ + +/* + * Creates a new, blank SCT. + * The caller is responsible for calling SCT_free when finished with the SCT. + */ +SCT *SCT_new(void); + +/* + * Creates a new SCT from some base64-encoded strings. + * The caller is responsible for calling SCT_free when finished with the SCT. + */ +SCT *SCT_new_from_base64(unsigned char version, + const char *logid_base64, + ct_log_entry_type_t entry_type, + uint64_t timestamp, + const char *extensions_base64, + const char *signature_base64); + +/* + * Frees the SCT and the underlying data structures. + */ +void SCT_free(SCT *sct); + +/* + * Free a stack of SCTs, and the underlying SCTs themselves. + * Intended to be compatible with X509V3_EXT_FREE. + */ +void SCT_LIST_free(STACK_OF(SCT) *a); + +/* + * Returns the version of the SCT. + */ +sct_version_t SCT_get_version(const SCT *sct); + +/* + * Set the version of an SCT. + * Returns 1 on success, 0 if the version is unrecognized. + */ +__owur int SCT_set_version(SCT *sct, sct_version_t version); + +/* + * Returns the log entry type of the SCT. + */ +ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct); + +/* + * Set the log entry type of an SCT. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type); + +/* + * Gets the ID of the log that an SCT came from. + * Ownership of the log ID remains with the SCT. + * Returns the length of the log ID. + */ +size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id); + +/* + * Set the log ID of an SCT to point directly to the *log_id specified. + * The SCT takes ownership of the specified pointer. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); + +/* + * Set the log ID of an SCT. + * This makes a copy of the log_id. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, + size_t log_id_len); + +/* + * Returns the timestamp for the SCT (epoch time in milliseconds). + */ +uint64_t SCT_get_timestamp(const SCT *sct); + +/* + * Set the timestamp of an SCT (epoch time in milliseconds). + */ +void SCT_set_timestamp(SCT *sct, uint64_t timestamp); + +/* + * Return the NID for the signature used by the SCT. + * For CT v1, this will be either NID_sha256WithRSAEncryption or + * NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset). + */ +int SCT_get_signature_nid(const SCT *sct); + +/* + * Set the signature type of an SCT + * For CT v1, this should be either NID_sha256WithRSAEncryption or + * NID_ecdsa_with_SHA256. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set_signature_nid(SCT *sct, int nid); + +/* + * Set *ext to point to the extension data for the SCT. ext must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext); + +/* + * Set the extensions of an SCT to point directly to the *ext specified. + * The SCT takes ownership of the specified pointer. + */ +void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len); + +/* + * Set the extensions of an SCT. + * This takes a copy of the ext. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, + size_t ext_len); + +/* + * Set *sig to point to the signature for the SCT. sig must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_signature(const SCT *sct, unsigned char **sig); + +/* + * Set the signature of an SCT to point directly to the *sig specified. + * The SCT takes ownership of the specified pointer. + */ +void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len); + +/* + * Set the signature of an SCT to be a copy of the *sig specified. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, + size_t sig_len); + +/* + * The origin of this SCT, e.g. TLS extension, OCSP response, etc. + */ +sct_source_t SCT_get_source(const SCT *sct); + +/* + * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set_source(SCT *sct, sct_source_t source); + +/* + * Returns a text string describing the validation status of |sct|. + */ +const char *SCT_validation_status_string(const SCT *sct); + +/* + * Pretty-prints an |sct| to |out|. + * It will be indented by the number of spaces specified by |indent|. + * If |logs| is not NULL, it will be used to lookup the CT log that the SCT came + * from, so that the log name can be printed. + */ +void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs); + +/* + * Pretty-prints an |sct_list| to |out|. + * It will be indented by the number of spaces specified by |indent|. + * SCTs will be delimited by |separator|. + * If |logs| is not NULL, it will be used to lookup the CT log that each SCT + * came from, so that the log names can be printed. + */ +void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent, + const char *separator, const CTLOG_STORE *logs); + +/* + * Gets the last result of validating this SCT. + * If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET. + */ +sct_validation_status_t SCT_get_validation_status(const SCT *sct); + +/* + * Validates the given SCT with the provided context. + * Sets the "validation_status" field of the SCT. + * Returns 1 if the SCT is valid and the signature verifies. + * Returns 0 if the SCT is invalid or could not be verified. + * Returns -1 if an error occurs. + */ +__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx); + +/* + * Validates the given list of SCTs with the provided context. + * Sets the "validation_status" field of each SCT. + * Returns 1 if there are no invalid SCTs and all signatures verify. + * Returns 0 if at least one SCT is invalid or could not be verified. + * Returns a negative integer if an error occurs. + */ +__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts, + CT_POLICY_EVAL_CTX *ctx); + + +/********************************* + * SCT parsing and serialisation * + *********************************/ + +/* + * Serialize (to TLS format) a stack of SCTs and return the length. + * "a" must not be NULL. + * If "pp" is NULL, just return the length of what would have been serialized. + * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer + * for data that caller is responsible for freeing (only if function returns + * successfully). + * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring + * that "*pp" is large enough to accept all of the serialized data. + * Returns < 0 on error, >= 0 indicating bytes written (or would have been) + * on success. + */ +__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); + +/* + * Convert TLS format SCT list to a stack of SCTs. + * If "a" or "*a" is NULL, a new stack will be created that the caller is + * responsible for freeing (by calling SCT_LIST_free). + * "**pp" and "*pp" must not be NULL. + * Upon success, "*pp" will point to after the last bytes read, and a stack + * will be returned. + * Upon failure, a NULL pointer will be returned, and the position of "*pp" is + * not defined. + */ +STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, + size_t len); + +/* + * Serialize (to DER format) a stack of SCTs and return the length. + * "a" must not be NULL. + * If "pp" is NULL, just returns the length of what would have been serialized. + * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer + * for data that caller is responsible for freeing (only if function returns + * successfully). + * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring + * that "*pp" is large enough to accept all of the serialized data. + * Returns < 0 on error, >= 0 indicating bytes written (or would have been) + * on success. + */ +__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); + +/* + * Parses an SCT list in DER format and returns it. + * If "a" or "*a" is NULL, a new stack will be created that the caller is + * responsible for freeing (by calling SCT_LIST_free). + * "**pp" and "*pp" must not be NULL. + * Upon success, "*pp" will point to after the last bytes read, and a stack + * will be returned. + * Upon failure, a NULL pointer will be returned, and the position of "*pp" is + * not defined. + */ +STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, + long len); + +/* + * Serialize (to TLS format) an |sct| and write it to |out|. + * If |out| is null, no SCT will be output but the length will still be returned. + * If |out| points to a null pointer, a string will be allocated to hold the + * TLS-format SCT. It is the responsibility of the caller to free it. + * If |out| points to an allocated string, the TLS-format SCT will be written + * to it. + * The length of the SCT in TLS format will be returned. + */ +__owur int i2o_SCT(const SCT *sct, unsigned char **out); + +/* + * Parses an SCT in TLS format and returns it. + * If |psct| is not null, it will end up pointing to the parsed SCT. If it + * already points to a non-null pointer, the pointer will be free'd. + * |in| should be a pointer to a string containing the TLS-format SCT. + * |in| will be advanced to the end of the SCT if parsing succeeds. + * |len| should be the length of the SCT in |in|. + * Returns NULL if an error occurs. + * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len' + * fields will be populated (with |in| and |len| respectively). + */ +SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len); + +/******************** + * CT log functions * + ********************/ + +/* + * Creates a new CT log instance with the given |public_key| and |name|. + * Takes ownership of |public_key| but copies |name|. + * Returns NULL if malloc fails or if |public_key| cannot be converted to DER. + * Should be deleted by the caller using CTLOG_free when no longer needed. + */ +CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name); + +/* + * Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER + * in |pkey_base64|. The |name| is a string to help users identify this log. + * Returns 1 on success, 0 on failure. + * Should be deleted by the caller using CTLOG_free when no longer needed. + */ +int CTLOG_new_from_base64(CTLOG ** ct_log, + const char *pkey_base64, const char *name); + +/* + * Deletes a CT log instance and its fields. + */ +void CTLOG_free(CTLOG *log); + +/* Gets the name of the CT log */ +const char *CTLOG_get0_name(const CTLOG *log); +/* Gets the ID of the CT log */ +void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, + size_t *log_id_len); +/* Gets the public key of the CT log */ +EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log); + +/************************** + * CT log store functions * + **************************/ + +/* + * Creates a new CT log store. + * Should be deleted by the caller using CTLOG_STORE_free when no longer needed. + */ +CTLOG_STORE *CTLOG_STORE_new(void); + +/* + * Deletes a CT log store and all of the CT log instances held within. + */ +void CTLOG_STORE_free(CTLOG_STORE *store); + +/* + * Finds a CT log in the store based on its log ID. + * Returns the CT log, or NULL if no match is found. + */ +const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store, + const uint8_t *log_id, + size_t log_id_len); + +/* + * Loads a CT log list into a |store| from a |file|. + * Returns 1 if loading is successful, or 0 otherwise. + */ +__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file); + +/* + * Loads the default CT log list into a |store|. + * See internal/cryptlib.h for the environment variable and file path that are + * consulted to find the default file. + * Returns 1 if loading is successful, or 0 otherwise. + */ +__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store); + +/* BEGIN ERROR CODES */ +/* + * The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +int ERR_load_CT_strings(void); + +/* Error codes for the CT functions. */ + +/* Function codes. */ +# define CT_F_CTLOG_NEW 117 +# define CT_F_CTLOG_NEW_FROM_BASE64 118 +# define CT_F_CTLOG_NEW_FROM_CONF 119 +# define CT_F_CTLOG_NEW_NULL 120 +# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 122 +# define CT_F_CTLOG_STORE_LOAD_FILE 123 +# define CT_F_CTLOG_STORE_LOAD_LOG 130 +# define CT_F_CTLOG_STORE_NEW 131 +# define CT_F_CT_BASE64_DECODE 124 +# define CT_F_CT_POLICY_EVAL_CTX_NEW 133 +# define CT_F_CT_V1_LOG_ID_FROM_PKEY 125 +# define CT_F_I2O_SCT 107 +# define CT_F_I2O_SCT_LIST 108 +# define CT_F_I2O_SCT_SIGNATURE 109 +# define CT_F_O2I_SCT 110 +# define CT_F_O2I_SCT_LIST 111 +# define CT_F_O2I_SCT_SIGNATURE 112 +# define CT_F_SCT_CTX_NEW 126 +# define CT_F_SCT_NEW 100 +# define CT_F_SCT_NEW_FROM_BASE64 127 +# define CT_F_SCT_SET0_LOG_ID 101 +# define CT_F_SCT_SET1_EXTENSIONS 114 +# define CT_F_SCT_SET1_LOG_ID 115 +# define CT_F_SCT_SET1_SIGNATURE 116 +# define CT_F_SCT_SET_LOG_ENTRY_TYPE 102 +# define CT_F_SCT_SET_SIGNATURE_NID 103 +# define CT_F_SCT_SET_VERSION 104 +# define CT_F_SCT_CTX_VERIFY 128 + +/* Reason codes. */ +# define CT_R_BASE64_DECODE_ERROR 108 +# define CT_R_INVALID_LOG_ID_LENGTH 100 +# define CT_R_LOG_CONF_INVALID 109 +# define CT_R_LOG_CONF_INVALID_KEY 110 +# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 +# define CT_R_LOG_CONF_MISSING_KEY 112 +# define CT_R_LOG_KEY_INVALID 113 +# define CT_R_SCT_INVALID 104 +# define CT_R_SCT_INVALID_SIGNATURE 107 +# define CT_R_SCT_LIST_INVALID 105 +# define CT_R_SCT_LOG_ID_MISMATCH 114 +# define CT_R_SCT_NOT_SET 106 +# define CT_R_SCT_UNSUPPORTED_VERSION 115 +# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 +# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 +# define CT_R_UNSUPPORTED_VERSION 103 + +# ifdef __cplusplus +} +# endif +# endif +#endif diff --git a/openssl/openssl/des_old.h b/openssl/openssl/des_old.h index f1e1e2cb09..ee7607a241 100644 --- a/openssl/openssl/des_old.h +++ b/openssl/openssl/des_old.h @@ -1,4 +1,4 @@ -/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ +/* crypto/des/des_old.h */ /*- * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING diff --git a/openssl/openssl/dh.h b/openssl/openssl/dh.h index 0502f1a9cc..a5bd9016aa 100644 --- a/openssl/openssl/dh.h +++ b/openssl/openssl/dh.h @@ -142,7 +142,7 @@ struct dh_st { BIGNUM *p; BIGNUM *g; long length; /* optional */ - BIGNUM *pub_key; /* g^x */ + BIGNUM *pub_key; /* g^x % p */ BIGNUM *priv_key; /* x */ int flags; BN_MONT_CTX *method_mont_p; @@ -174,6 +174,7 @@ struct dh_st { /* DH_check_pub_key error codes */ # define DH_CHECK_PUBKEY_TOO_SMALL 0x01 # define DH_CHECK_PUBKEY_TOO_LARGE 0x02 +# define DH_CHECK_PUBKEY_INVALID 0x04 /* * primes p where (p-1)/2 is prime too are called "safe"; we define this for diff --git a/openssl/openssl/dso.h b/openssl/openssl/dso.h index 7c4a1dc4a6..c9013f5cea 100644 --- a/openssl/openssl/dso.h +++ b/openssl/openssl/dso.h @@ -1,4 +1,4 @@ -/* dso.h -*- mode:C; c-file-style: "eay" -*- */ +/* dso.h */ /* * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project * 2000. diff --git a/openssl/openssl/ec.h b/openssl/openssl/ec.h index 6d3178f609..81e6faf6c5 100644 --- a/openssl/openssl/ec.h +++ b/openssl/openssl/ec.h @@ -106,7 +106,7 @@ typedef enum { /** the point is encoded as z||x, where the octet z specifies * which solution of the quadratic equation y is */ POINT_CONVERSION_COMPRESSED = 2, - /** the point is encoded as z||x||y, where z is the octet 0x02 */ + /** the point is encoded as z||x||y, where z is the octet 0x04 */ POINT_CONVERSION_UNCOMPRESSED = 4, /** the point is encoded as z||x||y, where the octet z specifies * which solution of the quadratic equation y is */ diff --git a/openssl/openssl/ecdsa.h b/openssl/openssl/ecdsa.h index c4016ac3e1..a6f0930f82 100644 --- a/openssl/openssl/ecdsa.h +++ b/openssl/openssl/ecdsa.h @@ -233,7 +233,7 @@ void *ECDSA_get_ex_data(EC_KEY *d, int idx); * \return pointer to a ECDSA_METHOD structure or NULL if an error occurred */ -ECDSA_METHOD *ECDSA_METHOD_new(ECDSA_METHOD *ecdsa_method); +ECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_method); /** frees a ECDSA_METHOD structure * \param ecdsa_method pointer to the ECDSA_METHOD structure diff --git a/openssl/openssl/kdf.h b/openssl/openssl/kdf.h new file mode 100644 index 0000000000..9f87f788b2 --- /dev/null +++ b/openssl/openssl/kdf.h @@ -0,0 +1,75 @@ +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef HEADER_KDF_H +# define HEADER_KDF_H + +#ifdef __cplusplus +extern "C" { +#endif + +# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL) +# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1) +# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2) +# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3) +# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4) +# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5) +# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6) + +# define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_TLS_MD, 0, (void *)md) + +# define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)sec) + +# define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)seed) + +# define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_HKDF_MD, 0, (void *)md) + +# define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)salt) + +# define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)key) + +# define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \ + EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ + EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)info) + +/* BEGIN ERROR CODES */ +/* + * The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +int ERR_load_KDF_strings(void); + +/* Error codes for the KDF functions. */ + +/* Function codes. */ +# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 100 +# define KDF_F_PKEY_TLS1_PRF_DERIVE 101 + +/* Reason codes. */ +# define KDF_R_INVALID_DIGEST 100 +# define KDF_R_MISSING_PARAMETER 101 +# define KDF_R_VALUE_MISSING 102 + +# ifdef __cplusplus +} +# endif +#endif diff --git a/openssl/openssl/kssl.h b/openssl/openssl/kssl.h index 9a57672801..ae8a51f472 100644 --- a/openssl/openssl/kssl.h +++ b/openssl/openssl/kssl.h @@ -1,4 +1,4 @@ -/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */ +/* ssl/kssl.h */ /* * Written by Vern Staats for the OpenSSL project * 2000. project 2000. diff --git a/openssl/openssl/md2.h b/openssl/openssl/md2.h new file mode 100644 index 0000000000..7faf8e3d65 --- /dev/null +++ b/openssl/openssl/md2.h @@ -0,0 +1,44 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef HEADER_MD2_H +# define HEADER_MD2_H + +# include + +# ifndef OPENSSL_NO_MD2 +# include +# ifdef __cplusplus +extern "C" { +# endif + +typedef unsigned char MD2_INT; + +# define MD2_DIGEST_LENGTH 16 +# define MD2_BLOCK 16 + +typedef struct MD2state_st { + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; +} MD2_CTX; + +const char *MD2_options(void); +int MD2_Init(MD2_CTX *c); +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); +int MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md); + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/openssl/openssl/opensslconf.h b/openssl/openssl/opensslconf.h index 1f6a1ded2f..a8b64c1e8f 100644 --- a/openssl/openssl/opensslconf.h +++ b/openssl/openssl/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -95,12 +101,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif /* crypto/opensslconf.h.in */ @@ -110,8 +122,8 @@ extern "C" { #if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) -#define ENGINESDIR "/tmp/openssl-1.0.2d-x86_64/lib/engines" -#define OPENSSLDIR "/tmp/openssl-1.0.2d-x86_64" +#define ENGINESDIR "/Users/peter/build/OpenSSL-for-iPhone/bin/iPhoneSimulator10.0-x86_64.sdk/lib/engines" +#define OPENSSLDIR "/Users/peter/build/OpenSSL-for-iPhone/bin/iPhoneSimulator10.0-x86_64.sdk" #endif #endif @@ -225,7 +237,7 @@ extern "C" { optimization options. Older Sparc's work better with only UNROLL, but there's no way to tell at compile time what it is you're running on */ -#if defined( sun ) /* Newer Sparc's */ +#if defined( __sun ) || defined ( sun ) /* Newer Sparc's */ # define DES_PTR # define DES_RISC1 # define DES_UNROLL diff --git a/openssl/openssl/opensslv.h b/openssl/openssl/opensslv.h index c06b13ac6b..13fe440231 100644 --- a/openssl/openssl/opensslv.h +++ b/openssl/openssl/opensslv.h @@ -30,11 +30,11 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x1000204fL +# define OPENSSL_VERSION_NUMBER 0x1000208fL # ifdef OPENSSL_FIPS -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2d-fips 9 Jul 2015" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2h-fips 3 May 2016" # else -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2d 9 Jul 2015" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2h 3 May 2016" # endif # define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT diff --git a/openssl/openssl/rc5.h b/openssl/openssl/rc5.h new file mode 100644 index 0000000000..793f88e4e8 --- /dev/null +++ b/openssl/openssl/rc5.h @@ -0,0 +1,63 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef HEADER_RC5_H +# define HEADER_RC5_H + +# include + +# ifndef OPENSSL_NO_RC5 +# ifdef __cplusplus +extern "C" { +# endif + +# define RC5_ENCRYPT 1 +# define RC5_DECRYPT 0 + +# define RC5_32_INT unsigned int + +# define RC5_32_BLOCK 8 +# define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */ + +/* + * This are the only values supported. Tweak the code if you want more The + * most supported modes will be RC5-32/12/16 RC5-32/16/8 + */ +# define RC5_8_ROUNDS 8 +# define RC5_12_ROUNDS 12 +# define RC5_16_ROUNDS 16 + +typedef struct rc5_key_st { + /* Number of rounds */ + int rounds; + RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; +} RC5_32_KEY; + +void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, + int rounds); +void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, + RC5_32_KEY *key, int enc); +void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); +void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); +void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, + long length, RC5_32_KEY *ks, unsigned char *iv, + int enc); +void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC5_32_KEY *schedule, + unsigned char *ivec, int *num, int enc); +void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC5_32_KEY *schedule, + unsigned char *ivec, int *num); + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/openssl/openssl/srp.h b/openssl/openssl/srp.h index d072536fec..028892a1ff 100644 --- a/openssl/openssl/srp.h +++ b/openssl/openssl/srp.h @@ -82,16 +82,21 @@ typedef struct SRP_gN_cache_st { DECLARE_STACK_OF(SRP_gN_cache) typedef struct SRP_user_pwd_st { + /* Owned by us. */ char *id; BIGNUM *s; BIGNUM *v; + /* Not owned by us. */ const BIGNUM *g; const BIGNUM *N; + /* Owned by us. */ char *info; } SRP_user_pwd; DECLARE_STACK_OF(SRP_user_pwd) +void SRP_user_pwd_free(SRP_user_pwd *user_pwd); + typedef struct SRP_VBASE_st { STACK_OF(SRP_user_pwd) *users_pwd; STACK_OF(SRP_gN_cache) *gN_cache; @@ -115,7 +120,12 @@ DECLARE_STACK_OF(SRP_gN) SRP_VBASE *SRP_VBASE_new(char *seed_key); int SRP_VBASE_free(SRP_VBASE *vb); int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); + +/* This method ignores the configured seed and fails for an unknown user. */ SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username); +/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/ +SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); + char *SRP_create_verifier(const char *user, const char *pass, char **salt, char **verifier, const char *N, const char *g); int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, diff --git a/openssl/openssl/ssl.h b/openssl/openssl/ssl.h index 6fe1a2474d..5ef56faa50 100644 --- a/openssl/openssl/ssl.h +++ b/openssl/openssl/ssl.h @@ -338,7 +338,7 @@ extern "C" { * The following cipher list is used by default. It also is substituted when * an application-defined cipher list string starts with 'DEFAULT'. */ -# define SSL_DEFAULT_CIPHER_LIST "ALL:!EXPORT:!aNULL:!eNULL:!SSLv2" +# define SSL_DEFAULT_CIPHER_LIST "ALL:!EXPORT:!LOW:!aNULL:!eNULL:!SSLv2" /* * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always * starts with a reasonable order, and all we have to do for DEFAULT is @@ -625,7 +625,7 @@ struct ssl_session_st { # define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000L /* If set, always create a new key when using tmp_ecdh parameters */ # define SSL_OP_SINGLE_ECDH_USE 0x00080000L -/* If set, always create a new key when using tmp_dh parameters */ +/* Does nothing: retained for compatibility */ # define SSL_OP_SINGLE_DH_USE 0x00100000L /* Does nothing: retained for compatibiity */ # define SSL_OP_EPHEMERAL_RSA 0x0 @@ -2092,7 +2092,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) # define SSL_CTX_set1_sigalgs_list(ctx, s) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s) # define SSL_set1_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,clistlen,(int *)slist) + SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist) # define SSL_set1_sigalgs_list(ctx, s) \ SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s) # define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ @@ -2345,7 +2345,7 @@ const char *SSL_get_version(const SSL *s); /* This sets the 'default' SSL version that SSL_new() will create */ int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth); -# ifndef OPENSSL_NO_SSL2 +# ifndef OPENSSL_NO_SSL2_METHOD const SSL_METHOD *SSLv2_method(void); /* SSLv2 */ const SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */ const SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */ @@ -2681,6 +2681,7 @@ void ERR_load_SSL_strings(void); # define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 292 # define SSL_F_SSL3_ENC 134 # define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 +# define SSL_F_SSL3_GENERATE_MASTER_SECRET 388 # define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 # define SSL_F_SSL3_GET_CERT_STATUS 289 # define SSL_F_SSL3_GET_CERT_VERIFY 136 @@ -2846,8 +2847,11 @@ void ERR_load_SSL_strings(void); # define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 # define SSL_R_BAD_DECOMPRESSION 107 # define SSL_R_BAD_DH_G_LENGTH 108 +# define SSL_R_BAD_DH_G_VALUE 375 # define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 +# define SSL_R_BAD_DH_PUB_KEY_VALUE 393 # define SSL_R_BAD_DH_P_LENGTH 110 +# define SSL_R_BAD_DH_P_VALUE 395 # define SSL_R_BAD_DIGEST_LENGTH 111 # define SSL_R_BAD_DSA_SIGNATURE 112 # define SSL_R_BAD_ECC_CERT 304 @@ -3052,6 +3056,7 @@ void ERR_load_SSL_strings(void); # define SSL_R_SERVERHELLO_TLSEXT 275 # define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 # define SSL_R_SHORT_READ 219 +# define SSL_R_SHUTDOWN_WHILE_IN_INIT 407 # define SSL_R_SIGNATURE_ALGORITHMS_ERROR 360 # define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 # define SSL_R_SRP_A_CALC 361 diff --git a/openssl/openssl/tls1.h b/openssl/openssl/tls1.h index 5929607ff8..7e237d0631 100644 --- a/openssl/openssl/tls1.h +++ b/openssl/openssl/tls1.h @@ -231,13 +231,12 @@ extern "C" { /* ExtensionType value from RFC5620 */ # define TLSEXT_TYPE_heartbeat 15 -/* ExtensionType value from draft-ietf-tls-applayerprotoneg-00 */ +/* ExtensionType value from RFC7301 */ # define TLSEXT_TYPE_application_layer_protocol_negotiation 16 /* * ExtensionType value for TLS padding extension. - * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - * http://tools.ietf.org/html/draft-agl-tls-padding-03 + * http://tools.ietf.org/html/draft-agl-tls-padding */ # define TLSEXT_TYPE_padding 21 @@ -262,20 +261,19 @@ extern "C" { # define TLSEXT_TYPE_next_proto_neg 13172 # endif -/* NameType value from RFC 3546 */ +/* NameType value from RFC3546 */ # define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC 3546 */ +/* status request value from RFC3546 */ # define TLSEXT_STATUSTYPE_ocsp 1 -/* ECPointFormat values from draft-ietf-tls-ecc-12 */ +/* ECPointFormat values from RFC4492 */ # define TLSEXT_ECPOINTFORMAT_first 0 # define TLSEXT_ECPOINTFORMAT_uncompressed 0 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 # define TLSEXT_ECPOINTFORMAT_last 2 -/* Signature and hash algorithms from RFC 5246 */ - +/* Signature and hash algorithms from RFC5246 */ # define TLSEXT_signature_anonymous 0 # define TLSEXT_signature_rsa 1 # define TLSEXT_signature_dsa 2 @@ -430,7 +428,6 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 /* AES ciphersuites from RFC3268 */ - # define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F # define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 # define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 @@ -595,7 +592,7 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" # define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" -/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +/* ECC ciphersuites from RFC4492 */ # define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" diff --git a/openssl/openssl/ui.h b/openssl/openssl/ui.h index b917edab3a..0dc16330b8 100644 --- a/openssl/openssl/ui.h +++ b/openssl/openssl/ui.h @@ -1,4 +1,4 @@ -/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* crypto/ui/ui.h */ /* * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project * 2001. diff --git a/openssl/openssl/ui_compat.h b/openssl/openssl/ui_compat.h index 42fb9ff650..bf541542c0 100644 --- a/openssl/openssl/ui_compat.h +++ b/openssl/openssl/ui_compat.h @@ -1,4 +1,4 @@ -/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* crypto/ui/ui.h */ /* * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project * 2001. diff --git a/openssl/openssl/x509.h b/openssl/openssl/x509.h index 99337b849a..fc613ce635 100644 --- a/openssl/openssl/x509.h +++ b/openssl/openssl/x509.h @@ -1305,6 +1305,7 @@ void ERR_load_X509_strings(void); # define X509_R_LOADING_CERT_DIR 103 # define X509_R_LOADING_DEFAULTS 104 # define X509_R_METHOD_NOT_SUPPORTED 124 +# define X509_R_NAME_TOO_LONG 134 # define X509_R_NEWER_CRL_NOT_NEWER 132 # define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 # define X509_R_NO_CRL_NUMBER 130 diff --git a/openssl/openssl/x509_vfy.h b/openssl/openssl/x509_vfy.h index bd8613c62b..2663e1c0a3 100644 --- a/openssl/openssl/x509_vfy.h +++ b/openssl/openssl/x509_vfy.h @@ -313,7 +313,7 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) # define X509_V_OK 0 -/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ +# define X509_V_ERR_UNSPECIFIED 1 # define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 # define X509_V_ERR_UNABLE_TO_GET_CRL 3 diff --git a/thirdparty/AFNetworking/AFHTTPClient.m b/thirdparty/AFNetworking/AFHTTPClient.m index 753bab67ae..8ac818423b 100644 --- a/thirdparty/AFNetworking/AFHTTPClient.m +++ b/thirdparty/AFNetworking/AFHTTPClient.m @@ -277,7 +277,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { #if __IPHONE_OS_VERSION_MIN_REQUIRED // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 - [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion], [[UIDevice currentDevice] model], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0)]]; + [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", @"iOS", @"unknown", @"iOS", (2.0)]]; #elif __MAC_OS_X_VERSION_MIN_REQUIRED [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown"]]; #endif diff --git a/thirdparty/AsyncSocket/GCDAsyncSocket.h b/thirdparty/AsyncSocket/GCDAsyncSocket.h index db835d4c5a..6e64b4651e 100644 --- a/thirdparty/AsyncSocket/GCDAsyncSocket.h +++ b/thirdparty/AsyncSocket/GCDAsyncSocket.h @@ -93,6 +93,8 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError; #pragma mark - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +@class MTNetworkUsageCalculationInfo; + @interface GCDAsyncSocket : NSObject { uint32_t flags; @@ -147,6 +149,7 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError; } @property (nonatomic) bool useTcpNodelay; +@property (nonatomic, strong) MTNetworkUsageCalculationInfo *usageCalculationInfo; /** * GCDAsyncSocket uses the standard delegate paradigm, diff --git a/thirdparty/AsyncSocket/GCDAsyncSocket.m b/thirdparty/AsyncSocket/GCDAsyncSocket.m index 49c15b7ab0..e496bfc8e7 100755 --- a/thirdparty/AsyncSocket/GCDAsyncSocket.m +++ b/thirdparty/AsyncSocket/GCDAsyncSocket.m @@ -10,7 +10,7 @@ #import "GCDAsyncSocket.h" -#import +#import "MTLogging.h" #if TARGET_OS_IPHONE #import @@ -30,6 +30,9 @@ #import #import +#import "MTNetworkUsageCalculationInfo.h" +#import "MTNetworkUsageManager.h" + #if ! __has_feature(objc_arc) #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). // For more information see: https://github.com/robbiehanson/CocoaAsyncSocket/wiki/ARC @@ -181,7 +184,10 @@ enum GCDAsyncSocketConfig static NSThread *cfstreamThread; // Used for CFStreams #endif -@interface GCDAsyncSocket () +@interface GCDAsyncSocket () { + MTNetworkUsageManager *_usageManager; + MTNetworkUsageManagerInterface _interface; +} // Accepting - (BOOL)doAccept:(int)socketFD; @@ -2298,6 +2304,20 @@ enum GCDAsyncSocketConfig [self closeWithError:error]; } + +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { + dispatch_async(socketQueue, ^{ + if (_usageCalculationInfo != usageCalculationInfo) { + _usageCalculationInfo = usageCalculationInfo; + if (usageCalculationInfo != nil) { + _usageManager = [[MTNetworkUsageManager alloc] initWithInfo:usageCalculationInfo]; + } else { + _usageManager = nil; + } + } + }); +} + - (BOOL)connectWithAddress4:(NSData *)address4 address6:(NSData *)address6 error:(NSError **)errPtr { LogTrace(); @@ -2411,9 +2431,50 @@ enum GCDAsyncSocketConfig int result = connect(socketFD, (const struct sockaddr *)[address bytes], (socklen_t)[address length]); if (result == 0) { - MTLog(@"Connection time: %f ms", (CFAbsoluteTimeGetCurrent() - startTime) * 1000.0f); + bool isWifi = false; + + struct sockaddr_in addr; + struct ifaddrs* ifaddr; + struct ifaddrs* ifa; + socklen_t addr_len; + + addr_len = sizeof(addr); + getsockname(socketFD, (struct sockaddr*)&addr, &addr_len); + getifaddrs(&ifaddr); + + // look which interface contains the wanted IP. + // When found, ifa->ifa_name contains the name of the interface (eth0, eth1, ppp0...) + for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr) + { + if (AF_INET == ifa->ifa_addr->sa_family) + { + struct sockaddr_in* inaddr = (struct sockaddr_in*)ifa->ifa_addr; + + if (inaddr->sin_addr.s_addr == addr.sin_addr.s_addr) + { + if (ifa->ifa_name) + { + if ([[NSString stringWithCString:ifa->ifa_name encoding:NSUTF8StringEncoding] hasPrefix:@"en"]) { + isWifi = true; + } + } + } + } + } + } + freeifaddrs(ifaddr); + + if (MTLogEnabled()) { + MTLog(@"Connection time: %f ms, interface: %@", (CFAbsoluteTimeGetCurrent() - startTime) * 1000.0f, isWifi ? @"Wifi" : @"WAN"); + } + dispatch_async(socketQueue, ^{ @autoreleasepool { - + if (_usageCalculationInfo != nil) { + _usageManager = [[MTNetworkUsageManager alloc] initWithInfo:_usageCalculationInfo]; + _interface = isWifi ? MTNetworkUsageManagerInterfaceOther : MTNetworkUsageManagerInterfaceWWAN; + } [self didConnect:aConnectIndex]; }}); } @@ -4636,6 +4697,7 @@ enum GCDAsyncSocketConfig else { bytesRead = result; + [_usageManager addIncomingBytes:(NSUInteger)bytesRead interface:_interface]; if (bytesRead < bytesToRead) { @@ -5591,6 +5653,7 @@ enum GCDAsyncSocketConfig else { bytesWritten = result; + [_usageManager addOutgoingBytes:(NSUInteger)bytesWritten interface:_interface]; } } }