summaryrefslogtreecommitdiff
path: root/security/john/files/patch-wpapsk.h
blob: 3cea05c77ae895eaac91e6b75a79ee35e3531b25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--- wpapsk.h.orig	2014-10-03 01:08:17 UTC
+++ wpapsk.h
@@ -13,6 +13,9 @@
 #include "arch.h"
 #include "common.h"
 #include "johnswap.h"
+#include "md5.h"
+#include "hmacmd5.h"
+#include "pbkdf2_hmac_sha1.h"
 #include "stdint.h"
 
 #include <assert.h>
@@ -200,7 +203,6 @@ static int valid(char *ciphertext, struct fmt_main *se
 #ifndef JOHN_OCL_WPAPSK
 static MAYBE_INLINE void prf_512(uint32_t * key, uint8_t * data, uint32_t * ret)
 {
-	HMAC_CTX ctx;
 	char *text = (char*)"Pairwise key expansion";
 	unsigned char buff[100];
 
@@ -208,10 +210,7 @@ static MAYBE_INLINE void prf_512(uint32_t * key, uint8
 	memcpy(buff + 23, data, 76);
 	buff[22] = 0;
 	buff[76 + 23] = 0;
-	HMAC_Init(&ctx, key, 32, EVP_sha1());
-	HMAC_Update(&ctx, buff, 100);
-	HMAC_Final(&ctx, (unsigned char *) ret, NULL);
-	HMAC_CTX_cleanup(&ctx);
+	hmac_sha1((unsigned char*)key, 32, buff, 100, (unsigned char*)ret, 20);
 }
 #endif
 
@@ -346,9 +345,12 @@ static void wpapsk_postprocess(int keys)
 #endif
 		for (i = 0; i < keys; i++) {
 			uint32_t prf[20/4];
+			HMACMD5Context ctx;
+
 			prf_512(outbuffer[i].v, data, prf);
-			HMAC(EVP_md5(), prf, 16, hccap.eapol, hccap.eapol_size,
-			    mic[i].keymic, NULL);
+			hmac_md5_init_K16((unsigned char*)prf, &ctx);
+			hmac_md5_update(hccap.eapol, hccap.eapol_size, &ctx);
+			hmac_md5_final(mic[i].keymic, &ctx);
 		}
 	} else {
 #ifdef _OPENMP
@@ -356,11 +358,10 @@ static void wpapsk_postprocess(int keys)
 #endif
 		for (i = 0; i < keys; i++) {
 			uint32_t prf[20/4];
-			unsigned char keymic[20];
+
 			prf_512(outbuffer[i].v, data, prf);
-			HMAC(EVP_sha1(), prf, 16, hccap.eapol,
-			    hccap.eapol_size, keymic, NULL);
-			memcpy(mic[i].keymic, keymic, 16);
+			hmac_sha1((unsigned char*)prf, 16, hccap.eapol,
+			          hccap.eapol_size, mic[i].keymic, 16);
 		}
 	}
 }