summaryrefslogtreecommitdiffstats
path: root/crypto/scrypt/patches/use_openssl_pbkdf2.patch
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2013-11-10 05:11:43 +0100
committerDees Troy <dees_troy@teamw.in>2013-11-10 05:11:48 +0100
commit4dff2e6234b4caf7201be2c17fde18d637b76c3d (patch)
tree3dec41365d7a597a0c4ff8b3c6fdd2d801623b29 /crypto/scrypt/patches/use_openssl_pbkdf2.patch
parentAdd reboot binary if it exists to recovery (diff)
downloadandroid_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.tar
android_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.tar.gz
android_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.tar.bz2
android_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.tar.lz
android_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.tar.xz
android_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.tar.zst
android_bootable_recovery-4dff2e6234b4caf7201be2c17fde18d637b76c3d.zip
Diffstat (limited to 'crypto/scrypt/patches/use_openssl_pbkdf2.patch')
-rw-r--r--crypto/scrypt/patches/use_openssl_pbkdf2.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/crypto/scrypt/patches/use_openssl_pbkdf2.patch b/crypto/scrypt/patches/use_openssl_pbkdf2.patch
new file mode 100644
index 000000000..0a1328cc0
--- /dev/null
+++ b/crypto/scrypt/patches/use_openssl_pbkdf2.patch
@@ -0,0 +1,80 @@
+diff --git a/lib/crypto/crypto_scrypt-ref.c b/lib/crypto/crypto_scrypt-ref.c
+index 79a6f8f..60ef2aa 100644
+--- a/lib/crypto/crypto_scrypt-ref.c
++++ b/lib/crypto/crypto_scrypt-ref.c
+@@ -34,7 +34,11 @@
+ #include <stdlib.h>
+ #include <string.h>
+
++#ifdef USE_OPENSSL_PBKDF2
++#include <openssl/evp.h>
++#else
+ #include "sha256.h"
++#endif
+ #include "sysendian.h"
+
+ #include "crypto_scrypt.h"
+@@ -256,7 +260,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
+ goto err2;
+
+ /* 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) */
++#ifdef USE_OPENSSL_PBKDF2
++ PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, salt, saltlen, 1, EVP_sha256(), p * 128 * r, B);
++#else
+ PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, 1, B, p * 128 * r);
++#endif
+
+ /* 2: for i = 0 to p - 1 do */
+ for (i = 0; i < p; i++) {
+@@ -265,7 +273,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
+ }
+
+ /* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
++#ifdef USE_OPENSSL_PBKDF2
++ PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, B, p * 128 * r, 1, EVP_sha256(), buflen, buf);
++#else
+ PBKDF2_SHA256(passwd, passwdlen, B, p * 128 * r, 1, buf, buflen);
++#endif
+
+ /* Free memory. */
+ free(V);
+diff --git a/lib/crypto/crypto_scrypt-sse.c b/lib/crypto/crypto_scrypt-sse.c
+index 875175e..dd18f29 100644
+--- a/lib/crypto/crypto_scrypt-sse.c
++++ b/lib/crypto/crypto_scrypt-sse.c
+@@ -37,7 +37,11 @@
+ #include <stdlib.h>
+ #include <string.h>
+
++#ifdef USE_OPENSSL_PBKDF2
++#include <openssl/evp.h>
++#else
+ #include "sha256.h"
++#endif
+ #include "sysendian.h"
+
+ #include "crypto_scrypt.h"
+@@ -332,7 +336,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
+ #endif
+
+ /* 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) */
++#ifdef USE_OPENSSL_PBKDF2
++ PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, salt, saltlen, 1, EVP_sha256(), p * 128 * r, B);
++#else
+ PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, 1, B, p * 128 * r);
++#endif
+
+ /* 2: for i = 0 to p - 1 do */
+ for (i = 0; i < p; i++) {
+@@ -341,7 +349,11 @@ crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
+ }
+
+ /* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
++#ifdef USE_OPENSSL_PBKDF2
++ PKCS5_PBKDF2_HMAC((const char *)passwd, passwdlen, B, p * 128 * r, 1, EVP_sha256(), buflen, buf);
++#else
+ PBKDF2_SHA256(passwd, passwdlen, B, p * 128 * r, 1, buf, buflen);
++#endif
+
+ /* Free memory. */
+ #ifdef MAP_ANON