summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/arc4random.383
-rw-r--r--lib/libc/gen/arc4random.c172
-rw-r--r--lib/libc/gen/stringlist.3120
-rw-r--r--lib/libc/gen/stringlist.c120
-rw-r--r--lib/libc/i386/string/memcpy.S2
-rw-r--r--lib/libc/locale/mskanji.c107
6 files changed, 0 insertions, 604 deletions
diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3
deleted file mode 100644
index 25c6d4d0a02ec..0000000000000
--- a/lib/libc/gen/arc4random.3
+++ /dev/null
@@ -1,83 +0,0 @@
-.\" $OpenBSD: arc4random.3,v 1.2 1997/04/27 22:40:25 angelos Exp $
-.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Niels Provos.
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" Manual page, using -mandoc macros
-.\"
-.Dd April 15, 1997
-.Dt ARC4RANDOM 3
-.Os
-.Sh NAME
-.Nm arc4random,
-.Nm arc4random_stir,
-.Nm arc4random_addrandom
-.Nd arc4 random number generator.
-.Sh SYNOPSIS
-.Fd #include <stdlib.h>
-.Ft u_int32_t
-.Fn arc4random "void"
-.Ft void
-.Fn arc4random_stir "void"
-.Ft void
-.Fn arc4random_addrandom "unsigned char *dat" "int datlen"
-.Sh DESCRIPTION
-The
-.Fn arc4random
-function uses the key stream generator employed by the
-arc4 cipher, which uses 8*8 8 bit S-Boxes. The S-Boxes
-can be in about
-.if t 2\u\s71700\s10\d
-.if n (2**1700)
-states.
-.Pp
-The
-.Fn arc4random_stir
-function reads data from
-.Pa /dev/urandom
-and uses it to permutate the S-Boxes via
-.Fn arc4random_addrandom .
-.Pp
-There is no need to call
-.Fn arc4random_stir
-before using
-.Fn arc4random ,
-since
-.Fn arc4random
-automatically initalizes itself.
-.Sh SEE ALSO
-.Xr rand 3 ,
-.Xr random 3 ,
-.Xr srandomdev 3
-.Sh HISTORY
-.Pa RC4
-has been designed by RSA Data Security, Inc. It was posted anonymously
-to the USENET and was confirmed to be equivalent by several sources who
-had access to the original cipher. Since
-.Pa RC4
-used to be a trade secret, the cipher is now refered to as
-.Pa ARC4 .
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c
deleted file mode 100644
index b9f8a48468328..0000000000000
--- a/lib/libc/gen/arc4random.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* $Id: arc4random.c,v 1.1 1996/12/28 06:33:01 dm Exp $ */
-
-/*
- * Arc4 random number generator for OpenBSD.
- * Copyright 1996 David Mazieres <dm@lcs.mit.edu>.
- *
- * Modification and redistribution in source and binary forms is
- * permitted provided that due credit is given to the author and the
- * OpenBSD project (for instance by leaving this copyright notice
- * intact).
- */
-
-/*
- * This code is derived from section 17.1 of Applied Cryptography,
- * second edition, which describes a stream cipher allegedly
- * compatible with RSA Labs "RC4" cipher (the actual description of
- * which is a trade secret). The same algorithm is used as a stream
- * cipher called "arcfour" in Tatu Ylonen's ssh package.
- *
- * Here the stream cipher has been modified always to include the time
- * when initializing the state. That makes it impossible to
- * regenerate the same random sequence twice, so this can't be used
- * for encryption, but will generate good random numbers.
- *
- * RC4 is a registered trademark of RSA Laboratories.
- */
-
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-struct arc4_stream {
- u_int8_t i;
- u_int8_t j;
- u_int8_t s[256];
-};
-
-static int rs_initialized;
-static struct arc4_stream rs;
-
-static inline void
-arc4_init(as)
- struct arc4_stream *as;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- as->s[n] = n;
- as->i = 0;
- as->j = 0;
-}
-
-static inline void
-arc4_addrandom(as, dat, datlen)
- struct arc4_stream *as;
- u_char *dat;
- int datlen;
-{
- int n;
- u_int8_t si;
-
- as->i--;
- for (n = 0; n < 256; n++) {
- as->i = (as->i + 1);
- si = as->s[as->i];
- as->j = (as->j + si + dat[n % datlen]);
- as->s[as->i] = as->s[as->j];
- as->s[as->j] = si;
- }
-}
-
-static void
-arc4_stir(as)
- struct arc4_stream *as;
-{
- int fd;
- struct {
- struct timeval tv;
- pid_t pid;
- u_int8_t rnd[128 - sizeof(struct timeval) - sizeof(pid_t)];
- } rdat;
-
- gettimeofday(&rdat.tv, NULL);
- rdat.pid = getpid();
- fd = open("/dev/urandom", O_RDONLY, 0);
- if (fd >= 0) {
- (void) read(fd, rdat.rnd, sizeof(rdat.rnd));
- close(fd);
- }
- /* fd < 0? Ah, what the heck. We'll just take whatever was on the
- * stack... */
-
- arc4_addrandom(as, (void *) &rdat, sizeof(rdat));
-}
-
-static inline u_int8_t
-arc4_getbyte(as)
- struct arc4_stream *as;
-{
- u_int8_t si, sj;
-
- as->i = (as->i + 1);
- si = as->s[as->i];
- as->j = (as->j + si);
- sj = as->s[as->j];
- as->s[as->i] = sj;
- as->s[as->j] = si;
- return (as->s[(si + sj) & 0xff]);
-}
-
-static inline u_int32_t
-arc4_getword(as)
- struct arc4_stream *as;
-{
- u_int32_t val;
- val = arc4_getbyte(as) << 24;
- val |= arc4_getbyte(as) << 16;
- val |= arc4_getbyte(as) << 8;
- val |= arc4_getbyte(as);
- return val;
-}
-
-void
-arc4random_stir()
-{
- if (!rs_initialized) {
- arc4_init(&rs);
- rs_initialized = 1;
- }
- arc4_stir(&rs);
-}
-
-void
-arc4random_addrandom(dat, datlen)
- u_char *dat;
- int datlen;
-{
- if (!rs_initialized)
- arc4random_stir();
- arc4_addrandom(&rs, dat, datlen);
-}
-
-u_int32_t
-arc4random()
-{
- if (!rs_initialized)
- arc4random_stir();
- return arc4_getword(&rs);
-}
-
-#if 0
-/*-------- Test code for i386 --------*/
-#include <stdio.h>
-#include <machine/pctr.h>
-int
-main(int argc, char **argv)
-{
- const int iter = 1000000;
- int i;
- pctrval v;
-
- v = rdtsc();
- for (i = 0; i < iter; i++)
- arc4random();
- v = rdtsc() - v;
- v /= iter;
-
- printf("%qd cycles\n", v);
-}
-#endif
diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3
deleted file mode 100644
index 5023c5cebb02a..0000000000000
--- a/lib/libc/gen/stringlist.3
+++ /dev/null
@@ -1,120 +0,0 @@
-.\" $NetBSD: stringlist.3,v 1.2 1997/04/09 08:59:25 kleink Exp $
-.\"
-.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
-.\" contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd February 24, 1997
-.Os NetBSD 1.3
-.Dt STRINGLIST 3
-.Sh NAME
-.Nm stringlist ,
-.Nm sl_init ,
-.Nm sl_add ,
-.Nm sl_free ,
-.Nm sl_find
-.Nd stringlist manipulation functions
-.Sh SYNOPSIS
-.Fd #include <stringlist.h>
-.Ft StringList *
-.Fn sl_init
-.Ft void
-.Fn sl_add "StringList *sl" "char *item"
-.Ft void
-.Fn sl_free "StringList *sl" "int freeall"
-.Ft char *
-.Fn sl_find "StringList *sl" "char *item"
-.Sh DESCRIPTION
-The
-.Nm
-functions manipulate stringlists, which are lists of
-strings that extend automatically if necessary.
-.Pp
-The
-.Ar StringList
-structure has the following definition:
-.Bd -literal -offset indent
-typedef struct _stringlist {
- char **sl_str;
- size_t sl_max;
- size_t sl_cur;
-} StringList;
-.Ed
-.Pp
-.Bl -tag -width "sl_str" -offset indent
-.It Ar sl_str
-a pointer to the base of the array containing the list.
-.It Ar sl_max
-the size of
-.Ar sl_str .
-.It Ar sl_cur
-the offset in
-.Ar sl_str
-of the current element.
-.El
-.Pp
-The following stringlist manipulation functions are available:
-.Bl -tag -width "sl_init()"
-.It Fn sl_init
-Create a stringlist.
-Returns a pointer to a
-.Ar StringList .
-.It Fn sl_free
-Releases memory occupied by
-.Ar sl
-and the
-.Ar sl->sl_str
-array.
-If
-.Ar freeall
-is non-zero, then each of the items within
-.Ar sl->sl_str
-is released as well.
-.It Fn sl_add
-Add
-.Ar item
-to
-.Ar sl->sl_str
-at
-.Ar sl->sl_cur ,
-extending the size of
-.Ar sl->sl_str
-.It Fn sl_find
-Find
-.Ar item
-in
-.Ar sl ,
-returning NULL if it's not found.
-.El
-.Sh SEE ALSO
-.Xr free 3 ,
-.Xr malloc 3
diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c
deleted file mode 100644
index 57c4d91485e80..0000000000000
--- a/lib/libc/gen/stringlist.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* $NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $ */
-
-/*
- * Copyright (c) 1994 Christos Zoulas
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <string.h>
-#include <err.h>
-#include <stdlib.h>
-#include <stringlist.h>
-
-#define _SL_CHUNKSIZE 20
-
-/*
- * sl_init(): Initialize a string list
- */
-StringList *
-sl_init()
-{
- StringList *sl = malloc(sizeof(StringList));
- if (sl == NULL)
- err(1, "stringlist: %m");
-
- sl->sl_cur = 0;
- sl->sl_max = _SL_CHUNKSIZE;
- sl->sl_str = malloc(sl->sl_max * sizeof(char *));
- if (sl->sl_str == NULL)
- err(1, "stringlist: %m");
- return sl;
-}
-
-
-/*
- * sl_add(): Add an item to the string list
- */
-void
-sl_add(sl, name)
- StringList *sl;
- char *name;
-{
- if (sl->sl_cur == sl->sl_max - 1) {
- sl->sl_max += _SL_CHUNKSIZE;
- sl->sl_str = realloc(sl->sl_str, sl->sl_max * sizeof(char *));
- if (sl->sl_str == NULL)
- err(1, "stringlist: %m");
- }
- sl->sl_str[sl->sl_cur++] = name;
-}
-
-
-/*
- * sl_free(): Free a stringlist
- */
-void
-sl_free(sl, all)
- StringList *sl;
- int all;
-{
- size_t i;
-
- if (sl == NULL)
- return;
- if (sl->sl_str) {
- if (all)
- for (i = 0; i < sl->sl_cur; i++)
- free(sl->sl_str[i]);
- free(sl->sl_str);
- }
- free(sl);
-}
-
-
-/*
- * sl_find(): Find a name in the string list
- */
-char *
-sl_find(sl, name)
- StringList *sl;
- char *name;
-{
- size_t i;
-
- for (i = 0; i < sl->sl_cur; i++)
- if (strcmp(sl->sl_str[i], name) == 0)
- return sl->sl_str[i];
-
- return NULL;
-}
diff --git a/lib/libc/i386/string/memcpy.S b/lib/libc/i386/string/memcpy.S
deleted file mode 100644
index 1617c7153aacb..0000000000000
--- a/lib/libc/i386/string/memcpy.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define MEMCOPY
-#include "bcopy.S"
diff --git a/lib/libc/locale/mskanji.c b/lib/libc/locale/mskanji.c
deleted file mode 100644
index bce27fe433863..0000000000000
--- a/lib/libc/locale/mskanji.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * ja_JP.SJIS locale table for BSD4.4/rune
- * version 1.0
- * (C) Sin'ichiro MIYATANI / Phase One, Inc
- * May 12, 1995
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Phase One, Inc.
- * 4. The name of Phase One, Inc. may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifdef XPG4
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <rune.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-rune_t _MSKanji_sgetrune __P((const char *, size_t, char const **));
-int _MSKanji_sputrune __P((rune_t, char *, size_t, char **));
-
-int
-_MSKanji_init(rl)
- _RuneLocale *rl;
-{
- rl->sgetrune = _MSKanji_sgetrune;
- rl->sputrune = _MSKanji_sputrune;
-
- _CurrentRuneLocale = rl;
- __mb_cur_max = 2;
- return (0);
-}
-
-rune_t
-_MSKanji_sgetrune(string, n, result)
- const char *string;
- size_t n;
- char const **result;
-{
- rune_t rune = 0;
-
- if (n < 1 ) {
- rune = _INVALID_RUNE;
- } else {
- rune = *( string++ ) & 0xff;
- if ( ( rune > 0x80 && rune < 0xa0 )
- || ( rune >= 0xe0 && rune < 0xfa ) ) {
- if ( n < 2 ) {
- rune = (rune_t)_INVALID_RUNE;
- --string;
- } else {
- rune = ( rune << 8 ) | ( *( string++ ) & 0xff );
- }
- }
- }
- if (result) *result = string;
- return rune;
-}
-
-int
-_MSKanji_sputrune(c, string, n, result)
- rune_t c;
- char *string, **result;
- size_t n;
-{
- int len, i;
-
- len = ( c > 0x100 ) ? 2 : 1;
- if ( n < len ) {
- if ( result ) *result = (char *) 0;
- } else {
- if ( result ) *result = string + len;
- for ( i = len; i-- > 0; ) {
- *( string++ ) = c >> ( i << 3 );
- }
- }
- return len;
-}
-#endif /* XPG4 */