• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/lib/crypto/crypto_scrypt-ref.c b/lib/crypto/crypto_scrypt-ref.c
2index 79a6f8f..60ef2aa 100644
3--- a/lib/crypto/crypto_scrypt-ref.c
4+++ b/lib/crypto/crypto_scrypt-ref.c
5@@ -34,7 +34,11 @@
6 #include <stdlib.h>
7 #include <string.h>
8
9+#ifdef USE_OPENSSL_PBKDF2
10+#include <openssl/evp.h>
11+#else
12 #include "sha256.h"
13+#endif
14 #include "sysendian.h"
15
16 #include "crypto_scrypt.h"
17@@ -256,7 +260,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
18 		goto err2;
19
20 	/* 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) */
21+#ifdef USE_OPENSSL_PBKDF2
22+	PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, salt, saltlen, 1, EVP_sha256(), p * 128 * r, B);
23+#else
24 	PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, 1, B, p * 128 * r);
25+#endif
26
27 	/* 2: for i = 0 to p - 1 do */
28 	for (i = 0; i < p; i++) {
29@@ -265,7 +273,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
30 	}
31
32 	/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
33+#ifdef USE_OPENSSL_PBKDF2
34+	PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, B, p * 128 * r, 1, EVP_sha256(), buflen, buf);
35+#else
36 	PBKDF2_SHA256(passwd, passwdlen, B, p * 128 * r, 1, buf, buflen);
37+#endif
38
39 	/* Free memory. */
40 	free(V);
41diff --git a/lib/crypto/crypto_scrypt-sse.c b/lib/crypto/crypto_scrypt-sse.c
42index 875175e..dd18f29 100644
43--- a/lib/crypto/crypto_scrypt-sse.c
44+++ b/lib/crypto/crypto_scrypt-sse.c
45@@ -37,7 +37,11 @@
46 #include <stdlib.h>
47 #include <string.h>
48
49+#ifdef USE_OPENSSL_PBKDF2
50+#include <openssl/evp.h>
51+#else
52 #include "sha256.h"
53+#endif
54 #include "sysendian.h"
55
56 #include "crypto_scrypt.h"
57@@ -332,7 +336,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
58 #endif
59
60 	/* 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) */
61+#ifdef USE_OPENSSL_PBKDF2
62+	PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, salt, saltlen, 1, EVP_sha256(), p * 128 * r, B);
63+#else
64 	PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, 1, B, p * 128 * r);
65+#endif
66
67 	/* 2: for i = 0 to p - 1 do */
68 	for (i = 0; i < p; i++) {
69@@ -341,7 +349,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
70 	}
71
72 	/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
73+#ifdef USE_OPENSSL_PBKDF2
74+	PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, B, p * 128 * r, 1, EVP_sha256(), buflen, buf);
75+#else
76 	PBKDF2_SHA256(passwd, passwdlen, B, p * 128 * r, 1, buf, buflen);
77+#endif
78
79 	/* Free memory. */
80 #ifdef MAP_ANON
81