(fix) handle sha512-crypt with rounds
This commit is contained in:
parent
071c1032c1
commit
9fbc84158a
|
@ -721,7 +721,7 @@ static void _nettle_md5_compress(uint32_t *digest, const uint8_t *input);
|
|||
|
||||
cryptParts = [cryptString componentsSeparatedByString: @"$"];
|
||||
// correct number of elements (first one is an empty string)
|
||||
if ([cryptParts count] != 4)
|
||||
if ([cryptParts count] < 4)
|
||||
{
|
||||
return [NSData data];
|
||||
}
|
||||
|
@ -731,7 +731,16 @@ static void _nettle_md5_compress(uint32_t *digest, const uint8_t *input);
|
|||
[[cryptParts objectAtIndex: 1] caseInsensitiveCompare: @"6"] == NSOrderedSame)
|
||||
{
|
||||
// third is the salt; convert it to NSData
|
||||
if ([cryptParts count] == 4)
|
||||
return [[cryptParts objectAtIndex: 2] dataUsingEncoding: NSUTF8StringEncoding];
|
||||
else
|
||||
{
|
||||
NSString *saltWithRounds;
|
||||
|
||||
saltWithRounds = [NSString stringWithFormat: @"%@$%@", [cryptParts objectAtIndex: 2], [cryptParts objectAtIndex: 3]];
|
||||
|
||||
return [saltWithRounds dataUsingEncoding: NSUTF8StringEncoding];
|
||||
}
|
||||
}
|
||||
// nothing good
|
||||
return [NSData data];
|
||||
|
|
Loading…
Reference in a new issue