Skip to content

Commit afb394d

Browse files
committed
ZIP formats: Report cost (data size) in KiB
The cost functions use unsigned int, so can't describe 4 GiB or larger correctly without this. Closes #5733
1 parent 3c58b05 commit afb394d

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

src/opencl_zip_fmt_plug.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,6 @@ static int cmp_exact(char *source, int index)
374374
}
375375

376376

377-
static unsigned int cost_hmac_len(void *salt)
378-
{
379-
winzip_salt *s = *((winzip_salt**)salt);
380-
381-
return s->comp_len;
382-
}
383-
384377
struct fmt_main fmt_opencl_zip = {
385378
{
386379
FORMAT_LABEL,
@@ -398,7 +391,7 @@ struct fmt_main fmt_opencl_zip = {
398391
MAX_KEYS_PER_CRYPT,
399392
FMT_CASE | FMT_8_BIT | FMT_DYNA_SALT | FMT_HUGE_INPUT,
400393
{
401-
"HMAC size"
394+
"HMAC size [KiB]"
402395
},
403396
{ WINZIP_FORMAT_TAG },
404397
winzip_common_tests
@@ -412,7 +405,7 @@ struct fmt_main fmt_opencl_zip = {
412405
winzip_common_binary,
413406
winzip_common_get_salt,
414407
{
415-
cost_hmac_len
408+
winzip_common_cost_hmac_len
416409
},
417410
fmt_default_source,
418411
{

src/pkzip.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,10 @@ void *winzip_common_binary(char *ciphertext) {
248248
}
249249
return bin;
250250
}
251+
252+
unsigned int winzip_common_cost_hmac_len(void *salt)
253+
{
254+
winzip_salt *s = *((winzip_salt**)salt);
255+
256+
return (s->comp_len + 1023) / 1024;
257+
}

src/pkzip.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern int winzip_common_valid(char *ciphertext, struct fmt_main *self);
106106
extern char *winzip_common_split(char *ciphertext, int index, struct fmt_main *self);
107107
extern void *winzip_common_binary(char *ciphertext);
108108
extern void *winzip_common_get_salt(char *ciphertext);
109+
extern unsigned int winzip_common_cost_hmac_len(void *salt);
109110

110111
extern struct fmt_tests winzip_common_tests[];
111112

src/zip_fmt_plug.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,6 @@ static int cmp_exact(char *source, int index)
208208
return 1;
209209
}
210210

211-
static unsigned int cost_hmac_len(void *salt)
212-
{
213-
winzip_salt *s = *((winzip_salt**)salt);
214-
215-
return s->comp_len;
216-
}
217-
218211
struct fmt_main fmt_zip = {
219212
{
220213
FORMAT_LABEL,
@@ -232,7 +225,7 @@ struct fmt_main fmt_zip = {
232225
MAX_KEYS_PER_CRYPT,
233226
FMT_CASE | FMT_8_BIT | FMT_OMP | FMT_DYNA_SALT | FMT_HUGE_INPUT,
234227
{
235-
"HMAC size"
228+
"HMAC size [KiB]"
236229
},
237230
{ WINZIP_FORMAT_TAG },
238231
winzip_common_tests
@@ -246,7 +239,7 @@ struct fmt_main fmt_zip = {
246239
winzip_common_binary,
247240
winzip_common_get_salt,
248241
{
249-
cost_hmac_len
242+
winzip_common_cost_hmac_len
250243
},
251244
fmt_default_source,
252245
{

0 commit comments

Comments
 (0)