diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libcrypt | |
download | illumos-gate-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libcrypt')
23 files changed, 2803 insertions, 0 deletions
diff --git a/usr/src/lib/libcrypt/Makefile b/usr/src/lib/libcrypt/Makefile new file mode 100644 index 0000000000..bde11f7726 --- /dev/null +++ b/usr/src/lib/libcrypt/Makefile @@ -0,0 +1,81 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# usr/src/lib/libcrypt/Makefile + +include ../Makefile.lib + +SUBDIRS= $(MACH) +$(BUILD64)SUBDIRS += $(MACH64) + +all := TARGET= all +clean := TARGET= clean +clobber := TARGET= clobber +install := TARGET= install +lint := TARGET= lint + +.KEEP_STATE: + +all clean clobber install: spec .WAIT $(SUBDIRS) + +lint: $(SUBDIRS) + +check: $(CHECKHDRS) + +spec $(SUBDIRS): FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +include ../Makefile.targ + +# EXPORT DELETE START +EXPORT_SRC: + $(RM) common/des.c+ common/des_crypt.c+ common/des_soft.c+ \ + common/des_decrypt.c+ common/des_encrypt.c+ \ + Makefile+ + sed -e "/EXPORT DELETE START/,/EXPORT DELETE END/d" < \ + common/des.c > common/des.c+ + $(MV) common/des.c+ common/des.c + sed -e "/EXPORT DELETE START/,/EXPORT DELETE END/d" < \ + common/des_crypt.c > common/des_crypt.c+ + $(MV) common/des_crypt.c+ common/des_crypt.c + sed -e "/EXPORT DELETE START/,/EXPORT DELETE END/d" < \ + common/des_soft.c > common/des_soft.c+ + $(MV) common/des_soft.c+ common/des_soft.c + sed -e "/EXPORT DELETE START/,/EXPORT DELETE END/d" < \ + common/des_encrypt.c > common/des_encrypt.c+ + $(MV) common/des_encrypt.c+ common/des_encrypt.c + sed -e "/EXPORT DELETE START/,/EXPORT DELETE END/d" < \ + common/des_decrypt.c > common/des_decrypt.c+ + $(MV) common/des_decrypt.c+ common/des_decrypt.c + sed -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \ + < Makefile > Makefile+ + $(MV) Makefile+ Makefile + $(CHMOD) 444 Makefile common/des.c common/des_crypt.c \ + common/des_soft.c common/des_encrypt.c common/des_decrypt.c +# EXPORT DELETE END diff --git a/usr/src/lib/libcrypt/Makefile.com b/usr/src/lib/libcrypt/Makefile.com new file mode 100644 index 0000000000..3818bd2cc9 --- /dev/null +++ b/usr/src/lib/libcrypt/Makefile.com @@ -0,0 +1,83 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +LIBRARY= libcrypt.a +VERS= .1 + +OBJECTS= \ + cryptio.o \ + des.o \ + des_crypt.o \ + des_encrypt.o \ + des_decrypt.o \ + des_soft.o + +include ../../Makefile.lib + +SRCDIR= ../common + +LIBS= $(DYNLIB) $(LINTLIB) +SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c) +MAPDIR= ../spec/$(TRANSMACH) +SPECMAPFILE= $(MAPDIR)/mapfile + +$(LINTLIB):= SRCS=$(SRCDIR)/$(LINTSRC) + +CFLAGS += $(CCVERBOSE) +CPPFLAGS += -D_REENTRANT -I../inc -I../../common/inc -I../../libgen/inc +LDLIBS += -lgen -lc + +.KEEP_STATE: + +all: $(LIBS) + +lint: lintcheck + +include ../../Makefile.targ + +$(ROOTLINKS) := INS.liblink = \ + $(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@; \ + cd $(ROOTLIBDIR); \ + $(RM) libcrypt_i.so$(VERS) libcrypt_i.so ;\ + $(RM) libcrypt_d.so$(VERS) libcrypt_d.so ;\ + $(SYMLINK) libcrypt.so$(VERS) libcrypt_i.so$(VERS); \ + $(SYMLINK) libcrypt.so libcrypt_i.so; \ + $(SYMLINK) libcrypt.so$(VERS) libcrypt_d.so$(VERS); \ + $(SYMLINK) libcrypt.so libcrypt_d.so; + +$(ROOTLINKS64) := INS.liblink64 = \ + $(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@; \ + cd $(ROOTLIBDIR64); \ + $(RM) libcrypt_i.so$(VERS) libcrypt_i.so ;\ + $(RM) libcrypt_d.so$(VERS) libcrypt_d.so ;\ + $(SYMLINK) libcrypt.so$(VERS) libcrypt_i.so$(VERS); \ + $(SYMLINK) libcrypt.so libcrypt_i.so; \ + $(SYMLINK) libcrypt.so$(VERS) libcrypt_d.so$(VERS); \ + $(SYMLINK) libcrypt.so libcrypt_d.so; + + diff --git a/usr/src/lib/libcrypt/amd64/Makefile b/usr/src/lib/libcrypt/amd64/Makefile new file mode 100644 index 0000000000..bd2cdcd780 --- /dev/null +++ b/usr/src/lib/libcrypt/amd64/Makefile @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/amd64/Makefile + +include ../Makefile.com +include ../../Makefile.lib.64 + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/lib/libcrypt/common/cryptio.c b/usr/src/lib/libcrypt/common/cryptio.c new file mode 100644 index 0000000000..cc1758d967 --- /dev/null +++ b/usr/src/lib/libcrypt/common/cryptio.c @@ -0,0 +1,206 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak run_setkey = _run_setkey +#pragma weak run_crypt = _run_crypt +#pragma weak crypt_close = _crypt_close +#pragma weak makekey = _makekey + +#include "synonyms.h" +#include "mtlib.h" +#include <stdio.h> +#include <signal.h> +#include <fcntl.h> +#include <errno.h> +#include <thread.h> +#include <sys/types.h> +#include <unistd.h> +#include <strings.h> +#include <crypt.h> +#include "des_soft.h" +#include "lib_gen.h" + +#define READER 0 +#define WRITER 1 +#define KSIZE 8 + +/* Global Variables */ +static char key[KSIZE+1]; +struct header { + long offset; + unsigned int count; +}; + +static mutex_t lock = DEFAULTMUTEX; + +static int cryptopen(); +static int writekey(); + +void _exit(); + +int +run_setkey(int p[2], const char *keyparam) +{ + (void) mutex_lock(&lock); + if (cryptopen(p) == -1) { + (void) mutex_unlock(&lock); + return (-1); + } + (void) strncpy(key, keyparam, KSIZE); + if (*key == 0) { + (void) crypt_close_nolock(p); + (void) mutex_unlock(&lock); + return (0); + } + if (writekey(p, key) == -1) { + (void) mutex_unlock(&lock); + return (-1); + } + (void) mutex_unlock(&lock); + return (1); +} + +static char cmd[] = "exec /usr/bin/crypt -p 2>/dev/null"; +static int +cryptopen(int p[2]) +{ + char c; + + if (__p2open(cmd, p) < 0) + return (-1); + if (read(p[WRITER], &c, 1) != 1) { /* check that crypt is working on */ + /* other end */ + (void) crypt_close(p); /* remove defunct process */ + return (-1); + } + return (1); +} + +static int +writekey(int p[2], char *keyarg) +{ + void (*pstat) (); + pstat = signal(SIGPIPE, SIG_IGN); /* don't want pipe errors to cause */ + /* death */ + if (write(p[READER], keyarg, KSIZE) != KSIZE) { + (void) crypt_close(p); /* remove defunct process */ + (void) signal(SIGPIPE, pstat); + return (-1); + } + (void) signal(SIGPIPE, pstat); + return (1); +} + + +int +run_crypt(long offset, char *buffer, unsigned int count, int p[2]) +{ + struct header header; + void (*pstat) (); + + (void) mutex_lock(&lock); + header.count = count; + header.offset = offset; + pstat = signal(SIGPIPE, SIG_IGN); + if (write(p[READER], (char *)&header, sizeof (header)) + != sizeof (header)) { + (void) crypt_close_nolock(p); + (void) signal(SIGPIPE, pstat); + (void) mutex_unlock(&lock); + return (-1); + } + if (write(p[READER], buffer, count) < count) { + (void) crypt_close_nolock(p); + (void) signal(SIGPIPE, pstat); + (void) mutex_unlock(&lock); + return (-1); + } + if (read(p[WRITER], buffer, count) < count) { + (void) crypt_close_nolock(p); + (void) signal(SIGPIPE, pstat); + (void) mutex_unlock(&lock); + return (-1); + } + (void) signal(SIGPIPE, pstat); + (void) mutex_unlock(&lock); + return (0); +} + +int +makekey(int b[2]) +{ + int i; + long gorp; + char tempbuf[KSIZE], *a, *temp; + + (void) mutex_lock(&lock); + a = key; + temp = tempbuf; + for (i = 0; i < KSIZE; i++) + temp[i] = *a++; + gorp = getuid() + getgid(); + + for (i = 0; i < 4; i++) + temp[i] ^= (char)((gorp>>(8*i))&0377); + + if (cryptopen(b) == -1) { + (void) mutex_unlock(&lock); + return (-1); + } + if (writekey(b, temp) == -1) { + (void) mutex_unlock(&lock); + return (-1); + } + (void) mutex_unlock(&lock); + return (0); +} + +int +crypt_close_nolock(int p[2]) +{ + + if (p[0] == 0 && p[1] == 0 || p[0] < 0 || p[1] < 0) { + return (-1); + } + + return (__p2close(p, NULL, SIGKILL)); +} + +int +crypt_close(int p[2]) +{ + (void) mutex_lock(&lock); + (void) crypt_close_nolock(p); + (void) mutex_unlock(&lock); + return (0); +} diff --git a/usr/src/lib/libcrypt/common/des.c b/usr/src/lib/libcrypt/common/des.c new file mode 100644 index 0000000000..61fcd3c407 --- /dev/null +++ b/usr/src/lib/libcrypt/common/des.c @@ -0,0 +1,186 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" +/*LINTLIBRARY*/ + +/* + * DES encryption library routines + */ + +#include <sys/types.h> + +#include <rpc/des_crypt.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stropts.h> +#ifdef sun +#include <sys/ioctl.h> +#include <sys/des.h> +#ifdef _KERNEL +#include <sys/conf.h> +#define getdesfd() (cdevsw[11].d_open(0, 0) ? -1 : 0) +#define ioctl(a, b, c) (cdevsw[11].d_ioctl(0, b, c, 0) ? -1 : 0) +#ifndef CRYPT +#define __des_crypt(a, b, c) 0 +#endif +#else +#define getdesfd() (open("/dev/des", 0, 0)) +#endif +#else +#include <des/des.h> +#endif + +#include "des_soft.h" + +/* + * To see if chip is installed + */ +#define UNOPENED (-2) + +/* + * Copy 8 bytes + */ +#define COPY8(src, dst) { \ + char *a = (char *) dst; \ + char *b = (char *) src; \ + *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ + *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ +} + +/* + * Copy multiple of 8 bytes + */ +#define DESCOPY(src, dst, len) { \ + char *a = (char *) dst; \ + char *b = (char *) src; \ + int i; \ + for (i = (int) len; i > 0; i -= 8) { \ + *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ + *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ + } \ +} +static int common_crypt(char *, char *, unsigned, unsigned, struct desparams *); + +/* + * CBC mode encryption + */ +int +cbc_crypt(char *key, char *buf, size_t len, unsigned int mode, char *ivec) +{ + int err = 0; + +/* EXPORT DELETE START */ + struct desparams dp; + + dp.des_mode = CBC; + COPY8(ivec, dp.des_ivec); + err = common_crypt(key, buf, len, mode, &dp); + COPY8(dp.des_ivec, ivec); +/* EXPORT DELETE END */ + return (err); +} + + +/* + * ECB mode encryption + */ +int +ecb_crypt(char *key, char *buf, size_t len, unsigned int mode) +{ + int ret = 0; + +/* EXPORT DELETE START */ + struct desparams dp; + + dp.des_mode = ECB; + ret = common_crypt(key, buf, len, mode, &dp); +/* EXPORT DELETE END */ + return (ret); +} + + +/* EXPORT DELETE START */ +/* + * Common code to cbc_crypt() & ecb_crypt() + */ +static int +common_crypt(char *key, char *buf, unsigned len, unsigned mode, struct desparams *desp) +{ + int desdev; + int res; + int g_desfd = UNOPENED; + + if ((len % 8) != 0 || len > DES_MAXDATA) { + return (DESERR_BADPARAM); + } + desp->des_dir = + ((mode & DES_DIRMASK) == DES_ENCRYPT) ? ENCRYPT : DECRYPT; + + desdev = mode & DES_DEVMASK; + COPY8(key, desp->des_key); +#ifdef sun + if (desdev == DES_HW) { + if (g_desfd < 0) { + if (g_desfd == -1 || (g_desfd = getdesfd()) < 0) { + goto software; /* no hardware device */ + } + } + + /* + * hardware + */ + desp->des_len = len; + if (len <= DES_QUICKLEN) { + DESCOPY(buf, desp->des_data, len); + res = ioctl(g_desfd, (int)DESIOCQUICK, (char *) desp); + DESCOPY(desp->des_data, buf, len); + } else { + desp->des_buf = (u_char *) buf; + res = ioctl(g_desfd, (int)DESIOCBLOCK, (char *) desp); + } + return (res == 0 ? DESERR_NONE : DESERR_HWERROR); + } +software: +#endif + /* + * software + */ + if (!__des_crypt(buf, len, desp)) { + return (DESERR_HWERROR); + } + return (desdev == DES_SW ? DESERR_NONE : DESERR_NOHWDEVICE); +} +/* EXPORT DELETE END */ diff --git a/usr/src/lib/libcrypt/common/des_crypt.c b/usr/src/lib/libcrypt/common/des_crypt.c new file mode 100644 index 0000000000..b7fd085065 --- /dev/null +++ b/usr/src/lib/libcrypt/common/des_crypt.c @@ -0,0 +1,422 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" +/*LINTLIBRARY*/ + +#pragma weak des_crypt = _des_crypt +#pragma weak des_encrypt = _des_encrypt +#pragma weak des_setkey = _des_setkey + +#include "synonyms.h" +#include "mtlib.h" +#include <sys/types.h> +#include <crypt.h> +#include "des_soft.h" + +#include <stdlib.h> +#include <thread.h> +#include <synch.h> +#include <sys/types.h> + +/* EXPORT DELETE START */ +/* + * This program implements the + * Proposed Federal Information Processing + * Data Encryption Standard. + * See Federal Register, March 17, 1975 (40FR12134) + */ + +/* + * Initial permutation, + */ +static char IP[] = { + 58, 50, 42, 34, 26, 18, 10, 2, + 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, + 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, + 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, + 63, 55, 47, 39, 31, 23, 15, 7, +}; + +/* + * Final permutation, FP = IP^(-1) + */ +static char FP[] = { + 40, 8, 48, 16, 56, 24, 64, 32, + 39, 7, 47, 15, 55, 23, 63, 31, + 38, 6, 46, 14, 54, 22, 62, 30, + 37, 5, 45, 13, 53, 21, 61, 29, + 36, 4, 44, 12, 52, 20, 60, 28, + 35, 3, 43, 11, 51, 19, 59, 27, + 34, 2, 42, 10, 50, 18, 58, 26, + 33, 1, 41, 9, 49, 17, 57, 25, +}; + +/* + * Permuted-choice 1 from the key bits + * to yield C and D. + * Note that bits 8, 16... are left out: + * They are intended for a parity check. + */ +static char PC1_C[] = { + 57, 49, 41, 33, 25, 17, 9, + 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, + 19, 11, 3, 60, 52, 44, 36, +}; + +static char PC1_D[] = { + 63, 55, 47, 39, 31, 23, 15, + 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, + 21, 13, 5, 28, 20, 12, 4, +}; + +/* + * Sequence of shifts used for the key schedule. + */ +static char shifts[] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, }; + +/* + * Permuted-choice 2, to pick out the bits from + * the CD array that generate the key schedule. + */ +static char PC2_C[] = { + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, +}; + +static char PC2_D[] = { + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32, +}; + +/* + * The C and D arrays used to calculate the key schedule. + */ + +static char C[28]; +static char D[28]; +/* + * The key schedule. + * Generated from the key. + */ +static char KS[16][48]; + +/* + * The E bit-selection table. + */ +static char E[48]; +static char e2[] = { + 32, 1, 2, 3, 4, 5, + 4, 5, 6, 7, 8, 9, + 8, 9, 10, 11, 12, 13, + 12, 13, 14, 15, 16, 17, + 16, 17, 18, 19, 20, 21, + 20, 21, 22, 23, 24, 25, + 24, 25, 26, 27, 28, 29, + 28, 29, 30, 31, 32, 1, +}; + +/* + * Set up the key schedule from the key. + */ + +static mutex_t lock = DEFAULTMUTEX; + +/* EXPORT DELETE END */ + + +static void +des_setkey_nolock(const char *key) +{ +/* EXPORT DELETE START */ + int i, j, k; + char t; + + /* + * First, generate C and D by permuting + * the key. The low order bit of each + * 8-bit char is not used, so C and D are only 28 + * bits apiece. + */ + for (i = 0; i < 28; i++) { + C[i] = key[PC1_C[i]-1]; + D[i] = key[PC1_D[i]-1]; + } + /* + * To generate Ki, rotate C and D according + * to schedule and pick up a permutation + * using PC2. + */ + for (i = 0; i < 16; i++) { + /* + * rotate. + */ + for (k = 0; k < shifts[i]; k++) { + t = C[0]; + for (j = 0; j < 28-1; j++) + C[j] = C[j+1]; + C[27] = (char)t; + t = D[0]; + for (j = 0; j < 28-1; j++) + D[j] = D[j+1]; + D[27] = (char)t; + } + /* + * get Ki. Note C and D are concatenated. + */ + for (j = 0; j < 24; j++) { + KS[i][j] = C[PC2_C[j]-1]; + KS[i][j+24] = D[PC2_D[j]-28-1]; + } + } + + for (i = 0; i < 48; i++) + E[i] = e2[i]; +/* EXPORT DELETE END */ +} + +void +des_setkey(const char *key) +{ +/* EXPORT DELETE START */ + (void) mutex_lock(&lock); + des_setkey_nolock(key); + (void) mutex_unlock(&lock); +/* EXPORT DELETE END */ +} + +/* EXPORT DELETE START */ +/* + * The 8 selection functions. + * For some reason, they give a 0-origin + * index, unlike everything else. + */ +static char S[8][64] = { + 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, + 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, + 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, + 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, + + 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, + 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, + 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, + 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, + + 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, + 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, + 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, + + 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, + 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, + 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, + 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, + + 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, + 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, + 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, + 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, + + 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, + 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, + 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, + 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, + + 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, + 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, + 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, + 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, + + 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, + 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, + 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, + 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11, +}; + +/* + * P is a permutation on the selected combination + * of the current L and key. + */ +static char P[] = { + 16, 7, 20, 21, + 29, 12, 28, 17, + 1, 15, 23, 26, + 5, 18, 31, 10, + 2, 8, 24, 14, + 32, 27, 3, 9, + 19, 13, 30, 6, + 22, 11, 4, 25, +}; + +/* + * The current block, divided into 2 halves. + */ +static char L[64]; +static char tempL[32]; +static char f[32]; + +/* + * The combination of the key and the input, before selection. + */ +static char preS[48]; + +/* + * The payoff: encrypt a block. + */ +/* EXPORT DELETE END */ + +static void +des_encrypt_nolock(char *block, int edflag) +{ +/* EXPORT DELETE START */ + + if (edflag) + (void) des_decrypt1(block, L, IP, &L[32], + preS, E, KS, S, f, tempL, P, FP); + else + (void) des_encrypt1(block, L, IP, &L[32], + preS, E, KS, S, f, tempL, P, FP); + +/* EXPORT DELETE END */ +} + +void +des_encrypt(char *block, int edflag) +{ +/* EXPORT DELETE START */ + (void) mutex_lock(&lock); + des_encrypt_nolock(block, edflag); + (void) mutex_unlock(&lock); +/* EXPORT DELETE END */ +} + + + +#define IOBUF_SIZE 16 + +static char * +_get_iobuf(thread_key_t *key, unsigned size) +{ + char *iobuf = NULL; + + if (thr_getspecific(*key, (void **)&iobuf) != 0) { + if (_thr_keycreate(key, free) != 0) { + return (NULL); + } + } + + if (!iobuf) { + if (_thr_setspecific(*key, (void *)(iobuf = malloc(size))) + != 0) { + if (iobuf) + (void) free(iobuf); + return (NULL); + } + } + return (iobuf); +} + +char * +des_crypt(const char *pw, const char *salt) +{ +/* EXPORT DELETE START */ + int i, j; + char c, temp; + static thread_key_t key = 0; + char block[66], *iobuf = _get_iobuf(&key, IOBUF_SIZE); + + (void) mutex_lock(&lock); + for (i = 0; i < 66; i++) + block[i] = 0; + for (i = 0; (c = *pw) && (i < 64); pw++) { + for (j = 0; j < 7; j++, i++) + block[i] = (c>>(6-j)) & 01; + i++; + } + + des_setkey_nolock(block); + + for (i = 0; i < 66; i++) + block[i] = 0; + + for (i = 0; i < 2; i++) { + c = *salt++; + iobuf[i] = (char)c; + if (c > 'Z') + c -= 6; + if (c > '9') + c -= 7; + c -= '.'; + for (j = 0; j < 6; j++) { + if ((c>>j) & 01) { + temp = E[6*i+j]; + E[6*i+j] = E[6*i+j+24]; + E[6*i+j+24] = (char)temp; + } + } + } + + for (i = 0; i < 25; i++) + (void) des_encrypt_nolock(block, 0); + + for (i = 0; i < 11; i++) { + c = 0; + for (j = 0; j < 6; j++) { + c <<= 1; + c |= block[6*i+j]; + } + c += '.'; + if (c > '9') + c += 7; + if (c > 'Z') + c += 6; + iobuf[i+2] = (char)c; + } + iobuf[i+2] = 0; + if (iobuf[1] == 0) + iobuf[1] = iobuf[0]; + (void) mutex_unlock(&lock); + return (iobuf); +#if 0 +/* EXPORT DELETE END */ + return (0); +/* EXPORT DELETE START */ +#endif +/* EXPORT DELETE END */ +} diff --git a/usr/src/lib/libcrypt/common/des_decrypt.c b/usr/src/lib/libcrypt/common/des_decrypt.c new file mode 100644 index 0000000000..ac8fb8291f --- /dev/null +++ b/usr/src/lib/libcrypt/common/des_decrypt.c @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" +/*LINTLIBRARY*/ + +#include <sys/types.h> + +void +_des_decrypt1(char *block, char *L, char *IP, char *R, char *preS, char *E, char KS[][48], char S[][64], char *f, char *tempL, char *P, char *FP) +{ +/* EXPORT DELETE START */ + int i, ii; + int t, j, k; + char t2; + + /* + * First, permute the bits in the input + */ + for (j = 0; j < 64; j++) + L[j] = block[IP[j]-1]; + /* + * Perform a decryption operation 16 times. + */ + for (ii = 0; ii < 16; ii++) { + i = 15-ii; + /* + * Save the R array, + * which will be the new L. + */ + for (j = 0; j < 32; j++) + tempL[j] = R[j]; + /* + * Expand R to 48 bits using the E selector; + * exclusive-or with the current key bits. + */ + for (j = 0; j < 48; j++) + preS[j] = R[E[j]-1] ^ KS[i][j]; + /* + * The pre-select bits are now considered + * in 8 groups of 6 bits each. + * The 8 selection functions map these + * 6-bit quantities into 4-bit quantities + * and the results permuted + * to make an f(R, K). + * The indexing into the selection functions + * is peculiar; it could be simplified by + * rewriting the tables. + */ + for (j = 0; j < 8; j++) { + t = 6*j; + k = S[j][(preS[t+0]<<5)+ + (preS[t+1]<<3)+ + (preS[t+2]<<2)+ + (preS[t+3]<<1)+ + (preS[t+4]<<0)+ + (preS[t+5]<<4)]; + t = 4*j; + f[t+0] = (k>>3)&01; + f[t+1] = (k>>2)&01; + f[t+2] = (k>>1)&01; + f[t+3] = (k>>0)&01; + } + /* + * The new R is L ^ f(R, K). + * The f here has to be permuted first, though. + */ + for (j = 0; j < 32; j++) + R[j] = L[j] ^ f[P[j]-1]; + /* + * Finally, the new L (the original R) + * is copied back. + */ + for (j = 0; j < 32; j++) + L[j] = tempL[j]; + } + /* + * The output L and R are reversed. + */ + for (j = 0; j < 32; j++) { + t2 = L[j]; + L[j] = R[j]; + R[j] = t2; + } + /* + * The final output + * gets the inverse permutation of the very original. + */ + for (j = 0; j < 64; j++) + block[j] = L[FP[j]-1]; +/* EXPORT DELETE END */ +} diff --git a/usr/src/lib/libcrypt/common/des_encrypt.c b/usr/src/lib/libcrypt/common/des_encrypt.c new file mode 100644 index 0000000000..ff5b88cb3b --- /dev/null +++ b/usr/src/lib/libcrypt/common/des_encrypt.c @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" +/*LINTLIBRARY*/ + +#pragma weak des_encrypt1 = _des_encrypt1 + +#include "synonyms.h" +#include <sys/types.h> + +void +des_encrypt1(char *block, char *L, char *IP, char *R, char *preS, char *E, char KS[][48], char S[][64], char *f, char *tempL, char *P, char *FP) +{ +/* EXPORT DELETE START */ + int i; + int t, j, k; + char t2; + + /* + * First, permute the bits in the input + */ + for (j = 0; j < 64; j++) + L[j] = block[IP[j]-1]; + /* + * Perform an encryption operation 16 times. + */ + for (i = 0; i < 16; i++) { + /* + * Save the R array, + * which will be the new L. + */ + for (j = 0; j < 32; j++) + tempL[j] = R[j]; + /* + * Expand R to 48 bits using the E selector; + * exclusive-or with the current key bits. + */ + for (j = 0; j < 48; j++) + preS[j] = R[E[j]-1] ^ KS[i][j]; + /* + * The pre-select bits are now considered + * in 8 groups of 6 bits each. + * The 8 selection functions map these + * 6-bit quantities into 4-bit quantities + * and the results permuted + * to make an f(R, K). + * The indexing into the selection functions + * is peculiar; it could be simplified by + * rewriting the tables. + */ + for (j = 0; j < 8; j++) { + t = 6*j; + k = S[j][(preS[t+0]<<5)+ + (preS[t+1]<<3)+ + (preS[t+2]<<2)+ + (preS[t+3]<<1)+ + (preS[t+4]<<0)+ + (preS[t+5]<<4)]; + t = 4*j; + f[t+0] = (k>>3)&01; + f[t+1] = (k>>2)&01; + f[t+2] = (k>>1)&01; + f[t+3] = (k>>0)&01; + } + /* + * The new R is L ^ f(R, K). + * The f here has to be permuted first, though. + */ + for (j = 0; j < 32; j++) + R[j] = L[j] ^ f[P[j]-1]; + /* + * Finally, the new L (the original R) + * is copied back. + */ + for (j = 0; j < 32; j++) + L[j] = tempL[j]; + } + /* + * The output L and R are reversed. + */ + for (j = 0; j < 32; j++) { + t2 = L[j]; + L[j] = R[j]; + R[j] = t2; + } + /* + * The final output + * gets the inverse permutation of the very original. + */ + for (j = 0; j < 64; j++) + block[j] = L[FP[j]-1]; +/* EXPORT DELETE END */ +} diff --git a/usr/src/lib/libcrypt/common/des_soft.c b/usr/src/lib/libcrypt/common/des_soft.c new file mode 100644 index 0000000000..b560c2dd65 --- /dev/null +++ b/usr/src/lib/libcrypt/common/des_soft.c @@ -0,0 +1,446 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" +/*LINTLIBRARY*/ + +/* + * Warning! Things are arranged very carefully in this file to + * allow read-only data to be moved to the text segment. The + * various DES tables must appear before any function definitions + * (this is arranged by including them immediately below) and partab + * must also appear before and function definitions + * This arrangement allows all data up through the first text to + * be moved to text. + */ + +#ifndef _KERNEL +#define CRYPT /* cannot configure out of user-level code */ +#endif + +#include "synonyms.h" +#ifdef CRYPT +#include <sys/types.h> +#include <des/softdes.h> +#include <des/desdata.h> + +#ifdef sun +#include <sys/ioctl.h> +#include <sys/des.h> +#else +#include <des/des.h> +#endif + +#include "des_soft.h" + +/* + * Fast (?) software implementation of DES + * Has been seen going at 2000 bytes/sec on a Sun-2 + * Works on a VAX too. + * Won't work without 8 bit chars and 32 bit longs + */ + +#define btst(k, b) (k[b >> 3] & (0x80 >> (b & 07))) +#define BIT28 (1<<28) + + +#endif /* def CRYPT */ + +static void des_setkey(u_char [8], struct deskeydata *, unsigned); +static void des_encrypt(u_char *, struct deskeydata *); + +#ifndef _KERNEL +/* + * Table giving odd parity in the low bit for ASCII characters + */ +static char partab[128] = { + 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, + 0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e, + 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16, + 0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f, + 0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26, + 0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f, + 0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37, + 0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e, + 0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46, + 0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f, + 0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57, + 0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e, + 0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67, + 0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e, + 0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76, + 0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f, +}; + + + +/* + * Add odd parity to low bit of 8 byte key + */ +void +des_setparity(char *p) +{ + int i; + + for (i = 0; i < 8; i++) { + *p = partab[*p & 0x7f]; + p++; + } +} +#endif /* def _KERNEL */ + +#ifdef CRYPT +/* + * Software encrypt or decrypt a block of data (multiple of 8 bytes) + * Do the CBC ourselves if needed. + */ +int +__des_crypt(char *buf, unsigned int len, struct desparams *desp) +{ +/* EXPORT DELETE START */ + short i; + unsigned mode; + unsigned dir; + char nextiv[8]; + struct deskeydata softkey; + + mode = (unsigned) desp->des_mode; + dir = (unsigned) desp->des_dir; + des_setkey(desp->des_key, &softkey, dir); + while (len != 0) { + switch (mode) { + case CBC: + switch (dir) { + case ENCRYPT: + for (i = 0; i < 8; i++) + buf[i] ^= desp->des_ivec[i]; + des_encrypt((u_char *)buf, &softkey); + for (i = 0; i < 8; i++) + desp->des_ivec[i] = buf[i]; + break; + case DECRYPT: + for (i = 0; i < 8; i++) + nextiv[i] = buf[i]; + des_encrypt((u_char *)buf, &softkey); + for (i = 0; i < 8; i++) { + buf[i] ^= desp->des_ivec[i]; + desp->des_ivec[i] = nextiv[i]; + } + break; + } + break; + case ECB: + des_encrypt((u_char *)buf, &softkey); + break; + } + buf += 8; + len -= 8; + } +/* EXPORT DELETE END */ + return (1); +} + + +/* + * Set the key and direction for an encryption operation + * We build the 16 key entries here + */ +static void +des_setkey(u_char userkey[8], struct deskeydata *kd, unsigned int dir) +{ +/* EXPORT DELETE START */ + long C, D; + short i; + + /* + * First, generate C and D by permuting + * the key. The low order bit of each + * 8-bit char is not used, so C and D are only 28 + * bits apiece. + */ + { + short bit; + const short *pcc = PC1_C, *pcd = PC1_D; + + C = D = 0; + for (i = 0; i < 28; i++) { + C <<= 1; + D <<= 1; + bit = *pcc++; + if (btst(userkey, bit)) + C |= 1; + bit = *pcd++; + if (btst(userkey, bit)) + D |= 1; + } + } + /* + * To generate Ki, rotate C and D according + * to schedule and pick up a permutation + * using PC2. + */ + for (i = 0; i < 16; i++) { + chunk_t *c; + short j, k, bit; + long bbit; + + /* + * Do the "left shift" (rotate) + * We know we always rotate by either 1 or 2 bits + * the shifts table tells us if its 2 + */ + C <<= 1; + if (C & BIT28) + C |= 1; + D <<= 1; + if (D & BIT28) + D |= 1; + if (shifts[i]) { + C <<= 1; + if (C & BIT28) + C |= 1; + D <<= 1; + if (D & BIT28) + D |= 1; + } + /* + * get Ki. Note C and D are concatenated. + */ + bit = 0; + switch (dir) { + case ENCRYPT: + c = &kd->keyval[i]; break; + case DECRYPT: + c = &kd->keyval[15 - i]; break; + } + c->long0 = 0; + c->long1 = 0; + bbit = (1 << 5) << 24; + for (j = 0; j < 4; j++) { + for (k = 0; k < 6; k++) { + if (C & (BIT28 >> PC2_C[bit])) + c->long0 |= bbit >> k; + if (D & (BIT28 >> PC2_D[bit])) + c->long1 |= bbit >> k; + bit++; + } + bbit >>= 8; + } + + } +/* EXPORT DELETE END */ + return; +} + + + +/* + * Do an encryption operation + * Much pain is taken (with preprocessor) to avoid loops so the compiler + * can do address arithmetic instead of doing it at runtime. + * Note that the byte-to-chunk conversion is necessary to guarantee + * processor byte-order independence. + */ +static void +des_encrypt(u_char *data, struct deskeydata *kd) +{ +/* EXPORT DELETE START */ + chunk_t work1, work2; + + /* + * Initial permutation + * and byte to chunk conversion + */ + { + const uint32_t *lp; + uint32_t l0, l1, w; + short i, pbit; + + work1.byte0 = data[0]; + work1.byte1 = data[1]; + work1.byte2 = data[2]; + work1.byte3 = data[3]; + work1.byte4 = data[4]; + work1.byte5 = data[5]; + work1.byte6 = data[6]; + work1.byte7 = data[7]; + l0 = l1 = 0; + w = work1.long0; + for (lp = &longtab[0], i = 0; i < 32; i++) { + if (w & *lp++) { + pbit = IPtab[i]; + if (pbit < 32) + l0 |= longtab[pbit]; + else + l1 |= longtab[pbit-32]; + } + } + w = work1.long1; + for (lp = &longtab[0], i = 32; i < 64; i++) { + if (w & *lp++) { + pbit = IPtab[i]; + if (pbit < 32) + l0 |= longtab[pbit]; + else + l1 |= longtab[pbit-32]; + } + } + work2.long0 = l0; + work2.long1 = l1; + } + +/* + * Expand 8 bits of 32 bit R to 48 bit R + */ +#define do_R_to_ER(op, b) { \ + const struct R_to_ER *p = &R_to_ER_tab[b][R.byte##b]; \ + e0 op p->l0; \ + e1 op p->l1; \ +} + +/* + * Inner part of the algorithm: + * Expand R from 32 to 48 bits; xor key value; + * apply S boxes; permute 32 bits of output + */ +#define do_F(iter, inR, outR) { \ + chunk_t R, ER; \ + uint32_t e0, e1; \ + R.long0 = inR; \ + do_R_to_ER(=, 0); \ + do_R_to_ER(|=, 1); \ + do_R_to_ER(|=, 2); \ + do_R_to_ER(|=, 3); \ + ER.long0 = e0 ^ kd->keyval[iter].long0; \ + ER.long1 = e1 ^ kd->keyval[iter].long1; \ + R.long0 = \ + S_tab[0][ER.byte0] + \ + S_tab[1][ER.byte1] + \ + S_tab[2][ER.byte2] + \ + S_tab[3][ER.byte3] + \ + S_tab[4][ER.byte4] + \ + S_tab[5][ER.byte5] + \ + S_tab[6][ER.byte6] + \ + S_tab[7][ER.byte7]; \ + outR = \ + P_tab[0][R.byte0] + \ + P_tab[1][R.byte1] + \ + P_tab[2][R.byte2] + \ + P_tab[3][R.byte3]; \ +} + +/* + * Do a cipher step + * Apply inner part; do xor and exchange of 32 bit parts + */ +#define cipher(iter, inR, inL, outR, outL) { \ + do_F(iter, inR, outR); \ + outR ^= inL; \ + outL = inR; \ +} + + /* + * Apply the 16 ciphering steps + */ + { + uint32_t r0, l0, r1, l1; + + l0 = work2.long0; + r0 = work2.long1; + cipher(0, r0, l0, r1, l1); + cipher(1, r1, l1, r0, l0); + cipher(2, r0, l0, r1, l1); + cipher(3, r1, l1, r0, l0); + cipher(4, r0, l0, r1, l1); + cipher(5, r1, l1, r0, l0); + cipher(6, r0, l0, r1, l1); + cipher(7, r1, l1, r0, l0); + cipher(8, r0, l0, r1, l1); + cipher(9, r1, l1, r0, l0); + cipher(10, r0, l0, r1, l1); + cipher(11, r1, l1, r0, l0); + cipher(12, r0, l0, r1, l1); + cipher(13, r1, l1, r0, l0); + cipher(14, r0, l0, r1, l1); + cipher(15, r1, l1, r0, l0); + work1.long0 = r0; + work1.long1 = l0; + } + + /* + * Final permutation + * and chunk to byte conversion + */ + { + const uint32_t *lp; + uint32_t l0, l1, w; + short i, pbit; + + l0 = l1 = 0; + w = work1.long0; + for (lp = &longtab[0], i = 0; i < 32; i++) { + if (w & *lp++) { + pbit = FPtab[i]; + if (pbit < 32) + l0 |= longtab[pbit]; + else + l1 |= longtab[pbit-32]; + } + } + w = work1.long1; + for (lp = &longtab[0], i = 32; i < 64; i++) { + if (w & *lp++) { + pbit = FPtab[i]; + if (pbit < 32) + l0 |= longtab[pbit]; + else + l1 |= longtab[pbit-32]; + } + } + work2.long0 = l0; + work2.long1 = l1; + } + data[0] = work2.byte0; + data[1] = work2.byte1; + data[2] = work2.byte2; + data[3] = work2.byte3; + data[4] = work2.byte4; + data[5] = work2.byte5; + data[6] = work2.byte6; + data[7] = work2.byte7; + +/* EXPORT DELETE END */ + return; +} +#endif /* def CRYPT */ diff --git a/usr/src/lib/libcrypt/common/llib-lcrypt b/usr/src/lib/libcrypt/common/llib-lcrypt new file mode 100644 index 0000000000..5063b0a32e --- /dev/null +++ b/usr/src/lib/libcrypt/common/llib-lcrypt @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* LINTLIBRARY */ +/* PROTOLIB1 */ + +/* + * Copyright (c) 1997, 2000 by Sun Microsystems, Inc. + * All rights reserved. + */ +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <sys/types.h> +#include <des/softdes.h> +#include <des/desdata.h> +#include <sys/des.h> + +/* + * usr/src/lib/libcrypt + */ + +/* crypt.c */ +void setkey(const char *key); +void encrypt(char *block, int edflag); +char *crypt(const char *pw, const char *salt); + +/* cryptio.c */ +int _run_setkey(int p[2], const char *keyparam); +int run_setkey(int p[2], const char *keyparam); +int _run_crypt(long offset, char *buffer, unsigned int count, int p[2]); +int run_crypt(long offset, char *buffer, unsigned int count, int p[2]); +int _makekey(int b[2]); +int makekey(int b[2]); +int crypt_close_nolock(int p[2]); +int _crypt_close(int p[2]); +int crypt_close(int p[2]); + +/* des.c */ +int cbc_crypt(char *key, char *buf, size_t len, unsigned int mode, char *ivec); +int ecb_crypt(char *key, char *buf, size_t len, unsigned int mode); + +/* des_crypt.c */ +void _des_setkey(const char *key); +void des_setkey(const char *key); +void _des_encrypt(char *block, int edflag); +void des_encrypt(char *block, int edflag); +char *des_crypt(const char *pw, const char *salt); + +/* des_decrypt.c */ +void _des_decrypt1(char *block, char *L, char *IP, char *R, char *preS, + char *E, char KS[][48], char S[][64], char *f, + char *tempL, char *P, char *FP); + +/* des_encrypt.c */ +void des_encrypt1(char *block, char *L, char *IP, char *R, char *preS, + char *E, char KS[][48], char S[][64], char *f, + char *tempL, char *P, char *FP); +void _des_encrypt1(char *block, char *L, char *IP, char *R, char *preS, + char *E, char KS[][48], char S[][64], char *f, + char *tempL, char *P, char *FP); + +/* des_soft.c */ +void des_setparity(char *p); +int __des_crypt(char *buf, unsigned len, struct desparams *desp); diff --git a/usr/src/lib/libcrypt/i386/Makefile b/usr/src/lib/libcrypt/i386/Makefile new file mode 100644 index 0000000000..d4def41822 --- /dev/null +++ b/usr/src/lib/libcrypt/i386/Makefile @@ -0,0 +1,32 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/ie86/Makefile + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libcrypt/inc/des_soft.h b/usr/src/lib/libcrypt/inc/des_soft.h new file mode 100644 index 0000000000..85a7a8d2dc --- /dev/null +++ b/usr/src/lib/libcrypt/inc/des_soft.h @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997,2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _DES_SOFT_H +#define _DES_SOFT_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/des.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern int __des_crypt(char *, unsigned int, struct desparams *); +extern int crypt_close_nolock(int p[2]); +extern void des_encrypt1(); +extern void des_decrypt1(); + +#ifdef __cplusplus +} +#endif + +#endif /* _DES_SOFT_H */ diff --git a/usr/src/lib/libcrypt/inc/synonyms.h b/usr/src/lib/libcrypt/inc/synonyms.h new file mode 100644 index 0000000000..8eb72192a7 --- /dev/null +++ b/usr/src/lib/libcrypt/inc/synonyms.h @@ -0,0 +1,451 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBCRYPT_SYNONYMS_H +#define _LIBCRYPT_SYNONYMS_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__STDC__) + +/* external data */ +#define altzone _altzone +#define daylight _daylight +#define lone _lone +#define lten _lten +#define lzero _lzero +#define timezone _timezone +#define tzname _tzname + +/* functions */ +#define Msgdb _Msgdb +#define a64l _a64l +#define access _access +#define acct _acct +#define addseverity _addseverity +#define adjtime _adjtime +#define alarm _alarm +#define ascftime _ascftime +#define brk _brk +#define brkbase _brkbase +#define cat_init _cat_init +#define cat_malloc_init _cat_malloc_init +#define cat_name _cat_name +#define catclose _catclose +#define catgets _catgets +#define catopen _catopen +#define cfgetispeed _cfgetispeed +#define cfgetospeed _cfgetospeed +#define cfree _cfree +#define cfsetispeed _cfsetispeed +#define cfsetospeed _cfsetospeed +#define cftime _cftime +#define chdir _chdir +#define chmod _chmod +#define chown _chown +#define chroot _chroot +#define close _close +#define closedir _closedir +#define closelog _closelog +#define countbase _countbase +#define creat _creat +#define crypt _crypt +#define crypt_close _crypt_close +#define ctermid _ctermid +#define cuserid _cuserid +#define des_crypt _des_crypt +#define des_decrypt1 _des_decrypt1 +#define des_encrypt _des_encrypt +#define des_encrypt1 _des_encrypt1 +#define des_setkey _des_setkey +#define dial _dial +#define drand48 _drand48 +#define dup _dup +#define dup2 _dup2 +#define ecvt _ecvt +#define edata _edata +#define encrypt _encrypt +#define end _end +#define endgrent _endgrent +#define endpwent _endpwent +#define endspent _endspent +#define endutent _endutent +#define endutxent _endutxent +#define environ _environ +#define erand48 _erand48 +#define etext _etext +#define ev_traptousr _ev_traptousr +#define ev_usrtrapret _ev_usrtrapret +#define evsys _evsys +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execv _execv +#define execve _execve +#define execvp _execvp +#define exportfs _exportfs +#define fattach _fattach +#define fchdir _fchdir +#define fchmod _fchmod +#define fchown _fchown +#define fcntl _fcntl +#define fcvt _fcvt +#define fdetach _fdetach +#define fdopen _fdopen +#define ffs _ffs +#define fgetgrent _fgetgrent +#define fgetpwent _fgetpwent +#define fgetspent _fgetspent +#define finite _finite +#define fmount _fmount +#define fmtmsg _fmtmsg +#define fork _fork +#define fpathconf _fpathconf +#define fpclass _fpclass +#define fpgetmask _fpgetmask +#define fpgetround _fpgetround +#define fpgetsticky _fpgetsticky +#define fpsetmask _fpsetmask +#define fpsetround _fpsetround +#define fpsetsticky _fpsetsticky +#define fptrap _fptrap +#define fstat _fstat +#define fstatvfs _fstatvfs +#define fsync _fsync +#define ftok _ftok +#define ftruncate _ftruncate +#define ftw _ftw +#define funmount _funmount +#define fxstat _fxstat +#define gcvt _gcvt +#define getcontext _getcontext +#define getcwd _getcwd +#define getdents _getdents +#define getegid _getegid +#define geteuid _geteuid +#define getgid _getgid +#define getgrent _getgrent +#define getgrgid _getgrgid +#define getgrnam _getgrnam +#define getgroups _getgroups +#define gethz _gethz +#define getitimer _getitimer +#define getlogin _getlogin +#define getmntany _getmntany +#define getmntent _getmntent +#define getmsg _getmsg +#define getopt _getopt +#define getpagesize _getpagesize +#define getpass _getpass +#define getpgid _getpgid +#define getpgrp _getpgrp +#define getpid _getpid +#define getpmsg _getpmsg +#define getppid _getppid +#define getpw _getpw +#define getpwent _getpwent +#define getpwnam _getpwnam +#define getpwuid _getpwuid +#define getrlimit _getrlimit +#define getsid _getsid +#define getspent _getspent +#define getspnam _getspnam +#define getsubopt _getsubopt +#define gettimeofday _gettimeofday +#define gettxt _gettxt +#define getuid _getuid +#define getutent _getutent +#define getutid _getutid +#define getutline _getutline +#define getutxent _getutxent +#define getutxid _getutxid +#define getutxline _getutxline +#define getvfsany _getvfsany +#define getvfsent _getvfsent +#define getvfsfile _getvfsfile +#define getvfsspec _getvfsspec +#define getw _getw +#define gsignal _gsignal +#define gtty _gtty +#define hcreate _hcreate +#define hdestroy _hdestroy +#define hrtalarm _hrtalarm +#define hrtascftime _hrtascftime +#define hrtasctime _hrtasctime +#define hrtcancel _hrtcancel +#define hrtcftime _hrtcftime +#define hrtcntl _hrtcntl +#define hrtctime _hrtctime +#define hrtnewres _hrtnewres +#define hrtsleep _hrtsleep +#define hrtstrftime _hrtstrftime +#define hsearch _hsearch +#define id2str _id2str +#define initgroups _initgroups +#define insque _insque +#define ioctl _ioctl +#define isastream _isastream +#define isatty _isatty +#define jrand48 _jrand48 +#define kill _kill +#define l3tol _l3tol +#define l64a _l64a +#define ladd _ladd +#define lchown _lchown +#define lckpwdf _lckpwdf +#define lcong48 _lcong48 +#define ldivide _ldivide +#define lexp10 _lexp10 +#define lfind _lfind +#define link _link +#define llog10 _llog10 +#define lmul _lmul +#define lockf _lockf +#define lrand48 _lrand48 +#define lsearch _lsearch +#define lseek _lseek +#define lshiftl _lshiftl +#define lsign _lsign +#define lstat _lstat +#define lsub _lsub +#define ltol3 _ltol3 +#define lxstat _lxstat +#define makecontext _makecontext +#define makekey _makekey +#define mctl _mctl +#define memalign _memalign +#define memccpy _memccpy +#define memcntl _memcntl +#define mincore _mincore +#define mkdir _mkdir +#define mkfifo _mkfifo +#define mknod _mknod +#define mktemp _mktemp +#define mlock _mlock +#define mlockall _mlockall +#define mmap _mmap +#define monitor _monitor +#define mount _mount +#define mprotect _mprotect +#define mrand48 _mrand48 +#define msgctl _msgctl +#define msgget _msgget +#define msgrcv _msgrcv +#define msgsnd _msgsnd +#define msync _msync +#define munlock _munlock +#define munlockall _munlockall +#define munmap _munmap +#define nfs_getfh _nfs_getfh +#define nfssvc _nfssvc +#define nftw _nftw +#define nice _nice +#define nrand48 _nrand48 +#define nuname _nuname +#define open _open +#define opendir _opendir +#define openlog _openlog +#define pathconf _pathconf +#define pause _pause +#define pclose _pclose +#define pipe _pipe +#define plock _plock +#define poll _poll +#define popen _popen +#define profil _profil +#define psiginfo _psiginfo +#define psignal _psignal +#define ptrace _ptrace +#define putenv _putenv +#define putmsg _putmsg +#define putpmsg _putpmsg +#define putpwent _putpwent +#define putspent _putspent +#define pututline _pututline +#define pututxline _pututxline +#define putw _putw +#define read _read +#define readdir _readdir +#define readlink _readlink +#define readv _readv +#define realpath _realpath +#define remque _remque +#define rmdir _rmdir +#define run_crypt _run_crypt +#define run_setkey _run_setkey +#define sbrk _sbrk +#define seed48 _seed48 +#define seekdir _seekdir +#define select _select +#define semctl _semctl +#define semget _semget +#define semop _semop +#define setcontext _setcontext +#define setegid _setegid +#define seteuid _seteuid +#define setgid _setgid +#define setgrent _setgrent +#define setgroups _setgroups +#define setitimer _setitimer +#define setkey _setkey +#define setlogmask _setlogmask +#define setpgid _setpgid +#define setpgrp _setpgrp +#define setpwent _setpwent +#define setrlimit _setrlimit +#define setsid _setsid +#define setspent _setspent +#define settimeofday _settimeofday +#define setuid _setuid +#define setutent _setutent +#define setutxent _setutxent +#define shmat _shmat +#define shmctl _shmctl +#define shmdt _shmdt +#define shmget _shmget +#define sig2str _sig2str +#define sigaction _sigaction +#define sigaddset _sigaddset +#define sigaltstack _sigaltstack +#define sigdelset _sigdelset +#define sigemptyset _sigemptyset +#define sigfillset _sigfillset +#define sigflag _sigflag +#define sighold _sighold +#define sigignore _sigignore +#define sigismember _sigismember +#define siglongjmp _siglongjmp +#define sigpause _sigpause +#define sigpending _sigpending +#define sigprocmask _sigprocmask +#define sigrelse _sigrelse +#define sigsend _sigsend +#define sigsendset _sigsendset +#define sigset _sigset +#define sigsetjmp _sigsetjmp +#define sigsuspend _sigsuspend +#define sleep _sleep +#define srand48 _srand48 +#define ssignal _ssignal +#define stat _stat +#define statfs _statfs +#define statvfs _statvfs +#define stime _stime +#define str2id _str2id +#define str2sig _str2sig +#define strdup _strdup +#define stty _stty +#define swab _swab +#define swapcontext _swapcontext +#define swapctl _swapctl +#define symlink _symlink +#define sync _sync +#define sys3b _sys3b +#define sys_errlist _sys_errlist +#define sys_nerr _sys_nerr +#define syscall _syscall +#define sysconf _sysconf +#define sysfs _sysfs +#define sysinfo _sysinfo +#define syslog _syslog +#define tcdrain _tcdrain +#define tcflow _tcflow +#define tcflush _tcflush +#define tcgetattr _tcgetattr +#define tcgetpgrp _tcgetpgrp +#define tcgetsid _tcgetsid +#define tcsendbreak _tcsendbreak +#define tcsetattr _tcsetattr +#define tcsetpgrp _tcsetpgrp +#define tdelete _tdelete +#define tell _tell +#define telldir _telldir +#define tempnam _tempnam +#define tfind _tfind +#define times _times +#define truncate _truncate +#define tsearch _tsearch +#define ttyname _ttyname +#define ttyslot _ttyslot +#define twalk _twalk +#define tzname _tzname +#define tzset _tzset +#define uadmin _uadmin +#define ulckpwdf _ulckpwdf +#define ulimit _ulimit +#define umask _umask +#define umount _umount +#define uname _uname +#define undial _undial +#define unlink _unlink +#define unordered _unordered +#define updutmp _updutmp +#define updwtmpx _updwtmpx +#define utime _utime +#define utmpname _utmpname +#define utmpxname _utmpxname +#define utssys _utssys +#define valloc _valloc +#define vfork _vfork +#define vsyslog _vsyslog +#define wait _wait +#define waitid _waitid +#define waitpid _waitpid +#define write _write +#define writev _writev +#define xmknod _xmknod +#define xstat _xstat +#define _assert __assert +#define _ctype __ctype +#define _filbuf __filbuf +#define _flsbuf __flsbuf +#define _iob __iob + + +#else /* not __STDC__ */ + +#define const + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBCRYPT_SYNONYMS_H */ diff --git a/usr/src/lib/libcrypt/sparc/Makefile b/usr/src/lib/libcrypt/sparc/Makefile new file mode 100644 index 0000000000..bcba4a291d --- /dev/null +++ b/usr/src/lib/libcrypt/sparc/Makefile @@ -0,0 +1,32 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/sparc/Makefile + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libcrypt/sparcv9/Makefile b/usr/src/lib/libcrypt/sparcv9/Makefile new file mode 100644 index 0000000000..87ac99efc1 --- /dev/null +++ b/usr/src/lib/libcrypt/sparcv9/Makefile @@ -0,0 +1,33 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/sparc/Makefile + +include ../Makefile.com +include ../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/libcrypt/spec/Makefile b/usr/src/lib/libcrypt/spec/Makefile new file mode 100644 index 0000000000..7bfb8914a5 --- /dev/null +++ b/usr/src/lib/libcrypt/spec/Makefile @@ -0,0 +1,31 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/spec/Makefile + +include $(SRC)/Makefile.master +include $(SRC)/lib/Makefile.spec.arch diff --git a/usr/src/lib/libcrypt/spec/Makefile.targ b/usr/src/lib/libcrypt/spec/Makefile.targ new file mode 100644 index 0000000000..b3c0b4d2f9 --- /dev/null +++ b/usr/src/lib/libcrypt/spec/Makefile.targ @@ -0,0 +1,33 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/spec/Makefile.targ + +LIBRARY = libcrypt.a +VERS = .1 + +OBJECTS = crypt.o diff --git a/usr/src/lib/libcrypt/spec/amd64/Makefile b/usr/src/lib/libcrypt/spec/amd64/Makefile new file mode 100644 index 0000000000..4b31884011 --- /dev/null +++ b/usr/src/lib/libcrypt/spec/amd64/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/spec/$(MACH64)/Makefile + +include ../Makefile.targ +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 +include $(SRC)/lib/Makefile.spec + +.KEEP_STATE: + +install: $(ROOTABILIB64) diff --git a/usr/src/lib/libcrypt/spec/crypt.spec b/usr/src/lib/libcrypt/spec/crypt.spec new file mode 100644 index 0000000000..b5c4820f4c --- /dev/null +++ b/usr/src/lib/libcrypt/spec/crypt.spec @@ -0,0 +1,170 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# + +function setkey +version SUNW_1.1 +filter libc.so.1 +end + +function encrypt +version SUNW_1.1 +filter libc.so.1 +end + +function crypt +version SUNW_1.1 +filter libc.so.1 +end + +function des_setkey +include <crypt.h> +declaration void des_setkey(const char *key) +version SUNWprivate_1.1 +end + +function run_setkey +include <crypt.h> +declaration int run_setkey(int *p, const char *keyparam) +version SUNWprivate_1.1 +end + +function run_crypt +include <crypt.h> +declaration int run_crypt(long offset, char *buffer, unsigned int count, int *p) +version SUNWprivate_1.1 +end + +function makekey +declaration int makekey(int *b) +version SUNWprivate_1.1 +exception $return == -1 +end + +function crypt_close_nolock +version SUNWprivate_1.1 +end + +function crypt_close +declaration int crypt_close(int *p) +version SUNWprivate_1.1 +end + +function des_encrypt +declaration void des_encrypt(char *block, int edflag) +version SUNWprivate_1.1 +end + +function des_crypt +declaration char *des_crypt(const char *pw, const char *salt) +version SUNWprivate_1.1 +end + +# +# weak interfaces +# + +function _lib_version +version SUNWprivate_1.1 +end + +function _setkey +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _encrypt +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _crypt +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _run_setkey +weak run_setkey +version SUNWprivate_1.1 +end + +function _run_crypt +weak run_crypt +version SUNWprivate_1.1 +end + +function _crypt_close +weak crypt_close +version SUNWprivate_1.1 +end + +function _makekey +weak makekey +version SUNWprivate_1.1 +end + +function _des_setkey +weak des_setkey +version SUNWprivate_1.1 +end + +function _des_encrypt +weak des_encrypt +version SUNWprivate_1.1 +end + +function _des_crypt +weak des_crypt +version SUNWprivate_1.1 +end + +function des_setparity +version SUNWprivate_1.1 +end + +function ecb_crypt +version SUNWprivate_1.1 +end + +function cbc_crypt +version SUNWprivate_1.1 +end + +function des_encrypt1 +version SUNWprivate_1.1 +end + +function _des_encrypt1 +version SUNWprivate_1.1 +end + +function __des_crypt +version SUNWprivate_1.1 +end + +function _des_decrypt1 +version SUNWprivate_1.1 +end diff --git a/usr/src/lib/libcrypt/spec/i386/Makefile b/usr/src/lib/libcrypt/spec/i386/Makefile new file mode 100644 index 0000000000..4365a173d5 --- /dev/null +++ b/usr/src/lib/libcrypt/spec/i386/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/spec/$(MACH32)/Makefile + + +include ../Makefile.targ +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.spec + +.KEEP_STATE: + +install: $(ROOTABILIB) diff --git a/usr/src/lib/libcrypt/spec/sparc/Makefile b/usr/src/lib/libcrypt/spec/sparc/Makefile new file mode 100644 index 0000000000..9b7e7ba95a --- /dev/null +++ b/usr/src/lib/libcrypt/spec/sparc/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/spec/$(MACH32)/Makefile + + +include ../Makefile.targ +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.spec + +.KEEP_STATE: + +install: $(ROOTABILIB) diff --git a/usr/src/lib/libcrypt/spec/sparcv9/Makefile b/usr/src/lib/libcrypt/spec/sparcv9/Makefile new file mode 100644 index 0000000000..4b31884011 --- /dev/null +++ b/usr/src/lib/libcrypt/spec/sparcv9/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/libcrypt/spec/$(MACH64)/Makefile + +include ../Makefile.targ +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 +include $(SRC)/lib/Makefile.spec + +.KEEP_STATE: + +install: $(ROOTABILIB64) diff --git a/usr/src/lib/libcrypt/spec/versions b/usr/src/lib/libcrypt/spec/versions new file mode 100644 index 0000000000..125f9b00f1 --- /dev/null +++ b/usr/src/lib/libcrypt/spec/versions @@ -0,0 +1,44 @@ +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# vers file for libcrypt +# +i386 { + SUNW_1.1; + SUNWprivate_1.1; +} +sparc { + SUNW_1.1; + SUNWprivate_1.1; +} +sparcv9 { + SUNW_1.1; + SUNWprivate_1.1; +} +amd64 { + SUNW_1.1; + SUNWprivate_1.1; +} |