summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-04-09 14:04:39 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-04-09 14:04:39 +0000
commitae64d2602befd5589c8c0141a6d812841fdfb232 (patch)
tree0392b8e1f9aaa5c0cb12d06d771538199edba09e /tools
parentf617ba4a43e17fcac695be5f69cec1941834973b (diff)
downloadrockbox-ae64d2602befd5589c8c0141a6d812841fdfb232.tar.gz
rockbox-ae64d2602befd5589c8c0141a6d812841fdfb232.tar.bz2
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.c6
-rw-r--r--tools/descramble.c10
-rw-r--r--tools/hmac-sha1.c48
-rw-r--r--tools/hmac-sha1.h13
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);
static int make_ciff_file(unsigned char *inbuf, int length,
unsigned char *outbuf, int device)
{
- char key[20];
+ unsigned char key[20];
memcpy(outbuf, "FFIC", 4);
int2le(length+90, &outbuf[4]);
memcpy(&outbuf[8], "FNIC", 4);
@@ -68,8 +68,8 @@ static int make_ciff_file(unsigned char *inbuf, int length,
memcpy(&outbuf[0x98+length], "LLUN", 4);
int2le(20, &outbuf[0x98+length+4]);
/* Do checksum */
- hmac_sha((char *)devices[device].null, strlen(devices[device].null),
- (char *)outbuf, 0x98+length, key, 20);
+ hmac_sha((unsigned char *)devices[device].null, strlen(devices[device].null),
+ outbuf, 0x98+length, key, 20);
memcpy(&outbuf[0x98+length+8], key, 20);
return length+0x90+0x1C+8;
}
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)
length |= header[10] << 16 | header[11] << 24;
/* calculate the xor string used */
- for (i=0; i<stringlen; i++) {
+ for (i=0; i<(unsigned long)stringlen; i++) {
int top=0, topchar=0, c;
int bytecount[256];
memset(bytecount, 0, sizeof(bytecount));
/* gather byte frequency statistics */
- for (c=i; c<length; c+=stringlen)
+ for (c=i; c<(int)length; c+=stringlen)
bytecount[inbuf[c]]++;
/* find the most frequent byte */
@@ -202,7 +202,7 @@ int main (int argc, char** argv)
int count = (byte2 & 0x0f) + 3;
int src =
(j & 0xfffff000) + (byte1 | ((byte2 & 0xf0)<<4)) + 18;
- if (src > j)
+ if (src > (int)j)
src -= 0x1000;
for (x=0; x<count; x++)
@@ -259,7 +259,7 @@ int iaudio_decode(char *iname, char *oname)
}
len = fread(outbuf, 1, length, file);
- if(len < length) {
+ if(len < (size_t)length) {
perror(iname);
return -2;
}
@@ -283,7 +283,7 @@ int iaudio_decode(char *iname, char *oname)
}
len = fwrite(outbuf+0x1030, 1, length-0x1030, file);
- if(len < length-0x1030) {
+ if(len < (size_t)length-0x1030) {
perror(oname);
return -4;
}
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 @@
*
*/
+#include <string.h>
+
#include "hmac-sha1.h"
/*
@@ -386,35 +388,20 @@ void SHA1PadMessage(SHA1Context *context)
#define SHA_BLOCKSIZE 64
-static void truncate
-(
- char* d1, /* data to be truncated */
- char* d2, /* truncated data */
- int len /* length in bytes to keep */
-)
-{
- int i ;
- for (i = 0 ; i < len ; i++) d2[i] = d1[i];
-}
-
-
/* Function to compute the digest */
void
-hmac_sha
-(
- char* k, /* secret key */
- int lk, /* length of the key in bytes */
- char* d, /* data */
- int ld, /* length of data in bytes */
- char* out, /* output buffer, at least "t" bytes */
- int t
-)
+hmac_sha(unsigned char* k, /* secret key */
+ int lk, /* length of the key in bytes */
+ unsigned char* d, /* data */
+ int ld, /* length of data in bytes */
+ unsigned char* out, /* output buffer, at least "t" bytes */
+ int t)
{
SHA1Context ictx, octx ;
- char isha[SHA_DIGESTSIZE], osha[SHA_DIGESTSIZE] ;
- char key[SHA_DIGESTSIZE] ;
- char buf[SHA_BLOCKSIZE] ;
- int i ;
+ unsigned char isha[SHA_DIGESTSIZE], osha[SHA_DIGESTSIZE] ;
+ unsigned char key[SHA_DIGESTSIZE] ;
+ unsigned char buf[SHA_BLOCKSIZE] ;
+ int i ;
if (lk > SHA_BLOCKSIZE) {
@@ -433,8 +420,11 @@ hmac_sha
SHA1Reset(&ictx) ;
/* Pad the key for inner digest */
- for (i = 0 ; i < lk ; ++i) buf[i] = k[i] ^ 0x36 ;
- for (i = lk ; i < SHA_BLOCKSIZE ; ++i) buf[i] = 0x36 ;
+ for (i = 0 ; i < lk ; ++i)
+ buf[i] = k[i] ^ 0x36 ;
+
+ for (i = lk ; i < SHA_BLOCKSIZE ; ++i)
+ buf[i] = 0x36 ;
SHA1Input(&ictx, buf, SHA_BLOCKSIZE) ;
SHA1Input(&ictx, d, ld) ;
@@ -456,8 +446,8 @@ hmac_sha
SHA1Result(&octx, osha) ;
- /* truncate and print the results */
+ /* truncate the results */
t = t > SHA_DIGESTSIZE ? SHA_DIGESTSIZE : t ;
- truncate(osha, out, t) ;
+ memcpy(out, osha, t);
}
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 *,
int SHA1Result( SHA1Context *,
uint8_t Message_Digest[SHA1HashSize]);
-void
-hmac_sha
-(
- char* k,
- int lk,
- char* d,
- int ld,
- char* out,
- int t
-);
+void hmac_sha(unsigned char* k, int lk,
+ unsigned char* d, int ld,
+ unsigned char* out, int t);
#endif