summaryrefslogtreecommitdiff
path: root/other/fun/cracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'other/fun/cracker.c')
-rw-r--r--other/fun/cracker.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/other/fun/cracker.c b/other/fun/cracker.c
index 843b9359..7b020bb7 100644
--- a/other/fun/cracker.c
+++ b/other/fun/cracker.c
@@ -13,8 +13,8 @@
13#include <time.h> 13#include <time.h>
14 14
15/* NaCl includes*/ 15/* NaCl includes*/
16#include <crypto_scalarmult_curve25519.h> 16#include <sodium/crypto_scalarmult_curve25519.h>
17#include <randombytes.h> 17#include <sodium/randombytes.h>
18 18
19/* Sodium include*/ 19/* Sodium include*/
20//#include <sodium.h> 20//#include <sodium.h>
@@ -42,8 +42,9 @@ int main(int argc, char *argv[])
42 unsigned char *key = hex_string_to_bin(argv[1]); 42 unsigned char *key = hex_string_to_bin(argv[1]);
43 uint8_t pub_key[32], priv_key[32], c_key[32]; 43 uint8_t pub_key[32], priv_key[32], c_key[32];
44 44
45 if (len > 32) 45 if (len > 32) {
46 len = 32; 46 len = 32;
47 }
47 48
48 memcpy(c_key, key, len); 49 memcpy(c_key, key, len);
49 free(key); 50 free(key);
@@ -53,14 +54,16 @@ int main(int argc, char *argv[])
53 crypto_scalarmult_curve25519_base(pub_key, priv_key); 54 crypto_scalarmult_curve25519_base(pub_key, priv_key);
54 uint32_t i; 55 uint32_t i;
55 56
56 if (memcmp(c_key, pub_key, len) == 0) 57 if (memcmp(c_key, pub_key, len) == 0) {
57 break; 58 break;
59 }
58 60
59 for (i = 32; i != 0; --i) { 61 for (i = 32; i != 0; --i) {
60 priv_key[i - 1] += 1; 62 priv_key[i - 1] += 1;
61 63
62 if (priv_key[i - 1] != 0) 64 if (priv_key[i - 1] != 0) {
63 break; 65 break;
66 }
64 } 67 }
65 68
66 ++num_tries; 69 ++num_tries;