mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2025-01-03 14:17:37 +00:00
Rename variable j
to something more descriptive
Remove `+ 1` in conditions, easier to understand using the comparators
This commit is contained in:
parent
a66224d549
commit
35cf8572bf
@ -84,7 +84,7 @@ int main(int argc, char *argv[])
|
||||
int ic=0; // iterative count
|
||||
int result_len;
|
||||
unsigned char *result; // result (binary - 32+16 chars)
|
||||
int i, j;
|
||||
int i, pw_lenght;
|
||||
|
||||
if ( argc != 4 ) {
|
||||
fprintf(stderr, "usage: %s salt count len <passwd >binary_key_iv\n", argv[0]);
|
||||
@ -115,21 +115,21 @@ int main(int argc, char *argv[])
|
||||
*
|
||||
* passwords containing just a bunch of spaces are valid
|
||||
*/
|
||||
while (j < (BUFFER_SIZE + 1)) {
|
||||
while (pw_lenght <= BUFFER_SIZE) {
|
||||
char c = getchar();
|
||||
if (c == EOF) break;
|
||||
pass[j] = c;
|
||||
j++;
|
||||
pass[pw_lenght] = c;
|
||||
pw_lenght++;
|
||||
}
|
||||
if (j >= BUFFER_SIZE + 1) {
|
||||
if (pw_lenght > BUFFER_SIZE) {
|
||||
fprintf(stderr, "Error: password is too long\n");
|
||||
exit(1);
|
||||
}
|
||||
if (j <= 1) {
|
||||
if (pw_lenght <= 1) {
|
||||
fprintf(stderr, "Error: password is empty\n");
|
||||
exit(1);
|
||||
}
|
||||
pass[j-1] = '\0';
|
||||
pass[pw_lenght-1] = '\0';
|
||||
|
||||
// PBKDF 2
|
||||
result = calloc(result_len, sizeof(unsigned char*));
|
||||
@ -146,7 +146,7 @@ int main(int argc, char *argv[])
|
||||
/* Tell Libgcrypt that initialization has completed. */
|
||||
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
||||
|
||||
gcry_kdf_derive(pass, j-1, GCRY_KDF_PBKDF2, GCRY_MD_SHA1, salt, salt_len, ic, result_len, result);
|
||||
gcry_kdf_derive(pass, pw_lenght-1, GCRY_KDF_PBKDF2, GCRY_MD_SHA1, salt, salt_len, ic, result_len, result);
|
||||
print_hex(result, result_len); // Key + IV (as hex string)
|
||||
|
||||
//clear and free everything
|
||||
|
Loading…
Reference in New Issue
Block a user