diff options
-rw-r--r-- | include/Makefile | 5 | ||||
-rw-r--r-- | include/siphash.h | 83 | ||||
-rw-r--r-- | include/stdlib.h | 6 | ||||
-rw-r--r-- | include/unistd.h | 6 |
4 files changed, 88 insertions, 12 deletions
diff --git a/include/Makefile b/include/Makefile index 3889dabd5c8..f0cd78b0785 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.196 2014/10/31 13:46:17 jsing Exp $ +# $OpenBSD: Makefile,v 1.197 2014/12/08 20:39:56 tedu Exp $ # $NetBSD: Makefile,v 1.59 1996/05/15 21:36:43 jtc Exp $ # @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91 @@ -16,7 +16,8 @@ FILES= a.out.h ar.h asr.h assert.h bitstring.h blf.h bsd_auth.h \ langinfo.h libgen.h limits.h locale.h login_cap.h malloc.h math.h \ md5.h memory.h mpool.h ndbm.h netdb.h netgroup.h nlist.h nl_types.h \ paths.h poll.h pwd.h ranlib.h readpassphrase.h regex.h \ - resolv.h rmd160.h search.h setjmp.h sha1.h sha2.h signal.h sndio.h \ + resolv.h rmd160.h search.h setjmp.h sha1.h sha2.h signal.h siphash.h \ + sndio.h \ spawn.h stdbool.h stddef.h stdio.h stdlib.h string.h strings.h struct.h \ sysexits.h tar.h tgmath.h time.h ttyent.h tzfile.h unistd.h utime.h \ utmp.h uuid.h vis.h wchar.h wctype.h diff --git a/include/siphash.h b/include/siphash.h new file mode 100644 index 00000000000..fd3eeb46fef --- /dev/null +++ b/include/siphash.h @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2013 Andre Oppermann <andre@FreeBSD.org> + * 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. 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 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +/* + * SipHash is a family of pseudorandom functions (a.k.a. keyed hash functions) + * optimized for speed on short messages returning a 64bit hash/digest value. + * + * The number of rounds is defined during the initialization: + * SipHash24_Init() for the fast and resonable strong version + * SipHash48_Init() for the strong version (half as fast) + * + * struct SIPHASH_CTX ctx; + * SipHash24_Init(&ctx); + * SipHash_SetKey(&ctx, "16bytes long key"); + * SipHash_Update(&ctx, pointer_to_string, length_of_string); + * SipHash_Final(output, &ctx); + */ + +#ifndef _SIPHASH_H_ +#define _SIPHASH_H_ + +#define SIPHASH_BLOCK_LENGTH 8 +#define SIPHASH_KEY_LENGTH 16 +#define SIPHASH_DIGEST_LENGTH 8 + +typedef struct _SIPHASH_CTX { + u_int64_t v[4]; + u_int8_t buf[SIPHASH_BLOCK_LENGTH]; + u_int32_t bytes; +} SIPHASH_CTX; + +typedef struct { + u_int64_t k0; + u_int64_t k1; +} SIPHASH_KEY; + +void SipHash_Init(SIPHASH_CTX *, const SIPHASH_KEY *); +void SipHash_Update(SIPHASH_CTX *, int, int, const void *, size_t); +u_int64_t SipHash_End(SIPHASH_CTX *, int, int); +void SipHash_Final(void *, SIPHASH_CTX *, int, int); +u_int64_t SipHash(const SIPHASH_KEY *, int, int, const void *, size_t); + +#define SipHash24_Init(_c, _k) SipHash_Init((_c), (_k)) +#define SipHash24_Update(_c, _p, _l) SipHash_Update((_c), 2, 4, (_p), (_l)) +#define SipHash24_End(_d) SipHash_End((_d), 2, 4) +#define SipHash24_Final(_d, _c) SipHash_Final((_d), (_c), 2, 4) +#define SipHash24(_k, _p, _l) SipHash((_k), 2, 4, (_p), (_l)) + +#define SipHash48_Init(_c, _k) SipHash_Init((_c), (_k)) +#define SipHash48_Update(_c, _p, _l) SipHash_Update((_c), 4, 8, (_p), (_l)) +#define SipHash48_End(_d) SipHash_End((_d), 4, 8) +#define SipHash48_Final(_d, _c) SipHash_Final((_d), (_c), 4, 8) +#define SipHash48(_k, _p, _l) SipHash((_k), 4, 8, (_p), (_l)) + +#endif /* _SIPHASH_H_ */ diff --git a/include/stdlib.h b/include/stdlib.h index 520a1b1f9ba..1f8e4a350ce 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdlib.h,v 1.60 2014/08/31 02:21:18 guenther Exp $ */ +/* $OpenBSD: stdlib.h,v 1.61 2014/12/08 20:39:56 tedu Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /*- @@ -194,8 +194,6 @@ void srandom(unsigned int); char *realpath(const char *, char *) __attribute__((__bounded__ (__minbytes__,2,1024))); -int setkey(const char *); - /* * XSI functions marked LEGACY in XPG5 and removed in IEEE Std 1003.1-2001 */ @@ -283,8 +281,6 @@ int daemon(int, int); char *devname(int, mode_t); int getloadavg(double [], int); -void cfree(void *); - const char * getprogname(void); void setprogname(const char *); diff --git a/include/unistd.h b/include/unistd.h index 0a8bca39edd..0bc85d2b1ce 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unistd.h,v 1.94 2014/11/21 05:13:44 tedu Exp $ */ +/* $OpenBSD: unistd.h,v 1.95 2014/12/08 20:39:56 tedu Exp $ */ /* $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $ */ /*- @@ -413,7 +413,6 @@ int fdatasync(int); #if __XPG_VISIBLE || __BSD_VISIBLE char *crypt(const char *, const char *); -int encrypt(char *, int); int fchdir(int); int fchown(int, uid_t, gid_t); long gethostid(void); @@ -423,7 +422,6 @@ int lchown(const char *, uid_t, gid_t); int mkstemp(char *); char *mktemp(char *); int nice(int); -int setkey(const char *); int setregid(gid_t, gid_t); int setreuid(uid_t, uid_t); void swab(const void *, void *, size_t); @@ -490,8 +488,6 @@ int acct(const char *); int closefrom(int); int crypt_checkpass(const char *, const char *); int crypt_newhash(const char *, const char *, char *, size_t); -int des_cipher(const char *, char *, int32_t, int); -int des_setkey(const char *); void endusershell(void); int exect(const char *, char * const *, char * const *); char *fflagstostr(u_int32_t); |