* Some minor indent and warning cleanup

This commit is contained in:
pancake 2011-07-04 18:16:12 +02:00
parent a089fcfa1a
commit 0b997374a0
8 changed files with 46 additions and 61 deletions

View File

@ -58,7 +58,6 @@ static int r_debug_gdb_attach(RDebug *dbg, int pid) {
// XXX TODO PID must be a socket here !!1
RIODesc *d = dbg->iob.io->fd;
if (d && d->plugin && d->plugin->name) {
if (!strcmp ("gdb", d->plugin->name)) {
RIOGdb *g = d->data;
support_sw_bp = UNKNOWN;
@ -215,7 +214,7 @@ static int r_debug_gdb_breakpoint (void *user, int type, ut64 addr, int hw, int
if(!type && gdbwrap_simplesetbp(desc,addr)){
support_sw_bp = SUPPORTED;
return R_TRUE;
} else if (type ) {
} else if (type) {
gdbwrap_simpledelbp(desc,addr);
return R_TRUE;
} else {

View File

@ -840,7 +840,7 @@ char *gdbwrap_shipallreg(gdbwrap_t *desc) {
int i;
if (desc == NULL)
return;
return NULL;
savedregs = (ut8 *)malloc (desc->num_registers*desc->reg_size);
if (savedregs==NULL)
return NULL;

View File

@ -5,6 +5,6 @@ LDFLAGS+=-lm
LINK=-lm
endif
OBJ=state.o md4.o md5c.o crc16.o crc32.o sha1.o hash.o hamdist.o entropy.o sha2.o calc.o
OBJ=state.o md5c.o crc16.o crc32.o sha1.o hash.o hamdist.o entropy.o sha2.o calc.o
include ../rules.mk

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
#include "r_hash.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2010
* Copyright (C) 2007-2011
* pancake <youterm.com>
*
* radare is free software; you can redistribute it and/or modify

View File

@ -6,8 +6,8 @@
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
const ut8 *end = buffer + len;
int n;
for(n=0; buffer<end; buffer = buffer + 1)
if (IS_PRINTABLE(buffer[0]))
for(n=0; buffer<end; buffer++)
if (IS_PRINTABLE (*buffer))
n++;
return ((100*n)/len);
}
@ -28,15 +28,15 @@ R_API int r_hash_parity(const ut8 *buf, ut64 len) {
R_API ut16 r_hash_xorpair(const ut8 *a, ut64 len) {
ut16 *b = (ut16 *)a;
ut16 result = 0;
for (len>>=1;len--;b=b+1)
result^=b[0];
for (len>>=1; len--; b++)
result ^= *b;
return result;
}
R_API ut8 r_hash_xor(const ut8 *b, ut64 len) {
ut8 res = 0;
for (;len--;b=b+1)
res^=b[0];
for (; len--; b++)
res ^= *b;
return res;
}

View File

@ -38,8 +38,7 @@
#define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))
static void shaHashBlock(R_SHA_CTX *ctx)
{
static void shaHashBlock(R_SHA_CTX *ctx) {
int t;
unsigned int A,B,C,D,E,TEMP;
@ -113,8 +112,7 @@ void SHA1_Update(R_SHA_CTX *ctx, const void *_dataIn, int len) {
}
}
void SHA1_Final(unsigned char hashout[20], R_SHA_CTX *ctx)
{
void SHA1_Final(unsigned char hashout[20], R_SHA_CTX *ctx) {
unsigned char pad0x80 = 0x80;
unsigned char pad0x00 = 0x00;
unsigned char padlen[8];

View File

@ -1,88 +1,76 @@
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
#include "r_hash.h"
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
// TODO: to be moved to r_hash_internal.h
void mdfour(ut8 *out, const ut8 *in, int n);
#include "md4.c" // included directly
#define CHKFLAG(f,x) if (f==0||f&x)
R_API struct r_hash_t *r_hash_new(int rst, int flags)
{
RHash *ctx;
ctx = R_NEW (RHash);
R_API struct r_hash_t *r_hash_new(int rst, int flags) {
RHash *ctx = R_NEW (RHash);
if (ctx) {
CHKFLAG(flags,R_HASH_MD5) MD5Init(&ctx->md5);
CHKFLAG(flags,R_HASH_SHA1) SHA1_Init(&ctx->sha1);
CHKFLAG(flags,R_HASH_SHA256) SHA256_Init(&ctx->sha256);
CHKFLAG(flags,R_HASH_SHA384) SHA384_Init(&ctx->sha384);
CHKFLAG(flags,R_HASH_SHA512) SHA512_Init(&ctx->sha512);
CHKFLAG (flags, R_HASH_MD5) MD5Init (&ctx->md5);
CHKFLAG (flags, R_HASH_SHA1) SHA1_Init (&ctx->sha1);
CHKFLAG (flags, R_HASH_SHA256) SHA256_Init (&ctx->sha256);
CHKFLAG (flags, R_HASH_SHA384) SHA384_Init (&ctx->sha384);
CHKFLAG (flags, R_HASH_SHA512) SHA512_Init (&ctx->sha512);
ctx->rst = rst;
}
return ctx;
}
R_API void r_hash_free(struct r_hash_t *ctx)
{
free(ctx);
R_API void r_hash_free(struct r_hash_t *ctx) {
free (ctx);
}
R_API const ut8 *r_hash_do_md5(struct r_hash_t *ctx, const ut8 *input, ut32 len)
{
R_API const ut8 *r_hash_do_md5(struct r_hash_t *ctx, const ut8 *input, ut32 len) {
if (ctx->rst)
MD5Init(&ctx->md5);
MD5Update(&ctx->md5, input, len);
MD5Init (&ctx->md5);
MD5Update (&ctx->md5, input, len);
if (ctx->rst || len == 0)
MD5Final(&ctx->digest, &ctx->md5);
MD5Final (&ctx->digest, &ctx->md5);
return ctx->digest;
}
R_API const ut8 *r_hash_do_sha1(struct r_hash_t *ctx, const ut8 *input, ut32 len)
{
R_API const ut8 *r_hash_do_sha1(struct r_hash_t *ctx, const ut8 *input, ut32 len) {
if (ctx->rst)
SHA1_Init(&ctx->sha1);
SHA1_Update(&ctx->sha1, input, len);
SHA1_Init (&ctx->sha1);
SHA1_Update (&ctx->sha1, input, len);
if (ctx->rst || len == 0)
SHA1_Final(ctx->digest, &ctx->sha1);
SHA1_Final (ctx->digest, &ctx->sha1);
return ctx->digest;
}
R_API const ut8 *r_hash_do_md4(struct r_hash_t *ctx, const ut8 *input, ut32 len)
{
mdfour(ctx->digest, input, len);
R_API const ut8 *r_hash_do_md4(struct r_hash_t *ctx, const ut8 *input, ut32 len) {
mdfour (ctx->digest, input, len);
return ctx->digest;
}
R_API const ut8 *r_hash_do_sha256(struct r_hash_t *ctx, const ut8 *input, ut32 len)
{
R_API const ut8 *r_hash_do_sha256(struct r_hash_t *ctx, const ut8 *input, ut32 len) {
if (ctx->rst)
SHA256_Init(&ctx->sha256);
SHA256_Update(&ctx->sha256, input, len);
SHA256_Init (&ctx->sha256);
SHA256_Update (&ctx->sha256, input, len);
if (ctx->rst || len == 0)
SHA256_Final(ctx->digest, &ctx->sha256);
SHA256_Final (ctx->digest, &ctx->sha256);
return ctx->digest;
}
R_API const ut8 *r_hash_do_sha384(struct r_hash_t *ctx, const ut8 *input, ut32 len)
{
R_API const ut8 *r_hash_do_sha384(struct r_hash_t *ctx, const ut8 *input, ut32 len) {
if (ctx->rst)
SHA384_Init(&ctx->sha384);
SHA384_Update(&ctx->sha384, input, len);
SHA384_Init (&ctx->sha384);
SHA384_Update (&ctx->sha384, input, len);
if (ctx->rst || len == 0)
SHA384_Final(ctx->digest, &ctx->sha384);
SHA384_Final (ctx->digest, &ctx->sha384);
return ctx->digest;
}
R_API const ut8 *r_hash_do_sha512(struct r_hash_t *ctx, const ut8 *input, ut32 len)
{
R_API const ut8 *r_hash_do_sha512(struct r_hash_t *ctx, const ut8 *input, ut32 len) {
if (ctx->rst)
SHA512_Init(&ctx->sha512);
SHA512_Update(&ctx->sha512, input, len);
SHA512_Init (&ctx->sha512);
SHA512_Update (&ctx->sha512, input, len);
if (ctx->rst || len == 0)
SHA512_Final(ctx->digest, &ctx->sha512);
SHA512_Final (ctx->digest, &ctx->sha512);
return ctx->digest;
}