{"action":"created","issue":{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1063","labels_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1063/labels{/name}","comments_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1063/comments","events_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1063/events","html_url":"https://github.com/magnumripper/JohnTheRipper/issues/1063","id":58631618,"number":1063,"title":"HMAC-SHA384 intermittent failures","user":{"login":"magnumripper","id":1268598,"avatar_url":"https://avatars.githubusercontent.com/u/1268598?v=3","gravatar_id":"","url":"https://api.github.com/users/magnumripper","html_url":"https://github.com/magnumripper","followers_url":"https://api.github.com/users/magnumripper/followers","following_url":"https://api.github.com/users/magnumripper/following{/other_user}","gists_url":"https://api.github.com/users/magnumripper/gists{/gist_id}","starred_url":"https://api.github.com/users/magnumripper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magnumripper/subscriptions","organizations_url":"https://api.github.com/users/magnumripper/orgs","repos_url":"https://api.github.com/users/magnumripper/repos","events_url":"https://api.github.com/users/magnumripper/events{/privacy}","received_events_url":"https://api.github.com/users/magnumripper/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/labels/bug","name":"bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"jfoug","id":1270024,"avatar_url":"https://avatars.githubusercontent.com/u/1270024?v=3","gravatar_id":"","url":"https://api.github.com/users/jfoug","html_url":"https://github.com/jfoug","followers_url":"https://api.github.com/users/jfoug/followers","following_url":"https://api.github.com/users/jfoug/following{/other_user}","gists_url":"https://api.github.com/users/jfoug/gists{/gist_id}","starred_url":"https://api.github.com/users/jfoug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfoug/subscriptions","organizations_url":"https://api.github.com/users/jfoug/orgs","repos_url":"https://api.github.com/users/jfoug/repos","events_url":"https://api.github.com/users/jfoug/events{/privacy}","received_events_url":"https://api.github.com/users/jfoug/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2015-02-23T19:01:02Z","updated_at":"2015-02-24T20:20:17Z","closed_at":"2015-02-24T18:18:29Z","body":"We still have some OpenMP problem with HMAC-SHA384. Running one thread seems to always be OK (even with OMP build) but two or more threads will fail more often than not. They fail in different places and with different test vectors.\r\n\r\nEasily reproducible with `--stress-test=0` instead of `--test`"},"comment":{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/comments/75837393","html_url":"https://github.com/magnumripper/JohnTheRipper/issues/1063#issuecomment-75837393","issue_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1063","id":75837393,"user":{"login":"magnumripper","id":1268598,"avatar_url":"https://avatars.githubusercontent.com/u/1268598?v=3","gravatar_id":"","url":"https://api.github.com/users/magnumripper","html_url":"https://github.com/magnumripper","followers_url":"https://api.github.com/users/magnumripper/followers","following_url":"https://api.github.com/users/magnumripper/following{/other_user}","gists_url":"https://api.github.com/users/magnumripper/gists{/gist_id}","starred_url":"https://api.github.com/users/magnumripper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magnumripper/subscriptions","organizations_url":"https://api.github.com/users/magnumripper/orgs","repos_url":"https://api.github.com/users/magnumripper/repos","events_url":"https://api.github.com/users/magnumripper/events{/privacy}","received_events_url":"https://api.github.com/users/magnumripper/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T20:20:17Z","updated_at":"2015-02-24T20:20:17Z","body":"Here's the net changes for SHA384 over the last three commits\r\n```diff\r\ndiff --git a/src/hmacSHA384_fmt_plug.c b/src/hmacSHA384_fmt_plug.c\r\nindex df1caa3..e468fe5 100644\r\n--- a/src/hmacSHA384_fmt_plug.c\r\n+++ b/src/hmacSHA384_fmt_plug.c\r\n@@ -26,7 +26,7 @@ john_register_one(&fmt_hmacSHA384);\r\n #ifdef _OPENMP\r\n #include <omp.h>\r\n #ifdef MMX_COEF_SHA512\r\n-#define OMP_SCALE               1024 // scaled on scaled core i7-quad HT\r\n+#define OMP_SCALE               1024 // scaled on core i7-quad HT\r\n #else\r\n #define OMP_SCALE               512 // scaled K8-dual HT\r\n #endif\r\n@@ -45,6 +45,7 @@ john_register_one(&fmt_hmacSHA384);\r\n \r\n #define PAD_SIZE\t\t\t128\r\n #define BINARY_SIZE\t\t\t(384/8)\r\n+#define BINARY_SIZE_512\t\t\t(512/8)\r\n #define BINARY_ALIGN\t\t\t8\r\n \r\n #ifndef MMX_COEF_SHA512\r\n@@ -115,8 +116,8 @@ static void init(struct fmt_main *self)\r\n \tcrypt_key = mem_calloc_tiny(bufsize, MEM_ALIGN_SIMD);\r\n \tipad = mem_calloc_tiny(bufsize, MEM_ALIGN_SIMD);\r\n \topad = mem_calloc_tiny(bufsize, MEM_ALIGN_SIMD);\r\n-\tprep_ipad = mem_calloc_tiny(sizeof(*prep_ipad) * self->params.max_keys_per_crypt * PAD_SIZE, MEM_ALIGN_SIMD);\r\n-\tprep_opad = mem_calloc_tiny(sizeof(*prep_opad) * self->params.max_keys_per_crypt * PAD_SIZE, MEM_ALIGN_SIMD);\r\n+\tprep_ipad = mem_calloc_tiny(sizeof(*prep_ipad) * self->params.max_keys_per_crypt * BINARY_SIZE_512, MEM_ALIGN_SIMD);\r\n+\tprep_opad = mem_calloc_tiny(sizeof(*prep_opad) * self->params.max_keys_per_crypt * BINARY_SIZE_512, MEM_ALIGN_SIMD);\r\n \tfor (i = 0; i < self->params.max_keys_per_crypt; ++i) {\r\n \t\tcrypt_key[GETPOS(BINARY_SIZE, i)] = 0x80;\r\n \t\t((ARCH_WORD_64*)crypt_key)[15 * MMX_COEF_SHA512 + (i & (MMX_COEF_SHA512-1)) + (i >> (MMX_COEF_SHA512>>1)) * SHA512_BUF_SIZ * MMX_COEF_SHA512] = (BINARY_SIZE + PAD_SIZE) << 3;\r\n@@ -187,6 +188,7 @@ static void set_key(char *key, int index)\r\n \tmemcpy(saved_plain[index], key, len);\r\n \tsaved_plain[index][len] = 0;\r\n \r\n+#if PAD_SIZE < PLAINTEXT_LENGTH\r\n \tif (len > PAD_SIZE) {\r\n \t\tunsigned char k0[BINARY_SIZE];\r\n \t\tSHA512_CTX ctx;\r\n@@ -205,6 +207,7 @@ static void set_key(char *key, int index)\r\n \t\t}\r\n \t}\r\n \telse\r\n+#endif\r\n \twhile(((temp = JOHNSWAP64(*keyp++)) & 0xff00000000000000)) {\r\n \t\tif (!(temp & 0x00ff000000000000) || !(temp & 0x0000ff0000000000))\r\n \t\t{\r\n@@ -251,6 +254,7 @@ static void set_key(char *key, int index)\r\n \tmemset(ipad[index], 0x36, PAD_SIZE);\r\n \tmemset(opad[index], 0x5C, PAD_SIZE);\r\n \r\n+#if PAD_SIZE < PLAINTEXT_LENGTH\r\n \tif (len > PAD_SIZE) {\r\n \t\tSHA512_CTX ctx;\r\n \t\tunsigned char k0[BINARY_SIZE];\r\n@@ -268,6 +272,7 @@ static void set_key(char *key, int index)\r\n \t\t}\r\n \t}\r\n \telse\r\n+#endif\r\n \tfor(i=0;i<len;i++)\r\n \t{\r\n \t\tipad[index][i] ^= key[i];\r\n@@ -330,7 +335,6 @@ static int crypt_all(int *pcount, struct db_salt *salt)\r\n {\r\n \tint count = *pcount;\r\n \tint index = 0;\r\n-\tint local_new_keys = new_keys;\r\n #if defined(_OPENMP) || MAX_KEYS_PER_CRYPT > 1\r\n \tint inc = 1;\r\n #endif\r\n@@ -348,17 +352,17 @@ static int crypt_all(int *pcount, struct db_salt *salt)\r\n \t{\r\n #ifdef MMX_COEF_SHA512\r\n \t\tARCH_WORD_64 *pclear;\r\n-\t\tif (local_new_keys) {\r\n+\t\tif (new_keys) {\r\n \t\t\tSSESHA512body(&ipad[index * SHA512_BUF_SIZ * 8],\r\n-\t\t\t            (ARCH_WORD_64*)&prep_ipad[index * BINARY_SIZE],\r\n+\t\t\t            (ARCH_WORD_64*)&prep_ipad[index * BINARY_SIZE_512],\r\n \t\t\t            NULL, SSEi_MIXED_IN|SSEi_CRYPT_SHA384);\r\n \t\t\tSSESHA512body(&opad[index * SHA512_BUF_SIZ * 8],\r\n-\t\t\t            (ARCH_WORD_64*)&prep_opad[index * BINARY_SIZE],\r\n+\t\t\t            (ARCH_WORD_64*)&prep_opad[index * BINARY_SIZE_512],\r\n \t\t\t            NULL, SSEi_MIXED_IN|SSEi_CRYPT_SHA384);\r\n \t\t}\r\n \t\tSSESHA512body(cur_salt,\r\n \t\t            (ARCH_WORD_64*)&crypt_key[index * SHA512_BUF_SIZ * 8],\r\n-\t\t            (ARCH_WORD_64*)&prep_ipad[index * BINARY_SIZE],\r\n+\t\t            (ARCH_WORD_64*)&prep_ipad[index * BINARY_SIZE_512],\r\n \t\t            SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT);\r\n \t\t// NOTE, SSESHA384 will output 64 bytes. We need the first 48 (plus the 0x80 padding).\r\n \t\t// so we are forced to 'clean' this crap up, before using the crypt as the input.\r\n@@ -368,7 +372,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)\r\n \t\tpclear[14] = pclear[15] = 0;\r\n \t\tSSESHA512body(&crypt_key[index * SHA512_BUF_SIZ * 8],\r\n \t\t            (ARCH_WORD_64*)&crypt_key[index * SHA512_BUF_SIZ * 8],\r\n-\t\t            (ARCH_WORD_64*)&prep_opad[index * BINARY_SIZE],\r\n+\t\t            (ARCH_WORD_64*)&prep_opad[index * BINARY_SIZE_512],\r\n \t\t            SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT);\r\n #else\r\n \t\tSHA512_CTX ctx;\r\n@@ -462,7 +466,6 @@ static int get_hash_5(int index) { return crypt_key[index][0] & 0xffffff; }\r\n static int get_hash_6(int index) { return crypt_key[index][0] & 0x7ffffff; }\r\n #endif\r\n \r\n-\r\n struct fmt_main fmt_hmacSHA384 = {\r\n \t{\r\n \t\tFORMAT_LABEL,\r\n```\r\nWe just needed to use BINARY_SIZE_512 for SHA384 ipad/opad just like we need to use BINARY_SIZE_256 in the SHA224 format."}}