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
This commit is contained in:
parent
f617ba4a43
commit
ae64d2602b
4 changed files with 30 additions and 47 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "hmac-sha1.h"
|
||||
|
||||
/*
|
||||
|
@ -386,34 +388,19 @@ 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 */
|
||||
hmac_sha(unsigned char* k, /* secret key */
|
||||
int lk, /* length of the key in bytes */
|
||||
char* d, /* data */
|
||||
unsigned char* d, /* data */
|
||||
int ld, /* length of data in bytes */
|
||||
char* out, /* output buffer, at least "t" bytes */
|
||||
int t
|
||||
)
|
||||
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] ;
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue