]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
CHG: my idea of malloc and free for bucketsort didn't work so well. Back to the...
authoriceman1001 <iceman@iuse.se>
Wed, 10 Feb 2016 20:44:32 +0000 (21:44 +0100)
committericeman1001 <iceman@iuse.se>
Wed, 10 Feb 2016 20:44:32 +0000 (21:44 +0100)
client/nonce2key/crapto1.c
common/bucketsort.c
common/bucketsort.h

index 36e21a1ce9b13ddccae09772c407c72c6095c007..919820e9a12e85e05da38ae08eb5ba039909e196 100644 (file)
@@ -158,7 +158,14 @@ struct Crypto1State* lfsr_recovery32(uint32_t ks2, uint32_t in)
        // allocate memory for out of place bucket_sort\r
        bucket_array_t bucket;\r
        \r
-       if ( !bucket_malloc(bucket) ) goto out;\r
+       for (uint32_t i = 0; i < 2; i++) {\r
+               for (uint32_t j = 0; j <= 0xff; j++) {\r
+                       bucket[i][j].head = malloc(sizeof(uint32_t)<<14);\r
+                       if (!bucket[i][j].head) {\r
+                                goto out;\r
+                       }\r
+               }\r
+       }\r
 \r
        // initialize statelists: add all possible states which would result into the rightmost 2 bits of the keystream\r
        for(i = 1 << 20; i >= 0; --i) {\r
@@ -183,7 +190,9 @@ struct Crypto1State* lfsr_recovery32(uint32_t ks2, uint32_t in)
 out:\r
        free(odd_head);\r
        free(even_head);\r
-       bucket_free(bucket);\r
+       for (uint8_t i = 0; i < 2; i++)\r
+               for (uint8_t j = 0; j <= 0xff; j++)\r
+                       free(bucket[i][j].head);\r
        return statelist;\r
 }\r
 \r
index c4199803a92ab01b4de5327186f9ca498fbe17bd..2aca2632b6454b94077c043db8eada6ca5361b38 100644 (file)
@@ -1,23 +1,5 @@
 #include "bucketsort.h"
 
-bool bucket_malloc(bucket_array_t bucket) {
-       for (uint32_t i = 0; i < 2; i++) {
-               for (uint32_t j = 0; j <= 0xff; j++) {
-                       bucket[i][j].head = malloc(sizeof(uint32_t)<<14);
-                       if (!bucket[i][j].head) {
-                               return false;
-                       }
-               }
-       }
-       return true;
-}
-
-void bucket_free(bucket_array_t bucket) {
-       for (uint8_t i = 0; i < 2; i++)
-               for (uint8_t j = 0; j <= 0xff; j++)
-                       free(bucket[i][j].head);
-}
-
 void bucket_sort_intersect(uint32_t* const estart, uint32_t* const estop,
                                                                  uint32_t* const ostart, uint32_t* const ostop,
                                                                  bucket_info_t *bucket_info, bucket_array_t bucket)
index 399277c128cbeb70d9259e01dba198df9971e432..d5423aa5d8fd1e18663df46a57b51443f551a357 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef BUCKETSORT_H__
 #define BUCKETSORT_H__
 #include <stdint.h>
-#include <stdbool.h>
 #include <stdlib.h>
 typedef struct bucket {
        uint32_t *head;
@@ -17,9 +16,6 @@ typedef struct bucket_info {
                uint32_t numbuckets;
 } bucket_info_t;
 
-
-bool bucket_malloc(bucket_array_t bucket);
-void bucket_free(bucket_array_t bucket);
 void bucket_sort_intersect(uint32_t* const estart, uint32_t* const estop,
                                                                  uint32_t* const ostart, uint32_t* const ostop,
                                                                  bucket_info_t *bucket_info, bucket_array_t bucket);
Impressum, Datenschutz