Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request #405 from loki-47-6F-64/master
Don't send PIN to GFE
  • Loading branch information
cgutman committed Apr 17, 2020
2 parents fdaf7f9 + 1366ede commit b0149b2
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions Limelight/Network/PairManager.m
Expand Up @@ -91,8 +91,10 @@ - (void) initiatePairWithPin:(NSString*)PIN forServerMajorVersion:(int)serverMaj
Log(LOG_W, @"Background pairing time has expired!");
}];

NSData* salt = [self saltPIN:PIN];
Log(LOG_I, @"PIN: %@, saltedPIN: %@", PIN, salt);
NSData* salt = [Utils randomBytes:16];
NSData* saltedPIN = [self concatData:salt with:[PIN dataUsingEncoding:NSUTF8StringEncoding]];

Log(LOG_I, @"PIN: %@, salt %@", PIN, salt);

HttpResponse* pairResp = [[HttpResponse alloc] init];
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:pairResp withUrlRequest:[_httpManager newPairRequest:salt clientCert:_clientCert]]];
Expand All @@ -117,11 +119,11 @@ - (void) initiatePairWithPin:(NSString*)PIN forServerMajorVersion:(int)serverMaj
// Gen 7 servers use SHA256 to get the key
int hashLength;
if (serverMajorVersion >= 7) {
aesKey = [cryptoMan createAESKeyFromSaltSHA256:salt];
aesKey = [cryptoMan createAESKeyFromSaltSHA256:saltedPIN];
hashLength = 32;
}
else {
aesKey = [cryptoMan createAESKeyFromSaltSHA1:salt];
aesKey = [cryptoMan createAESKeyFromSaltSHA1:saltedPIN];
hashLength = 20;
}

Expand Down Expand Up @@ -227,11 +229,4 @@ - (NSString*) generatePIN {
return PIN;
}

- (NSData*) saltPIN:(NSString*)PIN {
NSMutableData* saltedPIN = [[NSMutableData alloc] initWithCapacity:20];
[saltedPIN appendData:[Utils randomBytes:16]];
[saltedPIN appendBytes:[PIN UTF8String] length:4];
return saltedPIN;
}

@end

0 comments on commit b0149b2

Please sign in to comment.