diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-04-09 14:04:39 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-04-09 14:04:39 +0000 |
commit | ae64d2602befd5589c8c0141a6d812841fdfb232 (patch) | |
tree | 0392b8e1f9aaa5c0cb12d06d771538199edba09e /tools | |
parent | f617ba4a43e17fcac695be5f69cec1941834973b (diff) | |
download | rockbox-ae64d2602befd5589c8c0141a6d812841fdfb232.tar.gz rockbox-ae64d2602befd5589c8c0141a6d812841fdfb232.zip |
more code policing to stop warnings when built with -W -Wall
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17048 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r-- | tools/creative.c | 6 | ||||
-rw-r--r-- | tools/descramble.c | 10 | ||||
-rw-r--r-- | tools/hmac-sha1.c | 48 | ||||
-rw-r--r-- | tools/hmac-sha1.h | 13 |
4 files changed, 30 insertions, 47 deletions
diff --git a/tools/creative.c b/tools/creative.c index 6e0e468411..5b8f15abc0 100644 --- a/tools/creative.c +++ b/tools/creative.c | |||
@@ -52,7 +52,7 @@ extern unsigned int le2int(unsigned char* buf); | |||
52 | static int make_ciff_file(unsigned char *inbuf, int length, | 52 | static int make_ciff_file(unsigned char *inbuf, int length, |
53 | unsigned char *outbuf, int device) | 53 | unsigned char *outbuf, int device) |
54 | { | 54 | { |
55 | char key[20]; | 55 | unsigned char key[20]; |
56 | memcpy(outbuf, "FFIC", 4); | 56 | memcpy(outbuf, "FFIC", 4); |
57 | int2le(length+90, &outbuf[4]); | 57 | int2le(length+90, &outbuf[4]); |
58 | memcpy(&outbuf[8], "FNIC", 4); | 58 | memcpy(&outbuf[8], "FNIC", 4); |
@@ -68,8 +68,8 @@ static int make_ciff_file(unsigned char *inbuf, int length, | |||
68 | memcpy(&outbuf[0x98+length], "LLUN", 4); | 68 | memcpy(&outbuf[0x98+length], "LLUN", 4); |
69 | int2le(20, &outbuf[0x98+length+4]); | 69 | int2le(20, &outbuf[0x98+length+4]); |
70 | /* Do checksum */ | 70 | /* Do checksum */ |
71 | hmac_sha((char *)devices[device].null, strlen(devices[device].null), | 71 | hmac_sha((unsigned char *)devices[device].null, strlen(devices[device].null), |
72 | (char *)outbuf, 0x98+length, key, 20); | 72 | outbuf, 0x98+length, key, 20); |
73 | memcpy(&outbuf[0x98+length+8], key, 20); | 73 | memcpy(&outbuf[0x98+length+8], key, 20); |
74 | return length+0x90+0x1C+8; | 74 | return length+0x90+0x1C+8; |
75 | } | 75 | } |
diff --git a/tools/descramble.c b/tools/descramble.c index 3d09bfad75..42bc9cee6c 100644 --- a/tools/descramble.c +++ b/tools/descramble.c | |||
@@ -157,13 +157,13 @@ int main (int argc, char** argv) | |||
157 | length |= header[10] << 16 | header[11] << 24; | 157 | length |= header[10] << 16 | header[11] << 24; |
158 | 158 | ||
159 | /* calculate the xor string used */ | 159 | /* calculate the xor string used */ |
160 | for (i=0; i<stringlen; i++) { | 160 | for (i=0; i<(unsigned long)stringlen; i++) { |
161 | int top=0, topchar=0, c; | 161 | int top=0, topchar=0, c; |
162 | int bytecount[256]; | 162 | int bytecount[256]; |
163 | memset(bytecount, 0, sizeof(bytecount)); | 163 | memset(bytecount, 0, sizeof(bytecount)); |
164 | 164 | ||
165 | /* gather byte frequency statistics */ | 165 | /* gather byte frequency statistics */ |
166 | for (c=i; c<length; c+=stringlen) | 166 | for (c=i; c<(int)length; c+=stringlen) |
167 | bytecount[inbuf[c]]++; | 167 | bytecount[inbuf[c]]++; |
168 | 168 | ||
169 | /* find the most frequent byte */ | 169 | /* find the most frequent byte */ |
@@ -202,7 +202,7 @@ int main (int argc, char** argv) | |||
202 | int count = (byte2 & 0x0f) + 3; | 202 | int count = (byte2 & 0x0f) + 3; |
203 | int src = | 203 | int src = |
204 | (j & 0xfffff000) + (byte1 | ((byte2 & 0xf0)<<4)) + 18; | 204 | (j & 0xfffff000) + (byte1 | ((byte2 & 0xf0)<<4)) + 18; |
205 | if (src > j) | 205 | if (src > (int)j) |
206 | src -= 0x1000; | 206 | src -= 0x1000; |
207 | 207 | ||
208 | for (x=0; x<count; x++) | 208 | for (x=0; x<count; x++) |
@@ -259,7 +259,7 @@ int iaudio_decode(char *iname, char *oname) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | len = fread(outbuf, 1, length, file); | 261 | len = fread(outbuf, 1, length, file); |
262 | if(len < length) { | 262 | if(len < (size_t)length) { |
263 | perror(iname); | 263 | perror(iname); |
264 | return -2; | 264 | return -2; |
265 | } | 265 | } |
@@ -283,7 +283,7 @@ int iaudio_decode(char *iname, char *oname) | |||
283 | } | 283 | } |
284 | 284 | ||
285 | len = fwrite(outbuf+0x1030, 1, length-0x1030, file); | 285 | len = fwrite(outbuf+0x1030, 1, length-0x1030, file); |
286 | if(len < length-0x1030) { | 286 | if(len < (size_t)length-0x1030) { |
287 | perror(oname); | 287 | perror(oname); |
288 | return -4; | 288 | return -4; |
289 | } | 289 | } |
diff --git a/tools/hmac-sha1.c b/tools/hmac-sha1.c index 1b4b3b5abd..8882b10b9a 100644 --- a/tools/hmac-sha1.c +++ b/tools/hmac-sha1.c | |||
@@ -29,6 +29,8 @@ | |||
29 | * | 29 | * |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <string.h> | ||
33 | |||
32 | #include "hmac-sha1.h" | 34 | #include "hmac-sha1.h" |
33 | 35 | ||
34 | /* | 36 | /* |
@@ -386,35 +388,20 @@ void SHA1PadMessage(SHA1Context *context) | |||
386 | 388 | ||
387 | #define SHA_BLOCKSIZE 64 | 389 | #define SHA_BLOCKSIZE 64 |
388 | 390 | ||
389 | static void truncate | ||
390 | ( | ||
391 | char* d1, /* data to be truncated */ | ||
392 | char* d2, /* truncated data */ | ||
393 | int len /* length in bytes to keep */ | ||
394 | ) | ||
395 | { | ||
396 | int i ; | ||
397 | for (i = 0 ; i < len ; i++) d2[i] = d1[i]; | ||
398 | } | ||
399 | |||
400 | |||
401 | /* Function to compute the digest */ | 391 | /* Function to compute the digest */ |
402 | void | 392 | void |
403 | hmac_sha | 393 | hmac_sha(unsigned char* k, /* secret key */ |
404 | ( | 394 | int lk, /* length of the key in bytes */ |
405 | char* k, /* secret key */ | 395 | unsigned char* d, /* data */ |
406 | int lk, /* length of the key in bytes */ | 396 | int ld, /* length of data in bytes */ |
407 | char* d, /* data */ | 397 | unsigned char* out, /* output buffer, at least "t" bytes */ |
408 | int ld, /* length of data in bytes */ | 398 | int t) |
409 | char* out, /* output buffer, at least "t" bytes */ | ||
410 | int t | ||
411 | ) | ||
412 | { | 399 | { |
413 | SHA1Context ictx, octx ; | 400 | SHA1Context ictx, octx ; |
414 | char isha[SHA_DIGESTSIZE], osha[SHA_DIGESTSIZE] ; | 401 | unsigned char isha[SHA_DIGESTSIZE], osha[SHA_DIGESTSIZE] ; |
415 | char key[SHA_DIGESTSIZE] ; | 402 | unsigned char key[SHA_DIGESTSIZE] ; |
416 | char buf[SHA_BLOCKSIZE] ; | 403 | unsigned char buf[SHA_BLOCKSIZE] ; |
417 | int i ; | 404 | int i ; |
418 | 405 | ||
419 | if (lk > SHA_BLOCKSIZE) { | 406 | if (lk > SHA_BLOCKSIZE) { |
420 | 407 | ||
@@ -433,8 +420,11 @@ hmac_sha | |||
433 | SHA1Reset(&ictx) ; | 420 | SHA1Reset(&ictx) ; |
434 | 421 | ||
435 | /* Pad the key for inner digest */ | 422 | /* Pad the key for inner digest */ |
436 | for (i = 0 ; i < lk ; ++i) buf[i] = k[i] ^ 0x36 ; | 423 | for (i = 0 ; i < lk ; ++i) |
437 | for (i = lk ; i < SHA_BLOCKSIZE ; ++i) buf[i] = 0x36 ; | 424 | buf[i] = k[i] ^ 0x36 ; |
425 | |||
426 | for (i = lk ; i < SHA_BLOCKSIZE ; ++i) | ||
427 | buf[i] = 0x36 ; | ||
438 | 428 | ||
439 | SHA1Input(&ictx, buf, SHA_BLOCKSIZE) ; | 429 | SHA1Input(&ictx, buf, SHA_BLOCKSIZE) ; |
440 | SHA1Input(&ictx, d, ld) ; | 430 | SHA1Input(&ictx, d, ld) ; |
@@ -456,8 +446,8 @@ hmac_sha | |||
456 | 446 | ||
457 | SHA1Result(&octx, osha) ; | 447 | SHA1Result(&octx, osha) ; |
458 | 448 | ||
459 | /* truncate and print the results */ | 449 | /* truncate the results */ |
460 | t = t > SHA_DIGESTSIZE ? SHA_DIGESTSIZE : t ; | 450 | t = t > SHA_DIGESTSIZE ? SHA_DIGESTSIZE : t ; |
461 | truncate(osha, out, t) ; | 451 | memcpy(out, osha, t); |
462 | 452 | ||
463 | } | 453 | } |
diff --git a/tools/hmac-sha1.h b/tools/hmac-sha1.h index 149b5bac46..e5be1cfc38 100644 --- a/tools/hmac-sha1.h +++ b/tools/hmac-sha1.h | |||
@@ -70,15 +70,8 @@ int SHA1Input( SHA1Context *, | |||
70 | int SHA1Result( SHA1Context *, | 70 | int SHA1Result( SHA1Context *, |
71 | uint8_t Message_Digest[SHA1HashSize]); | 71 | uint8_t Message_Digest[SHA1HashSize]); |
72 | 72 | ||
73 | void | 73 | void hmac_sha(unsigned char* k, int lk, |
74 | hmac_sha | 74 | unsigned char* d, int ld, |
75 | ( | 75 | unsigned char* out, int t); |
76 | char* k, | ||
77 | int lk, | ||
78 | char* d, | ||
79 | int ld, | ||
80 | char* out, | ||
81 | int t | ||
82 | ); | ||
83 | 76 | ||
84 | #endif | 77 | #endif |