Update.
1999-10-25 Thorsten Kukuk <kukuk@suse.de> * md5-crypt/md5.h: Remove prototypes for public interface. md5 is used only internal. * md5-crypt/md5-crypt.c: Use internal names for md5 functions, remove weak alias for public names. * md5-crypt/md5.c: Remove weak aliase. 1999-10-25 Andreas Jaeger <aj@suse.de> * math/README.libm-test: New file, documents libm-test.inc. 1999-10-25 Andreas Jaeger <aj@suse.de> * math/gen-libm-test.pl: Only generate a new ulps file when -n is given. (print_ulps_file): Fix loops to not read @tests and @functions since those are not initialized with -n now. (parse_ulps): Set $results{..}{"kind"}.
This commit is contained in:
parent
3a8e65a0a7
commit
a9b5d2eeb1
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
||||
1999-10-25 Thorsten Kukuk <kukuk@suse.de>
|
||||
|
||||
* md5-crypt/md5.h: Remove prototypes for public interface. md5 is
|
||||
used only internal.
|
||||
* md5-crypt/md5-crypt.c: Use internal names for md5 functions,
|
||||
remove weak alias for public names.
|
||||
* md5-crypt/md5.c: Remove weak aliase.
|
||||
|
||||
1999-10-25 Andreas Jaeger <aj@suse.de>
|
||||
|
||||
* math/README.libm-test: New file, documents libm-test.inc.
|
||||
|
||||
1999-10-25 Andreas Jaeger <aj@suse.de>
|
||||
|
||||
* math/gen-libm-test.pl: Only generate a new ulps file when -n is
|
||||
given.
|
||||
(print_ulps_file): Fix loops to not read @tests and @functions
|
||||
since those are not initialized with -n now.
|
||||
(parse_ulps): Set $results{..}{"kind"}.
|
||||
|
||||
1999-10-25 Andreas Jaeger <aj@suse.de>
|
||||
|
||||
* math/gen-libm-test.pl (parse_ulps): Ignore 0 has ulp.
|
||||
|
@ -335,23 +335,23 @@ void __pthread_reset_main_thread(void);
|
||||
void __fresetlockfiles(void);
|
||||
void __pthread_manager_adjust_prio(int thread_prio);
|
||||
|
||||
extern int __pthread_attr_setguardsize __P ((pthread_attr_t *__attr,
|
||||
size_t __guardsize));
|
||||
extern int __pthread_attr_getguardsize __P ((__const pthread_attr_t *__attr,
|
||||
size_t *__guardsize));
|
||||
extern int __pthread_attr_setstackaddr __P ((pthread_attr_t *__attr,
|
||||
void *__stackaddr));
|
||||
extern int __pthread_attr_getstackaddr __P ((__const pthread_attr_t *__attr,
|
||||
void **__stackaddr));
|
||||
extern int __pthread_attr_setstacksize __P ((pthread_attr_t *__attr,
|
||||
size_t __stacksize));
|
||||
extern int __pthread_attr_getstacksize __P ((__const pthread_attr_t *__attr,
|
||||
size_t *__stacksize));
|
||||
extern int __pthread_getconcurrency __P ((void));
|
||||
extern int __pthread_setconcurrency __P ((int __level));
|
||||
extern int __pthread_mutexattr_gettype __P ((__const pthread_mutexattr_t *__attr,
|
||||
int *__kind));
|
||||
extern void __pthread_kill_other_threads_np __P ((void));
|
||||
extern int __pthread_attr_setguardsize (pthread_attr_t *__attr,
|
||||
size_t __guardsize) __THROW;
|
||||
extern int __pthread_attr_getguardsize (__const pthread_attr_t *__attr,
|
||||
size_t *__guardsize) __THROW;
|
||||
extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
|
||||
void *__stackaddr) __THROW;
|
||||
extern int __pthread_attr_getstackaddr (__const pthread_attr_t *__attr,
|
||||
void **__stackaddr) __THROW;
|
||||
extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
|
||||
size_t __stacksize) __THROW;
|
||||
extern int __pthread_attr_getstacksize (__const pthread_attr_t *__attr,
|
||||
size_t *__stacksize) __THROW;
|
||||
extern int __pthread_getconcurrency (void) __THROW;
|
||||
extern int __pthread_setconcurrency (int __level) __THROW;
|
||||
extern int __pthread_mutexattr_gettype (__const pthread_mutexattr_t *__attr,
|
||||
int *__kind) __THROW;
|
||||
extern void __pthread_kill_other_threads_np (void) __THROW;
|
||||
|
||||
/* Prototypes for the function without cancelation support when the
|
||||
normal version has it. */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* libc-internal interface for thread-specific data.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -17,7 +17,7 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <sys/cdefs.h> /* for __P */
|
||||
#include <sys/cdefs.h> /* for __const */
|
||||
#include <bits/libc-tsd.h>
|
||||
|
||||
/* This file provides uinitialized (common) definitions for the
|
||||
@ -29,6 +29,6 @@
|
||||
If -lpthread is not used, these uninitialized variables default to zero,
|
||||
which the __libc_tsd_* macros check for. */
|
||||
|
||||
void *(*__libc_internal_tsd_get) __P ((enum __libc_tsd_key_t));
|
||||
int (*__libc_internal_tsd_set) __P ((enum __libc_tsd_key_t,
|
||||
__const void *));
|
||||
void *(*__libc_internal_tsd_get) (enum __libc_tsd_key_t);
|
||||
int (*__libc_internal_tsd_set) (enum __libc_tsd_key_t,
|
||||
__const void *);
|
||||
|
@ -49,31 +49,31 @@ __BEGIN_DECLS
|
||||
|
||||
/* Initialize semaphore object SEM to VALUE. If PSHARED then share it
|
||||
with other processes. */
|
||||
extern int sem_init __P ((sem_t *__sem, int __pshared, unsigned int __value));
|
||||
extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW;
|
||||
|
||||
/* Free resources associated with semaphore object SEM. */
|
||||
extern int sem_destroy __P ((sem_t *__sem));
|
||||
extern int sem_destroy (sem_t *__sem) __THROW;
|
||||
|
||||
/* Open a named semaphore NAME with open flaot OFLAG. */
|
||||
extern sem_t *sem_open __P ((__const char *__name, int __oflag, ...));
|
||||
extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW;
|
||||
|
||||
/* Close descriptor for named semaphore SEM. */
|
||||
extern int sem_close __P ((sem_t *__sem));
|
||||
extern int sem_close (sem_t *__sem) __THROW;
|
||||
|
||||
/* Remove named semaphore NAME. */
|
||||
extern int sem_unlink __P ((__const char *__name));
|
||||
extern int sem_unlink (__const char *__name) __THROW;
|
||||
|
||||
/* Wait for SEM being posted. */
|
||||
extern int sem_wait __P ((sem_t *__sem));
|
||||
extern int sem_wait (sem_t *__sem) __THROW;
|
||||
|
||||
/* Test whether SEM is posted. */
|
||||
extern int sem_trywait __P ((sem_t *__sem));
|
||||
extern int sem_trywait (sem_t *__sem) __THROW;
|
||||
|
||||
/* Post SEM. */
|
||||
extern int sem_post __P ((sem_t *__sem));
|
||||
extern int sem_post (sem_t *__sem) __THROW;
|
||||
|
||||
/* Get current value of SEM and store it in *SVAL. */
|
||||
extern int sem_getvalue __P ((sem_t *__sem, int *__sval));
|
||||
extern int sem_getvalue (sem_t *__sem, int *__sval) __THROW;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -69,7 +69,7 @@ int pthread_kill(pthread_t thread, int signo)
|
||||
}
|
||||
|
||||
/* User-provided signal handlers */
|
||||
typedef void (*arch_sighandler_t) __PMT ((int, SIGCONTEXT));
|
||||
typedef void (*arch_sighandler_t) (int, SIGCONTEXT);
|
||||
static union
|
||||
{
|
||||
arch_sighandler_t old;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* libc-internal interface for thread-specific data. LinuxThreads version.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -26,9 +26,9 @@ enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
|
||||
_LIBC_TSD_KEY_DL_ERROR,
|
||||
_LIBC_TSD_KEY_N };
|
||||
|
||||
extern void *(*__libc_internal_tsd_get) __P ((enum __libc_tsd_key_t));
|
||||
extern int (*__libc_internal_tsd_set) __P ((enum __libc_tsd_key_t,
|
||||
__const void *));
|
||||
extern void *(*__libc_internal_tsd_get) (enum __libc_tsd_key_t) __THROW;
|
||||
extern int (*__libc_internal_tsd_set) (enum __libc_tsd_key_t,
|
||||
__const void *) __THROW;
|
||||
|
||||
#define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data;
|
||||
#define __libc_tsd_get(KEY) \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Signal handling function for threaded programs.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -28,10 +28,10 @@
|
||||
|
||||
/* Modify the signal mask for the calling thread. The arguments have
|
||||
the same meaning as for sigprocmask(2). */
|
||||
extern int pthread_sigmask __P ((int __how, __const __sigset_t *__newmask,
|
||||
__sigset_t *__oldmask));
|
||||
extern int pthread_sigmask (int __how, __const __sigset_t *__newmask,
|
||||
__sigset_t *__oldmask)__THROW;
|
||||
|
||||
/* Send signal SIGNO to the given thread. */
|
||||
extern int pthread_kill __P ((pthread_t __thread, int __signo));
|
||||
extern int pthread_kill (pthread_t __thread, int __signo) __THROW;
|
||||
|
||||
#endif /* bits/sigthread.h */
|
||||
|
@ -21,9 +21,9 @@
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int __pthread_return_0 __P ((void));
|
||||
extern int __pthread_return_1 __P ((void));
|
||||
extern void __pthread_return_void __P ((void));
|
||||
extern int __pthread_return_0 (void) __THROW;
|
||||
extern int __pthread_return_1 (void) __THROW;
|
||||
extern void __pthread_return_void (void) __THROW;
|
||||
|
||||
/* Those are pthread functions which return 0 if successful. */
|
||||
#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
|
||||
|
107
math/README.libm-test
Normal file
107
math/README.libm-test
Normal file
@ -0,0 +1,107 @@
|
||||
README for libm-test math test suite
|
||||
====================================
|
||||
|
||||
The libm-test math test suite tests a number of function points of
|
||||
math functions in the GNU C library. The following sections contain a
|
||||
brief overview. Please note that the test drivers and the Perl script
|
||||
"gen-libm-test.pl" have some options. A full list of options is
|
||||
available with --help (for the test drivers) and -h for
|
||||
"gen-libm-test.pl".
|
||||
|
||||
|
||||
What is tested?
|
||||
===============
|
||||
The tests just evaluate the functions at specified points and compare
|
||||
the results with precomputed values and the requirements of the ISO
|
||||
C99 standard.
|
||||
|
||||
Besides testing the special values mandated by IEEE 754 (infinities,
|
||||
NaNs and minus zero), some more or less random values are tested.
|
||||
|
||||
Files that are part of libm-test
|
||||
================================
|
||||
|
||||
The main file is "libm-test.inc". It is platform and floating point
|
||||
format independent. The file must be preprocessed by the Perl script
|
||||
"gen-libm-test.pl". The results are "libm-test.c" and a file
|
||||
"libm-test-ulps.h" with platform specific deltas.
|
||||
|
||||
The test drivers test-double.c, test-float.c, test-ldouble.c test the
|
||||
normal double, float and long double implementation of libm. The test
|
||||
drivers with an i in it (test-idouble.c, test-ifloat.c,
|
||||
test-ildoubl.c) test the corresponding inline functions (where
|
||||
available - otherwise they also test the real functions in libm).
|
||||
|
||||
"gen-libm-test.pl" needs a platform specific files with ULPs (Units of
|
||||
Last Precision). The file is called "libm-test-ulps" and lives in
|
||||
platform specific sysdep directory.
|
||||
|
||||
How can I generate "libm-test-ulps"?
|
||||
====================================
|
||||
|
||||
The test drivers have an option "-u" to output an unsorted list of all
|
||||
epsilons that the functions have. The output can be read in directly
|
||||
but it's better to pretty print it first. "gen-libm-test.pl" has an option
|
||||
to generate a pretty-printed and sorted new ULPs file from the output
|
||||
of the test drivers.
|
||||
|
||||
To generate a new "libm-test-ulps" file, you can execute for example:
|
||||
test-double -u --ignore-max-ulp=yes
|
||||
This generates a file "ULPs" with all double ULPs in it, ignoring any
|
||||
previous calculated ULPs.
|
||||
Now move this away, e.g. "mv ULPs allULPs" and generate the ULPs
|
||||
for all other formats and concat all ULP files together (e.g. "cat
|
||||
ULPs >> allULPs"). As final step run "gen-libm-test.pl" with the file
|
||||
as input and ask to generate a pretty printed output in the file "NewUlps":
|
||||
gen-libm-test.pl -u allULPs -n
|
||||
|
||||
Now you can rename "NewUlps" to "libm-test-ulps" and move it into
|
||||
sysdeps.
|
||||
|
||||
Contents of libm-test-ulps
|
||||
==========================
|
||||
Since libm-test-ulps can be generated automatically, just a few
|
||||
notes. The file contains lines for single tests, like:
|
||||
Test "cos (pi/2) == 0":
|
||||
float: 1
|
||||
|
||||
and lines for maximal errors of single functions, like:
|
||||
Function "yn":
|
||||
idouble: 6.0000
|
||||
|
||||
The keywords are float, ifloat, double, idouble, ldouble and ildouble
|
||||
(the prefix i stands for inline). You can also specify known
|
||||
failures, e.g.:
|
||||
|
||||
Test "cos (pi/2) == 0":
|
||||
float: 1
|
||||
float: fail
|
||||
|
||||
Adding tests to libm-test.inc
|
||||
=============================
|
||||
|
||||
The tests are evaluated by a set of special test macros. The macros
|
||||
start with "TEST_" followed by a specification the input values, an
|
||||
underscore and a specification of the output values. As an example,
|
||||
the test macro for a function with input of type FLOAT (FLOAT is
|
||||
either float, double, long double) and output of type FLOAT is
|
||||
"TEST_f_f". The macro's parameter are the name of the function, the
|
||||
input parameter, output parameter and optionally one exception
|
||||
parameter.
|
||||
|
||||
The accepted parameter types are:
|
||||
- "f" for FLOAT
|
||||
- "b" for boolean - just tests if the output parameter evaluates to 0
|
||||
or 1 (only for output).
|
||||
- "c" for complex. This parameter needs two values, first the real,
|
||||
then the imaginary part.
|
||||
- "i" for int.
|
||||
- "l" for long int.
|
||||
- "L" for long long int.
|
||||
- "F" for the address of a FLOAT (only as input parameter)
|
||||
- "I" for the address of an int (only as input parameter)
|
||||
|
||||
Some functions need special handling. For example gamma sets the
|
||||
global variable signgam and frexp takes an argument to &int. This
|
||||
special treatment is coded in "gen-libm-test.pl" and used while
|
||||
parsing "libm-test.inc".
|
@ -23,6 +23,8 @@
|
||||
# Note that functions and tests share the same namespace.
|
||||
|
||||
# Information about tests are stored in: %results
|
||||
# $results{$test}{"kind"} is either "fct" or "test" and flags whether this
|
||||
# is a maximal error of a function or a single test.
|
||||
# $results{$test}{"type"} is the result type, e.g. normal or complex.
|
||||
# $results{$test}{"has_ulps"} is set if deltas exist.
|
||||
# $results{$test}{"has_fails"} is set if exptected failures exist.
|
||||
@ -102,7 +104,7 @@ if ($opt_h) {
|
||||
print "Usage: gen-libm-test.pl [OPTIONS]\n";
|
||||
print " -h print this help, then exit\n";
|
||||
print " -o DIR directory where generated files will be placed\n";
|
||||
print " -n generate sorted file NewUlps from libm-test-ulps\n";
|
||||
print " -n only generate sorted file NewUlps from libm-test-ulps\n";
|
||||
print " -u FILE input file with ulps\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -116,8 +118,8 @@ $output = "${output_dir}libm-test.c";
|
||||
$count = 0;
|
||||
|
||||
&parse_ulps ($ulps_file);
|
||||
&generate_testfile ($input, $output);
|
||||
&output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file);
|
||||
&generate_testfile ($input, $output) unless ($opt_n);
|
||||
&output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
|
||||
&print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
|
||||
|
||||
# Return a nicer representation
|
||||
@ -484,7 +486,7 @@ sub generate_testfile {
|
||||
# Parse ulps file
|
||||
sub parse_ulps {
|
||||
my ($file) = @_;
|
||||
my ($test, $type, $float, $eps);
|
||||
my ($test, $type, $float, $eps, $kind);
|
||||
|
||||
# $type has the following values:
|
||||
# "normal": No complex variable
|
||||
@ -508,6 +510,7 @@ sub parse_ulps {
|
||||
}
|
||||
s/^.+\"(.*)\".*$/$1/;
|
||||
$test = $_;
|
||||
$kind = 'test';
|
||||
next;
|
||||
}
|
||||
if (/^Function: /) {
|
||||
@ -521,6 +524,7 @@ sub parse_ulps {
|
||||
$type = 'normal';
|
||||
}
|
||||
($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
|
||||
$kind = 'fct';
|
||||
next;
|
||||
}
|
||||
if (/^i?(float|double|ldouble):/) {
|
||||
@ -541,6 +545,7 @@ sub parse_ulps {
|
||||
} elsif ($type eq 'normal') {
|
||||
$results{$test}{'type'} = 'normal';
|
||||
}
|
||||
$results{$test}{'kind'} = $kind;
|
||||
next;
|
||||
}
|
||||
print "Skipping unknown entry: `$_'\n";
|
||||
@ -567,7 +572,9 @@ sub print_ulps_file {
|
||||
$last_fct = '';
|
||||
open NEWULP, ">$file" or die ("Can't open $file: $!");
|
||||
print NEWULP "# Begin of automatic generation\n";
|
||||
foreach $test (sort @tests) {
|
||||
# first the function calls
|
||||
foreach $test (sort keys %results) {
|
||||
next if ($results{$test}{'kind'} ne 'test');
|
||||
foreach $type ('real', 'imag', 'normal') {
|
||||
if (exists $results{$test}{$type}) {
|
||||
if (defined $results{$test}) {
|
||||
@ -599,7 +606,8 @@ sub print_ulps_file {
|
||||
}
|
||||
print NEWULP "\n# Maximal error of functions:\n";
|
||||
|
||||
foreach $fct (sort @functions) {
|
||||
foreach $fct (sort keys %results) {
|
||||
next if ($results{$fct}{'kind'} ne 'fct');
|
||||
foreach $type ('real', 'imag', 'normal') {
|
||||
if (exists $results{$fct}{$type}) {
|
||||
if ($type eq 'normal') {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* One way encryption based on MD5 sum.
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
|
||||
@ -39,11 +39,7 @@ static const char b64t[64] =
|
||||
/* Prototypes for local functions. */
|
||||
extern char *__md5_crypt_r __P ((const char *key, const char *salt,
|
||||
char *buffer, int buflen));
|
||||
extern char *md5_crypt_r __P ((const char *key, const char *salt,
|
||||
char *buffer, int buflen));
|
||||
extern char *__md5_crypt __P ((const char *key, const char *salt));
|
||||
extern char *md5_crypt __P ((const char *key, const char *salt));
|
||||
|
||||
|
||||
|
||||
/* This entry point is equivalent to the `crypt' function in Unix
|
||||
@ -73,42 +69,42 @@ __md5_crypt_r (key, salt, buffer, buflen)
|
||||
key_len = strlen (key);
|
||||
|
||||
/* Prepare for the real work. */
|
||||
md5_init_ctx (&ctx);
|
||||
__md5_init_ctx (&ctx);
|
||||
|
||||
/* Add the key string. */
|
||||
md5_process_bytes (key, key_len, &ctx);
|
||||
__md5_process_bytes (key, key_len, &ctx);
|
||||
|
||||
/* Because the SALT argument need not always have the salt prefix we
|
||||
add it separately. */
|
||||
md5_process_bytes (md5_salt_prefix, sizeof (md5_salt_prefix) - 1, &ctx);
|
||||
__md5_process_bytes (md5_salt_prefix, sizeof (md5_salt_prefix) - 1, &ctx);
|
||||
|
||||
/* The last part is the salt string. This must be at most 8
|
||||
characters and it ends at the first `$' character (for
|
||||
compatibility which existing solutions). */
|
||||
md5_process_bytes (salt, salt_len, &ctx);
|
||||
__md5_process_bytes (salt, salt_len, &ctx);
|
||||
|
||||
|
||||
/* Compute alternate MD5 sum with input KEY, SALT, and KEY. The
|
||||
final result will be added to the first context. */
|
||||
md5_init_ctx (&alt_ctx);
|
||||
__md5_init_ctx (&alt_ctx);
|
||||
|
||||
/* Add key. */
|
||||
md5_process_bytes (key, key_len, &alt_ctx);
|
||||
__md5_process_bytes (key, key_len, &alt_ctx);
|
||||
|
||||
/* Add salt. */
|
||||
md5_process_bytes (salt, salt_len, &alt_ctx);
|
||||
__md5_process_bytes (salt, salt_len, &alt_ctx);
|
||||
|
||||
/* Add key again. */
|
||||
md5_process_bytes (key, key_len, &alt_ctx);
|
||||
__md5_process_bytes (key, key_len, &alt_ctx);
|
||||
|
||||
/* Now get result of this (16 bytes) and add it to the other
|
||||
context. */
|
||||
md5_finish_ctx (&alt_ctx, alt_result);
|
||||
__md5_finish_ctx (&alt_ctx, alt_result);
|
||||
|
||||
/* Add for any character in the key one byte of the alternate sum. */
|
||||
for (cnt = key_len; cnt > 16; cnt -= 16)
|
||||
md5_process_bytes (alt_result, 16, &ctx);
|
||||
md5_process_bytes (alt_result, cnt, &ctx);
|
||||
__md5_process_bytes (alt_result, 16, &ctx);
|
||||
__md5_process_bytes (alt_result, cnt, &ctx);
|
||||
|
||||
/* For the following code we need a NUL byte. */
|
||||
*alt_result = '\0';
|
||||
@ -118,11 +114,11 @@ __md5_crypt_r (key, salt, buffer, buflen)
|
||||
bit the first character of the key. This does not seem to be
|
||||
what was intended but we have to follow this to be compatible. */
|
||||
for (cnt = key_len; cnt > 0; cnt >>= 1)
|
||||
md5_process_bytes ((cnt & 1) != 0 ? (const char *) alt_result : key, 1,
|
||||
&ctx);
|
||||
__md5_process_bytes ((cnt & 1) != 0 ? (const char *) alt_result : key, 1,
|
||||
&ctx);
|
||||
|
||||
/* Create intermediate result. */
|
||||
md5_finish_ctx (&ctx, alt_result);
|
||||
__md5_finish_ctx (&ctx, alt_result);
|
||||
|
||||
/* Now comes another weirdness. In fear of password crackers here
|
||||
comes a quite long loop which just processes the output of the
|
||||
@ -130,30 +126,30 @@ __md5_crypt_r (key, salt, buffer, buflen)
|
||||
for (cnt = 0; cnt < 1000; ++cnt)
|
||||
{
|
||||
/* New context. */
|
||||
md5_init_ctx (&ctx);
|
||||
__md5_init_ctx (&ctx);
|
||||
|
||||
/* Add key or last result. */
|
||||
if ((cnt & 1) != 0)
|
||||
md5_process_bytes (key, key_len, &ctx);
|
||||
__md5_process_bytes (key, key_len, &ctx);
|
||||
else
|
||||
md5_process_bytes (alt_result, 16, &ctx);
|
||||
__md5_process_bytes (alt_result, 16, &ctx);
|
||||
|
||||
/* Add salt for numbers not divisible by 3. */
|
||||
if (cnt % 3 != 0)
|
||||
md5_process_bytes (salt, salt_len, &ctx);
|
||||
__md5_process_bytes (salt, salt_len, &ctx);
|
||||
|
||||
/* Add key for numbers not divisible by 7. */
|
||||
if (cnt % 7 != 0)
|
||||
md5_process_bytes (key, key_len, &ctx);
|
||||
__md5_process_bytes (key, key_len, &ctx);
|
||||
|
||||
/* Add key or last result. */
|
||||
if ((cnt & 1) != 0)
|
||||
md5_process_bytes (alt_result, 16, &ctx);
|
||||
__md5_process_bytes (alt_result, 16, &ctx);
|
||||
else
|
||||
md5_process_bytes (key, key_len, &ctx);
|
||||
__md5_process_bytes (key, key_len, &ctx);
|
||||
|
||||
/* Create intermediate result. */
|
||||
md5_finish_ctx (&ctx, alt_result);
|
||||
__md5_finish_ctx (&ctx, alt_result);
|
||||
}
|
||||
|
||||
/* Now we can construct the result string. It consists of three
|
||||
@ -204,13 +200,10 @@ __md5_crypt_r (key, salt, buffer, buflen)
|
||||
|
||||
return buffer;
|
||||
}
|
||||
weak_alias (__md5_crypt_r, md5_crypt_r)
|
||||
|
||||
|
||||
char *
|
||||
__md5_crypt (key, salt)
|
||||
const char *key;
|
||||
const char *salt;
|
||||
__md5_crypt (const char *key, const char *salt)
|
||||
{
|
||||
/* We don't want to have an arbitrary limit in the size of the
|
||||
password. We can compute the size of the result in advance and
|
||||
@ -228,4 +221,3 @@ __md5_crypt (key, salt)
|
||||
|
||||
return __md5_crypt_r (key, salt, buffer, buflen);
|
||||
}
|
||||
weak_alias (__md5_crypt, md5_crypt)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
|
||||
according to the definition of MD5 in RFC 1321 from April 1992.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -43,7 +43,7 @@
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
/* We need to keep the namespace clean so define the MD5 function
|
||||
protected using leading __ and use weak aliases. */
|
||||
protected using leading __ . */
|
||||
# define md5_init_ctx __md5_init_ctx
|
||||
# define md5_process_block __md5_process_block
|
||||
# define md5_process_bytes __md5_process_bytes
|
||||
@ -426,22 +426,3 @@ md5_process_block (buffer, len, ctx)
|
||||
ctx->C = C;
|
||||
ctx->D = D;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Define weak aliases. */
|
||||
# undef md5_init_ctx
|
||||
weak_alias (__md5_init_ctx, md5_init_ctx)
|
||||
# undef md5_process_block
|
||||
weak_alias (__md5_process_block, md5_process_block)
|
||||
# undef md5_process_bytes
|
||||
weak_alias (__md5_process_bytes, md5_process_bytes)
|
||||
# undef md5_finish_ctx
|
||||
weak_alias (__md5_finish_ctx, md5_finish_ctx)
|
||||
# undef md5_read_ctx
|
||||
weak_alias (__md5_read_ctx, md5_read_ctx)
|
||||
# undef md5_stream
|
||||
weak_alias (__md5_stream, md5_stream)
|
||||
# undef md5_buffer
|
||||
weak_alias (__md5_buffer, md5_buffer)
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Declaration of functions and data types used for MD5 sum computing
|
||||
library functions.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -98,7 +98,6 @@ struct md5_ctx
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
extern void __md5_init_ctx __P ((struct md5_ctx *ctx));
|
||||
extern void md5_init_ctx __P ((struct md5_ctx *ctx));
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
@ -106,8 +105,6 @@ extern void md5_init_ctx __P ((struct md5_ctx *ctx));
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void __md5_process_block __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
extern void md5_process_block __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
@ -115,8 +112,6 @@ extern void md5_process_block __P ((const void *buffer, size_t len,
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void __md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
extern void md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 16 bytes following RESBUF. The result is always in little
|
||||
@ -126,7 +121,6 @@ extern void md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *__md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
|
||||
extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result is
|
||||
@ -136,7 +130,6 @@ extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *__md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
|
||||
extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
@ -150,7 +143,5 @@ extern int __md5_stream __P ((FILE *stream, void *resblock));
|
||||
digest. */
|
||||
extern void *__md5_buffer __P ((const char *buffer, size_t len,
|
||||
void *resblock));
|
||||
extern void *md5_buffer __P ((const char *buffer, size_t len,
|
||||
void *resblock));
|
||||
|
||||
#endif /* md5.h */
|
||||
|
Loading…
Reference in New Issue
Block a user