mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Cleanup and add logging
This commit is contained in:
parent
d19489b083
commit
b58d71c1c3
@ -109,9 +109,9 @@ static NSDictionary *selectPublicKey(NSArray *fingerprints, NSArray<NSDictionary
|
|||||||
{
|
{
|
||||||
for (NSDictionary *keyDesc in publicKeys)
|
for (NSDictionary *keyDesc in publicKeys)
|
||||||
{
|
{
|
||||||
int64_t keyFingerprint = [[keyDesc objectForKey:@"fingerprint"] longLongValue];
|
uint64_t keyFingerprint = [[keyDesc objectForKey:@"fingerprint"] unsignedLongLongValue];
|
||||||
|
|
||||||
if ([nFingerprint longLongValue] == keyFingerprint)
|
if ([nFingerprint unsignedLongLongValue] == keyFingerprint)
|
||||||
return keyDesc;
|
return keyDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,6 @@ typedef enum {
|
|||||||
id<EncryptionProvider> _encryptionProvider;
|
id<EncryptionProvider> _encryptionProvider;
|
||||||
|
|
||||||
bool _tempAuth;
|
bool _tempAuth;
|
||||||
MTSessionInfo *_sessionInfo;
|
|
||||||
|
|
||||||
MTDatacenterAuthStage _stage;
|
MTDatacenterAuthStage _stage;
|
||||||
int64_t _currentStageMessageId;
|
int64_t _currentStageMessageId;
|
||||||
@ -165,7 +164,6 @@ typedef enum {
|
|||||||
{
|
{
|
||||||
_encryptionProvider = context.encryptionProvider;
|
_encryptionProvider = context.encryptionProvider;
|
||||||
_tempAuth = tempAuth;
|
_tempAuth = tempAuth;
|
||||||
_sessionInfo = [[MTSessionInfo alloc] initWithRandomSessionIdAndContext:context];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -267,7 +265,7 @@ typedef enum {
|
|||||||
[reqDhBuffer appendInt64:_dhPublicKeyFingerprint];
|
[reqDhBuffer appendInt64:_dhPublicKeyFingerprint];
|
||||||
[reqDhBuffer appendTLBytes:_dhEncryptedData];
|
[reqDhBuffer appendTLBytes:_dhEncryptedData];
|
||||||
|
|
||||||
NSString *messageDescription = [NSString stringWithFormat:@"reqDh nonce:%@ serverNonce:%@ p:%@ q:%@ fingerprint:%llx", _nonce, _serverNonce, _dhP, _dhQ, _dhPublicKeyFingerprint];
|
NSString *messageDescription = [NSString stringWithFormat:@"reqDh nonce:%@ serverNonce:%@ p:%@ q:%@ fingerprint:%llx dhEncryptedData:%d bytes", _nonce, _serverNonce, _dhP, _dhQ, _dhPublicKeyFingerprint, (int)_dhEncryptedData.length];
|
||||||
MTOutgoingMessage *message = [[MTOutgoingMessage alloc] initWithData:reqDhBuffer.data metadata:messageDescription additionalDebugDescription:nil shortMetadata:messageDescription messageId:_currentStageMessageId messageSeqNo:_currentStageMessageSeqNo];
|
MTOutgoingMessage *message = [[MTOutgoingMessage alloc] initWithData:reqDhBuffer.data metadata:messageDescription additionalDebugDescription:nil shortMetadata:messageDescription messageId:_currentStageMessageId messageSeqNo:_currentStageMessageSeqNo];
|
||||||
return [[MTMessageTransaction alloc] initWithMessagePayload:@[message] prepared:nil failed:nil completion:^(NSDictionary *messageInternalIdToTransactionId, NSDictionary *messageInternalIdToPreparedMessage, __unused NSDictionary *messageInternalIdToQuickAckId)
|
return [[MTMessageTransaction alloc] initWithMessagePayload:@[message] prepared:nil failed:nil completion:^(NSDictionary *messageInternalIdToTransactionId, NSDictionary *messageInternalIdToPreparedMessage, __unused NSDictionary *messageInternalIdToQuickAckId)
|
||||||
{
|
{
|
||||||
@ -402,7 +400,11 @@ typedef enum {
|
|||||||
arc4random_buf(&random, 1);
|
arc4random_buf(&random, 1);
|
||||||
[dataWithHash appendBytes:&random length:1];
|
[dataWithHash appendBytes:&random length:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData *encryptedData = MTRsaEncrypt(_encryptionProvider, [publicKey objectForKey:@"key"], dataWithHash);
|
NSData *encryptedData = MTRsaEncrypt(_encryptionProvider, [publicKey objectForKey:@"key"], dataWithHash);
|
||||||
|
if (MTLogEnabled()) {
|
||||||
|
MTLog(@"[MTDatacenterAuthMessageService#%p encryptedData length %d dataWithHash length %d]", self, (int)encryptedData.length, (int)dataWithHash.length);
|
||||||
|
}
|
||||||
if (encryptedData.length < 256)
|
if (encryptedData.length < 256)
|
||||||
{
|
{
|
||||||
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];
|
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];
|
||||||
@ -438,8 +440,11 @@ typedef enum {
|
|||||||
arc4random_buf(&random, 1);
|
arc4random_buf(&random, 1);
|
||||||
[dataWithHash appendBytes:&random length:1];
|
[dataWithHash appendBytes:&random length:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData *encryptedData = MTRsaEncrypt(_encryptionProvider, [publicKey objectForKey:@"key"], dataWithHash);
|
NSData *encryptedData = MTRsaEncrypt(_encryptionProvider, [publicKey objectForKey:@"key"], dataWithHash);
|
||||||
|
if (MTLogEnabled()) {
|
||||||
|
MTLog(@"[MTDatacenterAuthMessageService#%p encryptedData length %d dataWithHash length %d]", self, (int)encryptedData.length, (int)dataWithHash.length);
|
||||||
|
}
|
||||||
if (encryptedData.length < 256)
|
if (encryptedData.length < 256)
|
||||||
{
|
{
|
||||||
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];
|
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user