mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-17 19:09:56 +00:00
Fixed macOS build
This commit is contained in:
parent
01ed96e839
commit
e38551b534
@ -517,7 +517,6 @@ func passwordUpdateKDF(password: String, derivation: TwoStepPasswordDerivation)
|
||||
|
||||
let nextSalt2 = salt2
|
||||
|
||||
|
||||
var g = Data(count: 4)
|
||||
g.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<Int8>) -> Void in
|
||||
var gValue = gValue
|
||||
@ -529,13 +528,13 @@ func passwordUpdateKDF(password: String, derivation: TwoStepPasswordDerivation)
|
||||
})
|
||||
}
|
||||
|
||||
let pbkdfInnerData = sha256Digest(salt2 + sha256Digest(salt1 + passwordData + salt1) + salt2)
|
||||
let pbkdfInnerData = sha256Digest(nextSalt2 + sha256Digest(nextSalt1 + passwordData + nextSalt1) + nextSalt2)
|
||||
|
||||
guard let pbkdfResult = MTPBKDF2(pbkdfInnerData, salt1, iterations) else {
|
||||
guard let pbkdfResult = MTPBKDF2(pbkdfInnerData, nextSalt1, iterations) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let x = sha256Digest(salt2 + pbkdfResult + salt2)
|
||||
let x = sha256Digest(nextSalt2 + pbkdfResult + nextSalt2)
|
||||
|
||||
let gx = MTExp(g, x, p)!
|
||||
|
||||
@ -611,7 +610,6 @@ func passwordKDF(password: String, derivation: TwoStepPasswordDerivation, srpSes
|
||||
let A = paddedToLength(what: MTExp(g, a, p)!, to: p)
|
||||
let u = sha256Digest(A + B)
|
||||
|
||||
// x = sha256(salt2 + pbkdf2(sha256(salt2 + sha256(salt1 + password + salt1) + salt2), salt1, 100000, sha512) + salt2)
|
||||
let pbkdfInnerData = sha256Digest(salt2 + sha256Digest(salt1 + passwordData + salt1) + salt2)
|
||||
|
||||
guard let pbkdfResult = MTPBKDF2(pbkdfInnerData, salt1, iterations) else {
|
||||
|
@ -35,7 +35,12 @@ static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char*
|
||||
#if kShouldPrintReachabilityFlags
|
||||
|
||||
NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
|
||||
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
|
||||
#if TARGET_OS_IPHONE
|
||||
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-'
|
||||
#else
|
||||
'-'
|
||||
#endif
|
||||
,
|
||||
(flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
|
||||
|
||||
(flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
|
||||
@ -306,6 +311,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
|
||||
{
|
||||
/*
|
||||
@ -313,6 +319,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
|
||||
*/
|
||||
returnValue = ReachableViaWWAN;
|
||||
}
|
||||
#endif
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
@ -103,17 +103,26 @@ public func updateTwoStepVerificationPassword(network: Network, currentPassword:
|
||||
|> mapError { _ -> UpdateTwoStepVerificationPasswordError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { authData -> Signal<(TwoStepAuthData, TwoStepVerificationSecureSecret?), UpdateTwoStepVerificationPasswordError> in
|
||||
|> mapToSignal { authData -> Signal<TwoStepVerificationSecureSecret?, UpdateTwoStepVerificationPasswordError> in
|
||||
if let _ = authData.currentPasswordDerivation {
|
||||
return requestTwoStepVerifiationSettings(network: network, password: currentPassword ?? "")
|
||||
|> mapError { _ -> UpdateTwoStepVerificationPasswordError in
|
||||
return .generic
|
||||
}
|
||||
|> map { settings in
|
||||
return (authData, settings.secureSecret)
|
||||
return settings.secureSecret
|
||||
}
|
||||
} else {
|
||||
return .single((authData, nil))
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { secureSecret -> Signal<(TwoStepAuthData, TwoStepVerificationSecureSecret?), UpdateTwoStepVerificationPasswordError> in
|
||||
return twoStepAuthData(network)
|
||||
|> mapError { _ -> UpdateTwoStepVerificationPasswordError in
|
||||
return .generic
|
||||
}
|
||||
|> map { authData -> (TwoStepAuthData, TwoStepVerificationSecureSecret?) in
|
||||
return (authData, secureSecret)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { authData, secureSecret -> Signal<UpdateTwoStepVerificationPasswordResult, UpdateTwoStepVerificationPasswordError> in
|
||||
@ -171,7 +180,7 @@ public func updateTwoStepVerificationPassword(network: Network, currentPassword:
|
||||
updatedSecureSettings = .secureSecretSettings(secureAlgo: updatedSecureSecret.derivation.apiAlgo, secureSecret: Buffer(data: updatedSecureSecret.data), secureSecretId: updatedSecureSecret.id)
|
||||
}
|
||||
|
||||
return network.request(Api.functions.account.updatePasswordSettings(password: .inputCheckPasswordEmpty, newSettings: Api.account.PasswordInputSettings.passwordInputSettings(flags: flags, newAlgo: updatedPasswordDerivation.apiAlgo, newPasswordHash: Buffer(data: updatedPasswordHash), hint: hint, email: email, newSecureSettings: updatedSecureSettings)), automaticFloodWait: false)
|
||||
return network.request(Api.functions.account.updatePasswordSettings(password: checkPassword, newSettings: Api.account.PasswordInputSettings.passwordInputSettings(flags: flags, newAlgo: updatedPasswordDerivation.apiAlgo, newPasswordHash: Buffer(data: updatedPasswordHash), hint: hint, email: email, newSecureSettings: updatedSecureSettings)), automaticFloodWait: false)
|
||||
|> map { _ -> UpdateTwoStepVerificationPasswordResult in
|
||||
return .password(password: password, pendingEmailPattern: nil)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user