Remove old hash.c code

This commit is contained in:
Pali Rohár committed 2012-08-09 19:52:22 +02:00
1 parent b2883167d5
commit 6e710dcac9
6 files changed
+7 -99

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
include ../config.mk include ../config.mk
OBJ=main.o hexdump.o dump.o flash.o serial.o qmode.o OBJ=main.o hexdump.o dump.o flash.o serial.o qmode.o
OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o console.o OBJ+=fpid.o query.o pieces.o utils.o devices.o console.o
OBJ+=squeue/squeue.o OBJ+=squeue/squeue.o
BIN=0xFFFF BIN=0xFFFF
#LIBS=`${HAVE_USB} && echo -- '-lusb'` #LIBS=`${HAVE_USB} && echo -- '-lusb'`
+3 -2
View File
@@ -18,7 +18,6 @@
#if HAVE_USB #if HAVE_USB
#include "main.h" #include "main.h"
#include "hash.h"
#include "hexdump.h" #include "hexdump.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -84,7 +83,7 @@ void flash_image(const char *filename, const char *piece, const char *device, co
unsigned long long size, off; unsigned long long size, off;
unsigned char bsize[4], tmp; unsigned char bsize[4], tmp;
unsigned char nolofiller[128]; unsigned char nolofiller[128];
ushort hash = do_hash_file(filename, piece); ushort hash = 0; //do_hash_file(filename, piece);
if (piece == NULL) { if (piece == NULL) {
//exit(1); //exit(1);
@@ -152,6 +151,8 @@ void flash_image(const char *filename, const char *piece, const char *device, co
printf("[=] Bulkwriting the %s piece...\n", piece); printf("[=] Bulkwriting the %s piece...\n", piece);
fflush(stdout); fflush(stdout);
#define BSIZE 0x20000
for(off = 0; off<size; off += BSIZE) { for(off = 0; off<size; off += BSIZE) {
char buf[BSIZE]; char buf[BSIZE];
int bread, bsize = size-off; int bread, bsize = size-off;
-82
View File
@@ -1,82 +0,0 @@
/*
* 0xFFFF - Open Free Fiasco Firmware Flasher
* Copyright (C) 2007-2009 pancake <pancake@youterm.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include "hash.h"
usho do_hash(usho *b, int len)
{
usho result = 0;
for(len>>=1;len--;b=b+1)
result^=b[0];
return result;
}
usho do_hash_file(const char *filename, const char *type)
{
unsigned char buf[BSIZE];
FILE *fd = fopen(filename, "r");
usho hash = 0;
int align = 0;
int size;
int ret;
if (fd == NULL) {
fprintf(stderr, "ERROR: File '%s' not found.\n", filename);
return -1;
}
do {
ret = fread(&buf, 1, BSIZE, fd);
if (ret == -1)
return 0;
hash ^= do_hash((usho *)&buf, ret);
} while(ret);
size = ftell(fd);
fclose(fd);
/* mmc and kernel image must be aligned */
if (type) {
if (strcmp(type, "mmc") == 0)
align = ((size >> 8) + 1) << 8;
else if (strcmp(type, "kernel") == 0)
align = ((size >> 7) + 1) << 7;
}
if (align) {
printf("align from %d to %d\n", size, align);
buf[0] = 0xff;
while (size < align) {
hash ^= do_hash((usho *)&buf, 1);
++size;
}
}
return hash;
}
#if 0
main()
{
usho us = do_hash_file("zImage");
unsigned char *h= (unsigned char *)&us;
printf("%x %x\n",h[0],h[1]);
}
#endif
-10
View File
@@ -1,10 +0,0 @@
#ifndef _INCLUDE_HASH_H_
#define _INCLUDE_HASH_H_
#define usho unsigned short
#define BSIZE 0x20000
usho do_hash(usho *b, int len);
usho do_hash_file(const char *filename, const char *type);
#endif
+3 -3
View File
@@ -416,9 +416,9 @@ int main(int argc, char **argv)
while((c = getopt(argc, argv, "QC:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:S:n")) != -1) { while((c = getopt(argc, argv, "QC:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:S:n")) != -1) {
switch(c) { switch(c) {
case 'H': // case 'H':
printf("xorpair: %04x\n", do_hash_file(optarg, NULL)); // printf("xorpair: %04x\n", do_hash_file(optarg, NULL));
return 0; // return 0;
case 'x': case 'x':
return dump_config(); return dump_config();
#if HAVE_USB #if HAVE_USB
-1
View File
@@ -2,7 +2,6 @@
#ifndef _INCLUDE_MAIN_H_ #ifndef _INCLUDE_MAIN_H_
#define _INCLUDE_MAIN_H_ #define _INCLUDE_MAIN_H_
#include "hash.h"
#include "nolo.h" #include "nolo.h"
#include "os.h" #include "os.h"
extern char strbuf[1024]; extern char strbuf[1024];