(2006-08-06) rescue-bootcd
This commit is contained in:
112
extra/syslinux-3.09/com32/libutil/Makefile
Normal file
112
extra/syslinux-3.09/com32/libutil/Makefile
Normal file
@@ -0,0 +1,112 @@
|
||||
#ident "$Id: Makefile,v 1.8 2005/01/21 00:49:46 hpa Exp $"
|
||||
## -----------------------------------------------------------------------
|
||||
##
|
||||
## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
|
||||
##
|
||||
## Permission is hereby granted, free of charge, to any person
|
||||
## obtaining a copy of this software and associated documentation
|
||||
## files (the "Software"), to deal in the Software without
|
||||
## restriction, including without limitation the rights to use,
|
||||
## copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
## sell copies of the Software, and to permit persons to whom
|
||||
## the Software is furnished to do so, subject to the following
|
||||
## conditions:
|
||||
##
|
||||
## The above copyright notice and this permission notice shall
|
||||
## be included in all copies or substantial portions of the Software.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
## OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
## HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
## WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
## OTHER DEALINGS IN THE SOFTWARE.
|
||||
##
|
||||
## -----------------------------------------------------------------------
|
||||
|
||||
##
|
||||
## Utility companion library for the COM32 library
|
||||
##
|
||||
|
||||
gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
|
||||
then echo $(1); else echo $(2); fi)
|
||||
|
||||
M32 := $(call gcc_ok,-m32,)
|
||||
|
||||
CC = gcc
|
||||
LD = ld -m elf_i386
|
||||
AR = ar
|
||||
NASM = nasm
|
||||
RANLIB = ranlib
|
||||
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -D__COM32__ -W -Wall -march=i386 -Os -fomit-frame-pointer -I./include -I../include
|
||||
SFLAGS = $(M32) -D__COM32__ -march=i386
|
||||
LDFLAGS = -T ../lib/com32.ld
|
||||
LNXCFLAGS = -I./include -W -Wall -O -g
|
||||
LNXSFLAGS = -g
|
||||
LNXLDFLAGS = -g
|
||||
OBJCOPY = objcopy
|
||||
LIBOBJS = ansiline.o ansiraw.o get_key.o idle.o sha1hash.o unbase64.o
|
||||
LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS))
|
||||
|
||||
.SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
|
||||
|
||||
BINDIR = /usr/bin
|
||||
LIBDIR = /usr/lib
|
||||
AUXDIR = $(LIBDIR)/syslinux
|
||||
INCDIR = /usr/include
|
||||
COM32DIR = $(AUXDIR)/com32
|
||||
|
||||
all: libutil_com.a libutil_lnx.a
|
||||
|
||||
libutil_com.a: $(LIBOBJS)
|
||||
rm -f $@
|
||||
$(AR) cq $@ $(LIBOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
libutil_lnx.a: $(LNXLIBOBJS)
|
||||
rm -f $@
|
||||
$(AR) cq $@ $(LNXLIBOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
.PRECIOUS: %.o
|
||||
%.o: %.S
|
||||
$(CC) $(SFLAGS) -c -o $@ $<
|
||||
|
||||
.PRECIOUS: %.o
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
.PRECIOUS: %.elf
|
||||
%.elf: %.o $(LIB)
|
||||
$(LD) $(LDFLAGS) -o $@ $^ $(LIBGCC)
|
||||
|
||||
.PRECIOUS: %.lo
|
||||
%.lo: %.S
|
||||
$(CC) $(LNXSFLAGS) -c -o $@ $<
|
||||
|
||||
.PRECIOUS: %.lo
|
||||
%.lo: %.c
|
||||
$(CC) $(LNXCFLAGS) -c -o $@ $<
|
||||
|
||||
.PRECIOUS: %.lnx
|
||||
%.lnx: %.lo
|
||||
$(CC) $(LNXCFLAGS) -o $@ $^
|
||||
|
||||
%.c32: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
tidy:
|
||||
rm -f *.o *.lo *.lst *.elf
|
||||
|
||||
clean: tidy
|
||||
rm -f *.lss *.a *.c32 *.lnx *.com
|
||||
|
||||
spotless: clean
|
||||
rm -f *~ \#*
|
||||
|
||||
install: all
|
||||
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
|
||||
install -m 644 libutil_com.a libutil_lnx.a $(INSTALLROOT)$(COM32DIR)
|
||||
|
||||
92
extra/syslinux-3.09/com32/libutil/ansiline.c
Normal file
92
extra/syslinux-3.09/com32/libutil/ansiline.c
Normal file
@@ -0,0 +1,92 @@
|
||||
#ident "$Id: ansiline.c,v 1.1 2004/12/01 01:30:07 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* ansiline.c
|
||||
*
|
||||
* Configures the console for ANSI output in line mode; versions
|
||||
* for COM32 and Linux support.
|
||||
*/
|
||||
|
||||
#ifdef __COM32__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <console.h>
|
||||
|
||||
static void __attribute__((destructor)) console_cleanup(void)
|
||||
{
|
||||
/* For the serial console, be nice and clean up */
|
||||
fputs("\033[0m\033[20l", stdout);
|
||||
}
|
||||
|
||||
void console_ansi_std(void)
|
||||
{
|
||||
openconsole(&dev_stdcon_r, &dev_ansiserial_w);
|
||||
fputs("\033[0m\033[20h", stdout);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
|
||||
static struct termios original_termios_settings;
|
||||
|
||||
static void __attribute__((constructor)) console_init(void)
|
||||
{
|
||||
tcgetattr(0, &original_termios_settings);
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) console_cleanup(void)
|
||||
{
|
||||
fputs("\033[0m\033[20l", stdout);
|
||||
tcsetattr(0, TCSANOW, &original_termios_settings);
|
||||
}
|
||||
|
||||
|
||||
void console_ansi_std(void)
|
||||
{
|
||||
struct termios tio;
|
||||
|
||||
/* Disable stdio buffering */
|
||||
setbuf(stdin, NULL);
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/* Set the termios flag so we behave the same as libcom32 */
|
||||
tcgetattr(0, &tio);
|
||||
tio.c_iflag &= ~ICRNL;
|
||||
tio.c_iflag |= IGNCR;
|
||||
tio.c_cflag |= ICANON|ECHO;
|
||||
tcsetattr(0, TCSANOW, &tio);
|
||||
fputs("\033[0m\033[20h", stdout);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BIN
extra/syslinux-3.09/com32/libutil/ansiline.lo
Normal file
BIN
extra/syslinux-3.09/com32/libutil/ansiline.lo
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/ansiline.o
Normal file
BIN
extra/syslinux-3.09/com32/libutil/ansiline.o
Normal file
Binary file not shown.
94
extra/syslinux-3.09/com32/libutil/ansiraw.c
Normal file
94
extra/syslinux-3.09/com32/libutil/ansiraw.c
Normal file
@@ -0,0 +1,94 @@
|
||||
#ident "$Id: ansiraw.c,v 1.5 2004/12/21 01:37:43 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* ansiraw.c
|
||||
*
|
||||
* Configures the console for ANSI output in raw mode; versions
|
||||
* for COM32 and Linux support.
|
||||
*/
|
||||
|
||||
#ifdef __COM32__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <console.h>
|
||||
|
||||
static void __attribute__((destructor)) console_cleanup(void)
|
||||
{
|
||||
/* For the serial console, be nice and clean up */
|
||||
fputs("\033[0m\033[20l", stdout);
|
||||
}
|
||||
|
||||
void console_ansi_raw(void)
|
||||
{
|
||||
openconsole(&dev_rawcon_r, &dev_ansiserial_w);
|
||||
fputs("\033[0m\033[20h", stdout);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
|
||||
static struct termios original_termios_settings;
|
||||
|
||||
static void __attribute__((constructor)) console_init(void)
|
||||
{
|
||||
tcgetattr(0, &original_termios_settings);
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) console_cleanup(void)
|
||||
{
|
||||
fputs("\033[0m\033[20l", stdout);
|
||||
tcsetattr(0, TCSANOW, &original_termios_settings);
|
||||
}
|
||||
|
||||
|
||||
void console_ansi_raw(void)
|
||||
{
|
||||
struct termios tio;
|
||||
|
||||
/* Disable stdio buffering */
|
||||
setbuf(stdin, NULL);
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/* Set the termios flag so we behave the same as libcom32 */
|
||||
tcgetattr(0, &tio);
|
||||
tio.c_iflag &= ~ICRNL;
|
||||
tio.c_iflag |= IGNCR;
|
||||
tio.c_lflag &= ~(ISIG|ICANON|ECHO);
|
||||
tio.c_cc[VMIN] = 0;
|
||||
tio.c_cc[VTIME] = 1; /* Don't 100% busy-wait in Linux */
|
||||
tcsetattr(0, TCSAFLUSH, &tio);
|
||||
fputs("\033[0m\033[20h", stdout);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BIN
extra/syslinux-3.09/com32/libutil/ansiraw.lo
Normal file
BIN
extra/syslinux-3.09/com32/libutil/ansiraw.lo
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/ansiraw.o
Normal file
BIN
extra/syslinux-3.09/com32/libutil/ansiraw.o
Normal file
Binary file not shown.
172
extra/syslinux-3.09/com32/libutil/get_key.c
Normal file
172
extra/syslinux-3.09/com32/libutil/get_key.c
Normal file
@@ -0,0 +1,172 @@
|
||||
#ident "$Id: get_key.c,v 1.7 2005/01/21 01:35:33 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* get_key.c
|
||||
*
|
||||
* Get a single key, and try to pick apart function key codes.
|
||||
* This doesn't decode anywhere close to all possiblities, but
|
||||
* hopefully is enough to be useful.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/times.h>
|
||||
#include <getkey.h>
|
||||
#include <libutil.h>
|
||||
|
||||
struct keycode {
|
||||
int code;
|
||||
int seqlen;
|
||||
const unsigned char *seq;
|
||||
};
|
||||
|
||||
#define MAXLEN 8
|
||||
#define CODE(x,y) { x, (sizeof y)-1, y }
|
||||
|
||||
static const struct keycode keycodes[] = {
|
||||
/* First, the BIOS combined codes */
|
||||
CODE(KEY_F1, "\0\x3B"),
|
||||
CODE(KEY_F2, "\0\x3C"),
|
||||
CODE(KEY_F3, "\0\x3D"),
|
||||
CODE(KEY_F4, "\0\x3E"),
|
||||
CODE(KEY_F5, "\0\x3F"),
|
||||
CODE(KEY_F6, "\0\x40"),
|
||||
CODE(KEY_F7, "\0\x41"),
|
||||
CODE(KEY_F8, "\0\x42"),
|
||||
CODE(KEY_F9, "\0\x43"),
|
||||
CODE(KEY_F10, "\0\x44"),
|
||||
CODE(KEY_F11, "\0\x85"),
|
||||
CODE(KEY_F12, "\0\x86"),
|
||||
|
||||
CODE(KEY_UP, "\0\x48"),
|
||||
CODE(KEY_DOWN, "\0\x50"),
|
||||
CODE(KEY_LEFT, "\0\x4B"),
|
||||
CODE(KEY_RIGHT,"\0\x4D"),
|
||||
CODE(KEY_PGUP, "\0\x49"),
|
||||
CODE(KEY_PGDN, "\0\x51"),
|
||||
CODE(KEY_HOME, "\0\x47"),
|
||||
CODE(KEY_END, "\0\x4F"),
|
||||
CODE(KEY_INSERT, "\0\x52"),
|
||||
CODE(KEY_DELETE, "\0\x53"),
|
||||
|
||||
/* Now, VT/xterm/Linux codes */
|
||||
CODE(KEY_F1, "\033[[A"),
|
||||
CODE(KEY_F1, "\033OP"),
|
||||
CODE(KEY_F2, "\033[[B"),
|
||||
CODE(KEY_F2, "\033OQ"),
|
||||
CODE(KEY_F3, "\033[[C"),
|
||||
CODE(KEY_F3, "\033OR"),
|
||||
CODE(KEY_F4, "\033[[D"),
|
||||
CODE(KEY_F4, "\033OS"),
|
||||
CODE(KEY_F5, "\033[[E"),
|
||||
CODE(KEY_F5, "\033[15~"),
|
||||
CODE(KEY_F6, "\033[17~"),
|
||||
CODE(KEY_F7, "\033[18~"),
|
||||
CODE(KEY_F8, "\033[19~"),
|
||||
CODE(KEY_F9, "\033[20~"),
|
||||
CODE(KEY_F10, "\033[21~"),
|
||||
CODE(KEY_F11, "\033[23~"),
|
||||
CODE(KEY_F12, "\033[24~"),
|
||||
|
||||
CODE(KEY_UP, "\033[A"),
|
||||
CODE(KEY_DOWN, "\033[B"),
|
||||
CODE(KEY_LEFT, "\033[D"),
|
||||
CODE(KEY_RIGHT,"\033[C"),
|
||||
CODE(KEY_PGUP, "\033[5~"),
|
||||
CODE(KEY_PGUP, "\033[V"),
|
||||
CODE(KEY_PGDN, "\033[6~"),
|
||||
CODE(KEY_PGDN, "\033[U"),
|
||||
CODE(KEY_HOME, "\033[1~"),
|
||||
CODE(KEY_HOME, "\033[H"),
|
||||
CODE(KEY_END, "\033[4~"),
|
||||
CODE(KEY_END, "\033[F"),
|
||||
CODE(KEY_END, "\033OF"),
|
||||
CODE(KEY_INSERT, "\033[2~"),
|
||||
CODE(KEY_INSERT, "\033[@"),
|
||||
CODE(KEY_DELETE, "\033[3~"),
|
||||
};
|
||||
#define NCODES ((int)(sizeof keycodes/sizeof(struct keycode)))
|
||||
|
||||
int get_key(FILE *f, clock_t timeout)
|
||||
{
|
||||
unsigned char buffer[MAXLEN];
|
||||
int nc, i, rv;
|
||||
const struct keycode *kc;
|
||||
int another;
|
||||
unsigned char ch;
|
||||
clock_t start;
|
||||
|
||||
/* We typically start in the middle of a clock tick */
|
||||
if ( timeout )
|
||||
timeout++;
|
||||
|
||||
nc = 0;
|
||||
start = times(NULL);
|
||||
do {
|
||||
rv = read(fileno(f), &ch, 1);
|
||||
if ( rv == 0 || (rv == -1 && errno == EAGAIN) ) {
|
||||
clock_t lateness = times(NULL)-start;
|
||||
if ( nc && lateness > 1+CLK_TCK/20 )
|
||||
return buffer[0]; /* timeout in sequence */
|
||||
else if ( !nc && timeout && lateness > timeout )
|
||||
return KEY_NONE; /* timeout before sequence */
|
||||
|
||||
do_idle();
|
||||
|
||||
another = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
start = times(NULL);
|
||||
|
||||
buffer[nc++] = ch;
|
||||
|
||||
another = 0;
|
||||
for ( i = 0, kc = keycodes ; i < NCODES ; i++, kc++ ) {
|
||||
if ( nc == kc->seqlen && !memcmp(buffer, kc->seq, nc) )
|
||||
return kc->code;
|
||||
else if ( nc < kc->seqlen && !memcmp(buffer, kc->seq, nc) ) {
|
||||
another = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while ( another );
|
||||
|
||||
/* We got an unrecognized sequence; return the first character */
|
||||
/* We really should remember this and return subsequent characters later */
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
extra/syslinux-3.09/com32/libutil/get_key.lo
Normal file
BIN
extra/syslinux-3.09/com32/libutil/get_key.lo
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/get_key.o
Normal file
BIN
extra/syslinux-3.09/com32/libutil/get_key.o
Normal file
Binary file not shown.
53
extra/syslinux-3.09/com32/libutil/idle.c
Normal file
53
extra/syslinux-3.09/com32/libutil/idle.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#ident "$Id: idle.c,v 1.1 2005/01/20 18:41:12 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2005 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* idle.c
|
||||
*
|
||||
* What to do in a busy loop...
|
||||
*/
|
||||
|
||||
#ifdef __COM32__
|
||||
|
||||
#include <syslinux.h>
|
||||
|
||||
void do_idle(void)
|
||||
{
|
||||
syslinux_idle();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
void do_idle(void)
|
||||
{
|
||||
sched_yield(); /* As good as we can get... */
|
||||
}
|
||||
|
||||
#endif
|
||||
BIN
extra/syslinux-3.09/com32/libutil/idle.lo
Normal file
BIN
extra/syslinux-3.09/com32/libutil/idle.lo
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/idle.o
Normal file
BIN
extra/syslinux-3.09/com32/libutil/idle.o
Normal file
Binary file not shown.
42
extra/syslinux-3.09/com32/libutil/include/base64.h
Normal file
42
extra/syslinux-3.09/com32/libutil/include/base64.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ident "$Id: base64.h,v 1.1 2005/01/21 00:49:46 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2005 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* base64.h
|
||||
*
|
||||
* Simple routines for handing base64 text
|
||||
*/
|
||||
|
||||
#ifndef LIBUTIL_BASE64_H
|
||||
#define LIBUTIL_BASE64_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
size_t unbase64(unsigned char *, size_t, const char *);
|
||||
|
||||
#endif
|
||||
42
extra/syslinux-3.09/com32/libutil/include/consoles.h
Normal file
42
extra/syslinux-3.09/com32/libutil/include/consoles.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ident "$Id: consoles.h,v 1.2 2004/12/01 02:44:34 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* consoles.h
|
||||
*
|
||||
* Utility functions for common console configurations
|
||||
*/
|
||||
|
||||
#ifndef LIBUTIL_CONSOLES_H
|
||||
#define LIBUTIL_CONSOLES_H
|
||||
|
||||
void console_ansi_std(void);
|
||||
void console_ansi_raw(void);
|
||||
|
||||
#endif /* LIBUTIL_CONSOLES_H */
|
||||
|
||||
76
extra/syslinux-3.09/com32/libutil/include/getkey.h
Normal file
76
extra/syslinux-3.09/com32/libutil/include/getkey.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ident "$Id: getkey.h,v 1.5 2005/01/21 01:35:33 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* getkey.h
|
||||
*
|
||||
* Function to get a key symbol and parse it
|
||||
*/
|
||||
|
||||
#ifndef LIBUTIL_GETKEY_H
|
||||
#define LIBUTIL_GETKEY_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/times.h>
|
||||
|
||||
#define KEY_NONE (-1)
|
||||
|
||||
#define KEY_CTRL(x) ((x) & 0x001f)
|
||||
#define KEY_BACKSPACE 0x0008
|
||||
#define KEY_TAB 0x0009
|
||||
#define KEY_ENTER 0x000d
|
||||
#define KEY_ESC 0x001b
|
||||
#define KEY_DEL 0x007f
|
||||
|
||||
#define KEY_F1 0x0100
|
||||
#define KEY_F2 0x0101
|
||||
#define KEY_F3 0x0102
|
||||
#define KEY_F4 0x0103
|
||||
#define KEY_F5 0x0104
|
||||
#define KEY_F6 0x0105
|
||||
#define KEY_F7 0x0106
|
||||
#define KEY_F8 0x0107
|
||||
#define KEY_F9 0x0108
|
||||
#define KEY_F10 0x0109
|
||||
#define KEY_F11 0x010A
|
||||
#define KEY_F12 0x010B
|
||||
|
||||
#define KEY_UP 0x0120
|
||||
#define KEY_DOWN 0x0121
|
||||
#define KEY_LEFT 0x0122
|
||||
#define KEY_RIGHT 0x0123
|
||||
#define KEY_PGUP 0x0124
|
||||
#define KEY_PGDN 0x0125
|
||||
#define KEY_HOME 0x0126
|
||||
#define KEY_END 0x0127
|
||||
#define KEY_INSERT 0x0128
|
||||
#define KEY_DELETE 0x0129
|
||||
|
||||
int get_key(FILE *, clock_t);
|
||||
|
||||
#endif /* LIBUTIL_GETKEY_H */
|
||||
40
extra/syslinux-3.09/com32/libutil/include/libutil.h
Normal file
40
extra/syslinux-3.09/com32/libutil/include/libutil.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ident "$Id: libutil.h,v 1.1 2005/01/20 18:41:12 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2005 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* libutil.h
|
||||
*
|
||||
* Misc libutil functions
|
||||
*/
|
||||
|
||||
#ifndef LIBUTIL_LIBUTIL_H
|
||||
#define LIBUTIL_LIBUTIL_H
|
||||
|
||||
void do_idle(void);
|
||||
|
||||
#endif
|
||||
44
extra/syslinux-3.09/com32/libutil/include/minmax.h
Normal file
44
extra/syslinux-3.09/com32/libutil/include/minmax.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ident "$Id: minmax.h,v 1.1 2004/12/20 23:19:36 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef _MINMAX_H
|
||||
#define _MINMAX_H
|
||||
|
||||
/*
|
||||
* minmax.h: Type-independent safe min/max macros
|
||||
*/
|
||||
|
||||
#define min(x,y) ({ __typeof(x) xx = (x); \
|
||||
__typeof(y) yy = (y); \
|
||||
xx < yy ? xx : yy; })
|
||||
#define max(x,y) ({ __typeof(x) xx = (x); \
|
||||
__typeof(y) yy = (y); \
|
||||
xx > yy ? xx : yy; })
|
||||
|
||||
#endif /* _MINMAX_H */
|
||||
|
||||
18
extra/syslinux-3.09/com32/libutil/include/sha1.h
Normal file
18
extra/syslinux-3.09/com32/libutil/include/sha1.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef LIBUTIL_SHA1_H
|
||||
#define LIBUTIL_SHA1_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t state[5];
|
||||
uint32_t count[2];
|
||||
unsigned char buffer[64];
|
||||
} SHA1_CTX;
|
||||
|
||||
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
|
||||
void SHA1Init(SHA1_CTX* context);
|
||||
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); /*
|
||||
JHB */
|
||||
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
||||
|
||||
#endif /* LIBUTIL_SHA1_H */
|
||||
BIN
extra/syslinux-3.09/com32/libutil/libutil_com.a
Normal file
BIN
extra/syslinux-3.09/com32/libutil/libutil_com.a
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/libutil_lnx.a
Normal file
BIN
extra/syslinux-3.09/com32/libutil/libutil_lnx.a
Normal file
Binary file not shown.
308
extra/syslinux-3.09/com32/libutil/sha1hash.c
Normal file
308
extra/syslinux-3.09/com32/libutil/sha1hash.c
Normal file
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
SHA-1 in C
|
||||
By Steve Reid <sreid@sea-to-sky.net>
|
||||
100% Public Domain
|
||||
|
||||
-----------------
|
||||
Modified 7/98
|
||||
By James H. Brown <jbrown@burgoyne.com>
|
||||
Still 100% Public Domain
|
||||
|
||||
Corrected a problem which generated improper hash values on 16 bit machines
|
||||
Routine SHA1Update changed from
|
||||
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
|
||||
len)
|
||||
to
|
||||
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
|
||||
long len)
|
||||
|
||||
The 'len' parameter was declared an int which works fine on 32 bit machines.
|
||||
However, on 16 bit machines an int is too small for the shifts being done
|
||||
against
|
||||
it. This caused the hash function to generate incorrect values if len was
|
||||
greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update().
|
||||
|
||||
Since the file IO in main() reads 16K at a time, any file 8K or larger would
|
||||
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
|
||||
"a"s).
|
||||
|
||||
I also changed the declaration of variables i & j in SHA1Update to
|
||||
unsigned long from unsigned int for the same reason.
|
||||
|
||||
These changes should make no difference to any 32 bit implementations since
|
||||
an
|
||||
int and a long are the same size in those environments.
|
||||
|
||||
--
|
||||
I also corrected a few compiler warnings generated by Borland C.
|
||||
1. Added #include <process.h> for exit() prototype
|
||||
2. Removed unused variable 'j' in SHA1Final
|
||||
3. Changed exit(0) to return(0) at end of main.
|
||||
|
||||
ALL changes I made can be located by searching for comments containing 'JHB'
|
||||
-----------------
|
||||
Modified 8/98
|
||||
By Steve Reid <sreid@sea-to-sky.net>
|
||||
Still 100% public domain
|
||||
|
||||
1- Removed #include <process.h> and used return() instead of exit()
|
||||
2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall)
|
||||
3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net
|
||||
|
||||
-----------------
|
||||
Modified 4/01
|
||||
By Saul Kravitz <Saul.Kravitz@celera.com>
|
||||
Still 100% PD
|
||||
Modified to run on Compaq Alpha hardware.
|
||||
|
||||
-----------------
|
||||
Modified 2/03
|
||||
By H. Peter Anvin <hpa@zytor.com>
|
||||
Still 100% PD
|
||||
Modified to run on any hardware with <inttypes.h> and <netinet/in.h>
|
||||
Changed the driver program
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Test Vectors (from FIPS PUB 180-1)
|
||||
"abc"
|
||||
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
|
||||
A million repetitions of "a"
|
||||
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||
*/
|
||||
|
||||
/* #define SHA1HANDSOFF */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <netinet/in.h> /* For htonl/ntohl/htons/ntohs */
|
||||
|
||||
#include "sha1.h"
|
||||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
/* blk0() and blk() perform the initial expand. */
|
||||
/* I got the idea of expanding during the round function from SSLeay */
|
||||
#define blk0(i) (block->l[i] = ntohl(block->l[i]))
|
||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||
|
||||
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
|
||||
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
|
||||
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
|
||||
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
|
||||
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
|
||||
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
||||
|
||||
|
||||
#ifdef VERBOSE /* SAK */
|
||||
void SHAPrintContext(SHA1_CTX *context, char *msg){
|
||||
printf("%s (%d,%d) %x %x %x %x %x\n",
|
||||
msg,
|
||||
context->count[0], context->count[1],
|
||||
context->state[0],
|
||||
context->state[1],
|
||||
context->state[2],
|
||||
context->state[3],
|
||||
context->state[4]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||
|
||||
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
|
||||
{
|
||||
uint32_t a, b, c, d, e;
|
||||
typedef union {
|
||||
unsigned char c[64];
|
||||
uint32_t l[16];
|
||||
} CHAR64LONG16;
|
||||
CHAR64LONG16* block;
|
||||
#ifdef SHA1HANDSOFF
|
||||
static unsigned char workspace[64];
|
||||
block = (CHAR64LONG16*)workspace;
|
||||
memcpy(block, buffer, 64);
|
||||
#else
|
||||
block = (CHAR64LONG16*)buffer;
|
||||
#endif
|
||||
/* Copy context->state[] to working vars */
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
e = state[4];
|
||||
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
||||
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
||||
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
||||
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
||||
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
||||
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
||||
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
||||
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
||||
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
||||
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
||||
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
||||
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
||||
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
||||
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
||||
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
||||
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
||||
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
||||
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
||||
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
||||
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
||||
/* Add the working vars back into context.state[] */
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
/* Wipe variables */
|
||||
a = b = c = d = e = 0;
|
||||
}
|
||||
|
||||
|
||||
/* SHA1Init - Initialize new context */
|
||||
|
||||
void SHA1Init(SHA1_CTX* context)
|
||||
{
|
||||
/* SHA1 initialization constants */
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xEFCDAB89;
|
||||
context->state[2] = 0x98BADCFE;
|
||||
context->state[3] = 0x10325476;
|
||||
context->state[4] = 0xC3D2E1F0;
|
||||
context->count[0] = context->count[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Run your data through this. */
|
||||
|
||||
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len) /*
|
||||
JHB */
|
||||
{
|
||||
uint32_t i, j; /* JHB */
|
||||
|
||||
#ifdef VERBOSE
|
||||
SHAPrintContext(context, "before");
|
||||
#endif
|
||||
j = (context->count[0] >> 3) & 63;
|
||||
if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
|
||||
context->count[1] += (len >> 29);
|
||||
if ((j + len) > 63) {
|
||||
memcpy(&context->buffer[j], data, (i = 64-j));
|
||||
SHA1Transform(context->state, context->buffer);
|
||||
for ( ; i + 63 < len; i += 64) {
|
||||
SHA1Transform(context->state, &data[i]);
|
||||
}
|
||||
j = 0;
|
||||
}
|
||||
else i = 0;
|
||||
memcpy(&context->buffer[j], &data[i], len - i);
|
||||
#ifdef VERBOSE
|
||||
SHAPrintContext(context, "after ");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Add padding and return the message digest. */
|
||||
|
||||
void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
|
||||
{
|
||||
uint32_t i; /* JHB */
|
||||
unsigned char finalcount[8];
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
||||
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
||||
}
|
||||
SHA1Update(context, (unsigned char *)"\200", 1);
|
||||
while ((context->count[0] & 504) != 448) {
|
||||
SHA1Update(context, (unsigned char *)"\0", 1);
|
||||
}
|
||||
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform()
|
||||
*/
|
||||
for (i = 0; i < 20; i++) {
|
||||
digest[i] = (unsigned char)
|
||||
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
||||
}
|
||||
/* Wipe variables */
|
||||
i = 0; /* JHB */
|
||||
memset(context->buffer, 0, 64);
|
||||
memset(context->state, 0, 20);
|
||||
memset(context->count, 0, 8);
|
||||
memset(finalcount, 0, 8); /* SWR */
|
||||
#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
|
||||
SHA1Transform(context->state, context->buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
/* This is not quite the MIME base64 algorithm: it uses _ instead of /,
|
||||
and instead of padding the output with = characters we just make the
|
||||
output shorter. */
|
||||
char *mybase64(uint8_t digest[20])
|
||||
{
|
||||
static const char charz[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_";
|
||||
uint8_t input[21];
|
||||
static char output[28];
|
||||
int i, j;
|
||||
uint8_t *p;
|
||||
char *q;
|
||||
uint32_t bv;
|
||||
|
||||
memcpy(input, digest, 20);
|
||||
input[20] = 0; /* Pad to multiple of 3 bytes */
|
||||
|
||||
p = input; q = output;
|
||||
for ( i = 0 ; i < 7 ; i++ ) {
|
||||
bv = (p[0] << 16) | (p[1] << 8) | p[2];
|
||||
p += 3;
|
||||
for ( j = 0 ; j < 4 ; j++ ) {
|
||||
*q++ = charz[(bv >> 18) & 0x3f];
|
||||
bv <<= 6;
|
||||
}
|
||||
}
|
||||
*--q = '\0'; /* The last character is not significant */
|
||||
return output;
|
||||
}
|
||||
|
||||
#ifdef FOR_TESTING_ONLY
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
SHA1_CTX context;
|
||||
uint8_t digest[20], buffer[16384];
|
||||
FILE* file;
|
||||
|
||||
if (argc < 2) {
|
||||
file = stdin;
|
||||
}
|
||||
else {
|
||||
if (!(file = fopen(argv[1], "rb"))) {
|
||||
fputs("Unable to open file.", stderr);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
SHA1Init(&context);
|
||||
while (!feof(file)) { /* note: what if ferror(file) */
|
||||
i = fread(buffer, 1, 16384, file);
|
||||
SHA1Update(&context, buffer, i);
|
||||
}
|
||||
SHA1Final(digest, &context);
|
||||
fclose(file);
|
||||
|
||||
puts(mybase64(digest));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
BIN
extra/syslinux-3.09/com32/libutil/sha1hash.lo
Normal file
BIN
extra/syslinux-3.09/com32/libutil/sha1hash.lo
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/sha1hash.o
Normal file
BIN
extra/syslinux-3.09/com32/libutil/sha1hash.o
Normal file
Binary file not shown.
78
extra/syslinux-3.09/com32/libutil/unbase64.c
Normal file
78
extra/syslinux-3.09/com32/libutil/unbase64.c
Normal file
@@ -0,0 +1,78 @@
|
||||
#ident "$Id: unbase64.c,v 1.1 2005/01/21 00:49:46 hpa Exp $"
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2005 H. Peter Anvin - All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall
|
||||
* be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* unbase64.c
|
||||
*
|
||||
* Convert a string in base64 format to a byte array.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <base64.h>
|
||||
|
||||
static const unsigned char _base64chars[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
|
||||
|
||||
size_t unbase64(unsigned char *buffer, size_t bufsiz, const char *txt)
|
||||
{
|
||||
unsigned int bits = 0;
|
||||
int nbits = 0;
|
||||
char base64tbl[256];
|
||||
int i;
|
||||
char v;
|
||||
size_t nbytes = 0;
|
||||
|
||||
|
||||
memset(base64tbl, -1, sizeof base64tbl);
|
||||
|
||||
for ( i = 0 ; _base64chars[i] ; i++ ) {
|
||||
base64tbl[_base64chars[i]] = i;
|
||||
}
|
||||
|
||||
/* Also support filesystem safe alternate base64 encoding */
|
||||
base64tbl['-'] = 62;
|
||||
base64tbl['_'] = 63;
|
||||
|
||||
while ( *txt ) {
|
||||
if ( (v = base64tbl[(unsigned char) *txt]) >= 0 ) {
|
||||
bits <<= 6;
|
||||
bits += v;
|
||||
nbits += 6;
|
||||
if ( nbits >= 8 ) {
|
||||
if ( nbytes < bufsiz )
|
||||
*buffer++ = (bits >> (nbits-8));
|
||||
nbytes++;
|
||||
nbits -= 8;
|
||||
}
|
||||
}
|
||||
txt++;
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
BIN
extra/syslinux-3.09/com32/libutil/unbase64.lo
Normal file
BIN
extra/syslinux-3.09/com32/libutil/unbase64.lo
Normal file
Binary file not shown.
BIN
extra/syslinux-3.09/com32/libutil/unbase64.o
Normal file
BIN
extra/syslinux-3.09/com32/libutil/unbase64.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user