mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
cae9dcd54d
@ -278,6 +278,8 @@ official_apple_pay_merchants = [
|
|||||||
"merchant.privatbank.test.telergramios",
|
"merchant.privatbank.test.telergramios",
|
||||||
"merchant.privatbank.prod.telergram",
|
"merchant.privatbank.prod.telergram",
|
||||||
"merchant.paymaster.test.telegramios",
|
"merchant.paymaster.test.telegramios",
|
||||||
|
"merchant.smartglocal.prod.telegramios",
|
||||||
|
"merchant.smartglocal.test.telegramios",
|
||||||
]
|
]
|
||||||
|
|
||||||
official_bundle_ids = [
|
official_bundle_ids = [
|
||||||
|
@ -43,11 +43,12 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static NSArray<MTDatacenterAuthPublicKey *> *defaultPublicKeys() {
|
static NSArray<MTDatacenterAuthPublicKey *> *defaultPublicKeys(bool isProduction) {
|
||||||
static NSArray<MTDatacenterAuthPublicKey *> *serverPublicKeys = nil;
|
static NSArray<MTDatacenterAuthPublicKey *> *testingPublicKeys = nil;
|
||||||
|
static NSArray<MTDatacenterAuthPublicKey *> *productionPublicKeys = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
serverPublicKeys = @[
|
testingPublicKeys = @[
|
||||||
[[MTDatacenterAuthPublicKey alloc] initWithPublicKey:@"-----BEGIN RSA PUBLIC KEY-----\n"
|
[[MTDatacenterAuthPublicKey alloc] initWithPublicKey:@"-----BEGIN RSA PUBLIC KEY-----\n"
|
||||||
"MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIR\n"
|
"MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIR\n"
|
||||||
"yy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwv\n"
|
"yy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwv\n"
|
||||||
@ -55,7 +56,10 @@ static NSArray<MTDatacenterAuthPublicKey *> *defaultPublicKeys() {
|
|||||||
"j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1\n"
|
"j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1\n"
|
||||||
"aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCO\n"
|
"aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCO\n"
|
||||||
"j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB\n"
|
"j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB\n"
|
||||||
"-----END RSA PUBLIC KEY-----"],
|
"-----END RSA PUBLIC KEY-----"]
|
||||||
|
];
|
||||||
|
|
||||||
|
productionPublicKeys = @[
|
||||||
[[MTDatacenterAuthPublicKey alloc] initWithPublicKey:@"-----BEGIN RSA PUBLIC KEY-----\n"
|
[[MTDatacenterAuthPublicKey alloc] initWithPublicKey:@"-----BEGIN RSA PUBLIC KEY-----\n"
|
||||||
"MIIBCgKCAQEA6LszBcC1LGzyr992NzE0ieY+BSaOW622Aa9Bd4ZHLl+TuFQ4lo4g\n"
|
"MIIBCgKCAQEA6LszBcC1LGzyr992NzE0ieY+BSaOW622Aa9Bd4ZHLl+TuFQ4lo4g\n"
|
||||||
"5nKaMBwK/BIb9xUfg0Q29/2mgIR6Zr9krM7HjuIcCzFvDtr+L0GQjae9H0pRB2OO\n"
|
"5nKaMBwK/BIb9xUfg0Q29/2mgIR6Zr9krM7HjuIcCzFvDtr+L0GQjae9H0pRB2OO\n"
|
||||||
@ -66,7 +70,11 @@ static NSArray<MTDatacenterAuthPublicKey *> *defaultPublicKeys() {
|
|||||||
"-----END RSA PUBLIC KEY-----"]
|
"-----END RSA PUBLIC KEY-----"]
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
return serverPublicKeys;
|
if (isProduction) {
|
||||||
|
return productionPublicKeys;
|
||||||
|
} else {
|
||||||
|
return testingPublicKeys;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static MTDatacenterAuthPublicKey *selectPublicKey(id<EncryptionProvider> encryptionProvider, NSArray<NSNumber *> *fingerprints, NSArray<MTDatacenterAuthPublicKey *> *publicKeys) {
|
static MTDatacenterAuthPublicKey *selectPublicKey(id<EncryptionProvider> encryptionProvider, NSArray<NSNumber *> *fingerprints, NSArray<MTDatacenterAuthPublicKey *> *publicKeys) {
|
||||||
@ -170,7 +178,7 @@ typedef enum {
|
|||||||
_stage = MTDatacenterAuthStagePQ;
|
_stage = MTDatacenterAuthStagePQ;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_publicKeys = defaultPublicKeys();
|
_publicKeys = defaultPublicKeys(!mtProto.context.isTestingEnvironment);
|
||||||
_stage = MTDatacenterAuthStagePQ;
|
_stage = MTDatacenterAuthStagePQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +192,10 @@ typedef enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)mtProtoPublicKeysUpdated:(MTProto *)mtProto datacenterId:(NSInteger)datacenterId publicKeys:(NSArray<NSDictionary *> *)publicKeys {
|
- (void)mtProtoPublicKeysUpdated:(MTProto *)mtProto datacenterId:(NSInteger)datacenterId publicKeys:(NSArray<NSDictionary *> *)publicKeys {
|
||||||
|
if (!mtProto.cdn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_stage == MTDatacenterAuthStageWaitingForPublicKeys) {
|
if (_stage == MTDatacenterAuthStageWaitingForPublicKeys) {
|
||||||
if (mtProto.datacenterId == datacenterId) {
|
if (mtProto.datacenterId == datacenterId) {
|
||||||
_publicKeys = [self convertPublicKeysFromDictionaries:publicKeys];
|
_publicKeys = [self convertPublicKeysFromDictionaries:publicKeys];
|
||||||
@ -281,77 +293,6 @@ typedef enum {
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSData *aesCbcEncrypt(NSData *data, NSData *key, NSData *iv) {
|
|
||||||
size_t keyLength = kCCKeySizeAES256;
|
|
||||||
if (key.length != keyLength) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
if (iv.length != 16) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
if (data.length % 16 != 0) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSMutableData *outData = [[NSMutableData alloc] initWithLength:data.length];
|
|
||||||
|
|
||||||
CCOperation operation = kCCEncrypt;
|
|
||||||
CCAlgorithm algoritm = kCCAlgorithmAES128;
|
|
||||||
CCOptions options = 0; // No padding
|
|
||||||
|
|
||||||
size_t outDataActualSize = 0;
|
|
||||||
|
|
||||||
int status = CCCrypt(
|
|
||||||
operation,
|
|
||||||
algoritm,
|
|
||||||
options,
|
|
||||||
key.bytes,
|
|
||||||
keyLength,
|
|
||||||
iv.bytes,
|
|
||||||
data.bytes,
|
|
||||||
data.length,
|
|
||||||
outData.mutableBytes,
|
|
||||||
outData.length,
|
|
||||||
&outDataActualSize
|
|
||||||
);
|
|
||||||
|
|
||||||
if (status != kCCSuccess) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
if (outDataActualSize != data.length) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
return outData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NSData *encryptRSALegacy(id<EncryptionProvider> encryptionProvider, NSData *pqInnerData, NSString *publicKey) {
|
|
||||||
NSMutableData *dataWithHash = [[NSMutableData alloc] init];
|
|
||||||
[dataWithHash appendData:MTSha1(pqInnerData)];
|
|
||||||
[dataWithHash appendData:pqInnerData];
|
|
||||||
while (dataWithHash.length < 255) {
|
|
||||||
uint8_t random = 0;
|
|
||||||
arc4random_buf(&random, 1);
|
|
||||||
[dataWithHash appendBytes:&random length:1];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSData *encryptedData = MTRsaEncrypt(encryptionProvider, publicKey, dataWithHash);
|
|
||||||
|
|
||||||
if (encryptedData.length < 256) {
|
|
||||||
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];
|
|
||||||
for (int i = 0; i < 256 - (int)encryptedData.length; i++)
|
|
||||||
{
|
|
||||||
uint8_t random = 0;
|
|
||||||
arc4random_buf(&random, 1);
|
|
||||||
[newEncryptedData appendBytes:&random length:1];
|
|
||||||
}
|
|
||||||
[newEncryptedData appendData:encryptedData];
|
|
||||||
encryptedData = newEncryptedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return encryptedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NSData *reversedBytes(NSData *data) {
|
static NSData *reversedBytes(NSData *data) {
|
||||||
NSMutableData *result = [[NSMutableData alloc] initWithLength:data.length];
|
NSMutableData *result = [[NSMutableData alloc] initWithLength:data.length];
|
||||||
for (NSUInteger i = 0; i < result.length; i++) {
|
for (NSUInteger i = 0; i < result.length; i++) {
|
||||||
|
@ -601,44 +601,13 @@ public final class OngoingGroupCallContext {
|
|||||||
mainView?.setOnIsMirroredUpdated { value in
|
mainView?.setOnIsMirroredUpdated { value in
|
||||||
f?(value)
|
f?(value)
|
||||||
}
|
}
|
||||||
|
}, setIsPaused: { [weak mainView] paused in
|
||||||
|
mainView?.setIsPaused(paused)
|
||||||
|
}, renderToSize: { [weak mainView] size, animated in
|
||||||
|
mainView?.render(to: size, animated: animated)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
var cloneVideoView: OngoingCallContextPresentationCallVideoView?
|
completion(mainVideoView, nil)
|
||||||
if let cloneView = cloneView {
|
|
||||||
cloneVideoView = OngoingCallContextPresentationCallVideoView(
|
|
||||||
view: cloneView,
|
|
||||||
setOnFirstFrameReceived: { [weak cloneView] f in
|
|
||||||
cloneView?.setOnFirstFrameReceived(f)
|
|
||||||
},
|
|
||||||
getOrientation: { [weak cloneView] in
|
|
||||||
if let cloneView = cloneView {
|
|
||||||
return OngoingCallVideoOrientation(cloneView.orientation)
|
|
||||||
} else {
|
|
||||||
return .rotation0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getAspect: { [weak cloneView] in
|
|
||||||
if let cloneView = cloneView {
|
|
||||||
return cloneView.aspect
|
|
||||||
} else {
|
|
||||||
return 0.0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setOnOrientationUpdated: { [weak cloneView] f in
|
|
||||||
cloneView?.setOnOrientationUpdated { value, aspect in
|
|
||||||
f?(OngoingCallVideoOrientation(value), aspect)
|
|
||||||
}
|
|
||||||
}, setVideoContentMode: { [weak cloneView] mode in
|
|
||||||
cloneView?.setVideoContentMode(mode)
|
|
||||||
},
|
|
||||||
setOnIsMirroredUpdated: { [weak cloneView] f in
|
|
||||||
cloneView?.setOnIsMirroredUpdated { value in
|
|
||||||
f?(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
completion(mainVideoView, cloneVideoView)
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
completion(nil, nil)
|
completion(nil, nil)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 3cf1822a70e3b84f6a762755e5249b26e915d321
|
Subproject commit 1d00d49002333436bb9069558cd718dd770dade1
|
Loading…
x
Reference in New Issue
Block a user