Skip to content

Commit

Permalink
ntlmv2-opencl: Implement clear_keys() for faster buffer cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
magnumripper committed Nov 11, 2012
1 parent 67832dd commit ba10ced
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/opencl_ntlmv2_fmt.c
Expand Up @@ -123,22 +123,23 @@ static void release_clobj(void)
output = NULL; saved_key = NULL; challenge = NULL;
}

static void clear_keys(void)
{
memset(saved_key, 0, 64 * global_work_size);
}

static void set_key(char *key, int index)
{
int len;
unsigned int *utfkey = &saved_key[index * 16];

/* Clean slate */
memset(utfkey, 0, 64);

/* convert key to UTF-16LE */
len = enc_to_utf16((UTF16*)utfkey, PLAINTEXT_LENGTH, (UTF8*)key, strlen(key));
if (len < 0)
len = strlen16((UTF16*)utfkey);

/* Prepare for GPU */
((UTF16*)utfkey)[len] = 0x80;

utfkey[14] = len << 4;

new_keys = 1;
Expand Down Expand Up @@ -729,7 +730,7 @@ struct fmt_main fmt_opencl_NTLMv2 = {
set_salt,
set_key,
get_key,
fmt_default_clear_keys,
clear_keys,
crypt_all,
{
get_hash_0,
Expand Down

0 comments on commit ba10ced

Please sign in to comment.