Skip to content

Commit b0149b2

Browse files
authored
Merge pull request #405 from loki-47-6F-64/master
Don't send PIN to GFE
2 parents fdaf7f9 + 1366ede commit b0149b2

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Diff for: Limelight/Network/PairManager.m

+6-11
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ - (void) initiatePairWithPin:(NSString*)PIN forServerMajorVersion:(int)serverMaj
9191
Log(LOG_W, @"Background pairing time has expired!");
9292
}];
9393

94-
NSData* salt = [self saltPIN:PIN];
95-
Log(LOG_I, @"PIN: %@, saltedPIN: %@", PIN, salt);
94+
NSData* salt = [Utils randomBytes:16];
95+
NSData* saltedPIN = [self concatData:salt with:[PIN dataUsingEncoding:NSUTF8StringEncoding]];
96+
97+
Log(LOG_I, @"PIN: %@, salt %@", PIN, salt);
9698

9799
HttpResponse* pairResp = [[HttpResponse alloc] init];
98100
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:pairResp withUrlRequest:[_httpManager newPairRequest:salt clientCert:_clientCert]]];
@@ -117,11 +119,11 @@ - (void) initiatePairWithPin:(NSString*)PIN forServerMajorVersion:(int)serverMaj
117119
// Gen 7 servers use SHA256 to get the key
118120
int hashLength;
119121
if (serverMajorVersion >= 7) {
120-
aesKey = [cryptoMan createAESKeyFromSaltSHA256:salt];
122+
aesKey = [cryptoMan createAESKeyFromSaltSHA256:saltedPIN];
121123
hashLength = 32;
122124
}
123125
else {
124-
aesKey = [cryptoMan createAESKeyFromSaltSHA1:salt];
126+
aesKey = [cryptoMan createAESKeyFromSaltSHA1:saltedPIN];
125127
hashLength = 20;
126128
}
127129

@@ -227,11 +229,4 @@ - (NSString*) generatePIN {
227229
return PIN;
228230
}
229231

230-
- (NSData*) saltPIN:(NSString*)PIN {
231-
NSMutableData* saltedPIN = [[NSMutableData alloc] initWithCapacity:20];
232-
[saltedPIN appendData:[Utils randomBytes:16]];
233-
[saltedPIN appendBytes:[PIN UTF8String] length:4];
234-
return saltedPIN;
235-
}
236-
237232
@end

0 commit comments

Comments
 (0)