X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=tools%2Fubsha1.c;h=90a6f3f59d2da956b6342284ed66bffa9e8671f9;hb=4225a4e4a9c8a1528c2ce3fb024c47f8180ce11d;hp=bc877606d2ffc36ff021d6c81653bc2c6b9da6a7;hpb=566a494f592ae3b3c0785d90d4e1ba45574880c4;p=oweals%2Fu-boot.git diff --git a/tools/ubsha1.c b/tools/ubsha1.c index bc877606d2..90a6f3f59d 100644 --- a/tools/ubsha1.c +++ b/tools/ubsha1.c @@ -1,53 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2007 * Heiko Schocher, DENX Software Engineering, - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ +#include "os_support.h" #include #include #include #include #include #include -#include #include -#include "sha1.h" - -#ifndef __ASSEMBLY__ -#define __ASSEMBLY__ /* Dirty trick to get only #defines */ -#endif -#include -#undef __ASSEMBLY__ - -#ifndef O_BINARY /* should be define'd on __WIN32__ */ -#define O_BINARY 0 -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED (-1) -#endif - -extern int errno; - -extern void sha1_csum (unsigned char *input, int ilen, unsigned char output[20]); +#include int main (int argc, char **argv) { @@ -84,7 +49,7 @@ int main (int argc, char **argv) cmdname, imagefile, strerror(errno)); exit (EXIT_FAILURE); } - + /* create a copy, so we can blank out the sha1 sum */ data = malloc (len); memcpy (data, ptr, len); @@ -93,15 +58,14 @@ int main (int argc, char **argv) for (i = 0; i < SHA1_SUM_LEN; i++) { ptroff[i] = 0; } - + sha1_csum ((unsigned char *) data, len, (unsigned char *)output); printf ("U-Boot sum:\n"); - for (i = 0; i < 20 ; i++) - { - printf ("%02X ", output[i]); - } - printf ("\n"); + for (i = 0; i < 20 ; i++) { + printf ("%02X ", output[i]); + } + printf ("\n"); /* overwrite the sum in the bin file, with the actual */ lseek (ifd, SHA1_SUM_POS, SEEK_END); if (write (ifd, output, SHA1_SUM_LEN) != SHA1_SUM_LEN) { @@ -109,7 +73,7 @@ int main (int argc, char **argv) cmdname, imagefile, strerror(errno)); exit (EXIT_FAILURE); } - + free (data); (void) munmap((void *)ptr, len); (void) close (ifd);