--- old/usr/src/cmd/cmd-crypto/decrypt/Makefile	Wed Apr 30 17:51:42 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/Makefile	Wed Apr 30 17:51:41 2008
@@ -19,39 +19,45 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)Makefile	1.5	07/02/02 SMI"
+# ident	"@(#)Makefile	1.6	08/04/30 SMI"
 #
 
-PROG = decrypt
+PROG= decrypt
+ROOTLINK= $(ROOTBIN)/encrypt
+DCFILE=$(PROG).dc
 
-OBJS = decrypt.o
+include ../../Makefile.cmd
 
-SRCS = $(OBJS:.o=.c)
+SUBDIRS= $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
 
-include ../../Makefile.cmd 
+all	:=	TARGET = all
+install	:=	TARGET = install
+clean	:=	TARGET = clean
+clobber	:=	TARGET = clobber
+lint	:=	TARGET = lint
 
-CFLAGS += $(CCVERBOSE) -D_FILE_OFFSET_BITS=64
-
-LDLIBS += -lkmf -lpkcs11 -lcryptoutil
-
 .KEEP_STATE:
 
-all:    $(PROG)
+all clean clobber lint:	$(SUBDIRS)
 
-$(PROG): $(OBJS)
-	$(LINK.c) $(OBJS) -o $@ $(LDLIBS) $(DYNFLAGS)
-	$(POST_PROCESS)
+install:	$(SUBDIRS)
+	-$(RM) $(ROOTPROG) $(ROOTLINK)
+	-$(LN) $(ISAEXEC) $(ROOTPROG)
+	-$(LN) $(ISAEXEC) $(ROOTLINK)
 
-install: all $(ROOTPROG)
-	$(RM) $(ROOTBIN)/encrypt
-	$(LN) $(ROOTPROG) $(ROOTBIN)/encrypt
+$(SUBDIRS):	FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
 
-clean:
-	$(RM) -f $(OBJS) $(PROG)
+$(DCFILE):
+	$(RM) messages.po
+	$(XGETTEXT) $(XGETFLAGS) -t $(PROG).c
+	$(SED) -e '/^domain/d' messages.po > $@
+	$(RM) messages.po
 
-lint:   lint_SRCS
+FRC:
 
 include ../../Makefile.targ
--- /dev/null	Wed Apr 30 17:51:47 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/Makefile.com	Wed Apr 30 17:51:47 2008
@@ -0,0 +1,69 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"@(#)Makefile.com	1.1	08/04/30 SMI"
+#
+
+PROG = decrypt
+
+ROOTLINK32= $(ROOTBIN32)/encrypt
+ROOTLINK64= $(ROOTBIN64)/encrypt
+
+OBJS = decrypt.o
+
+SRCS = $(OBJS:%.o=../%.c)
+
+include ../../../Makefile.cmd 
+
+CFLAGS += $(CCVERBOSE) 
+CFLAGS64 += $(CCVERBOSE)
+CPPFLAGS += -D_FILE_OFFSET_BITS=64
+
+LDLIBS += -lkmf -lpkcs11 -lcryptoutil
+
+.KEEP_STATE:
+
+all:    $(PROG)
+
+lint:   lint_SRCS
+
+include ../../../Makefile.targ
+
+%.o:	../%.c
+	$(COMPILE.c) $<
+
+$(PROG): $(OBJS)
+	$(LINK.c) $(OBJS) -o $@ $(LDLIBS) $(DYNFLAGS)
+	$(POST_PROCESS)
+
+$(ROOTLINK32): $(ROOTPROG32)
+	$(RM) $@
+	$(LN) $(ROOTPROG32) $@
+
+$(ROOTLINK64): $(ROOTPROG64)
+	$(RM) $@
+	$(LN) $(ROOTPROG64) $@
+
+clean:
+	$(RM) $(PROG) $(OBJS)
--- /dev/null	Wed Apr 30 17:51:50 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/amd64/Makefile	Wed Apr 30 17:51:50 2008
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"@(#)Makefile	1.1	08/04/30 SMI"
+#
+
+include ../Makefile.com
+include ../../../Makefile.cmd.64
+
+install: all $(ROOTPROG64) $(ROOTLINK64)
+
--- old/usr/src/cmd/cmd-crypto/decrypt/decrypt.c	Wed Apr 30 17:51:55 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/decrypt.c	Wed Apr 30 17:51:54 2008
@@ -20,11 +20,11 @@
  */
 /* Portions Copyright 2005 Richard Lowe */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"@(#)decrypt.c	1.13	07/10/04 SMI"
+#pragma ident	"@(#)decrypt.c	1.14	08/04/30 SMI"
 
 /*
  * decrypt.c
@@ -33,28 +33,30 @@
  *
  * One binary performs both encrypt/decrypt operation.
  *
- * usage:
+ * Usage:
+ *  -a algorithm mechanism name without CKM_ prefix. Case
+ *               does not matter
+ *  -k keyfile   file containing key data. If not specified user is
+ *               prompted to enter key. key length > 0 is required
+ *  -i infile    input file to encrypt/decrypt. If omitted, stdin used.
+ *  -o outfile   output file to encrypt/decrypt. If omitted, stdout used.
+ *               if infile & outfile are same, a temp file is used for
+ *               output and infile is replaced with this file after
+ *               operation is complete
+ *  -l           Display the list of  algorithms
+ *  -v           Display verbose information
+ *  -T tokenspec Specify a PKCS#11 token (optionally used with -K)
+ *  -K keylabel  Specify the symmetric PKCS#11 token key label
  *
- *  algorithm - mechanism name without CKM_ prefix. Case
- *              does not matter
- *  keyfile - file containing key data. If not specified user is
- *            prompted to enter key. key length > 0 is required
- *  infile  - input file to encrypt/decrypt. If omitted, stdin used.
- *  outfile - output file to encrypt/decrypt. If omitted, stdout used.
- *            if infile & outfile are same, a temp file is used for
- *            output and infile is replaced with this file after
- *            operation is complete.
- *
  * Implementation notes:
- *   iv data - It is generated by random bytes equal to one block size.
+ *   IV data - It is generated by random bytes equal to one block size.
  *
- *   encrypted output format -
+ *   Encrypted output format -
  *   - Output format version number - 4 bytes in network byte order.
  *   - Iterations used in key gen function, 4 bytes in  network byte order.
- *   - IV ( 'ivlen' bytes)
+ *   - IV ('ivlen' bytes).  Length is algorithm-dependent (see mech_aliases)
  *   - Salt data used in key gen (16 bytes)
- *   - cipher text data.
- *
+ *   - Cipher text data (remainder of the file)
  */
 
 #include <stdio.h>
@@ -165,14 +167,14 @@
 static boolean_t oflag = B_FALSE; /* -o <outfile> flag, use stdout if absent */
 static boolean_t lflag = B_FALSE; /* -l flag (list) */
 static boolean_t vflag = B_FALSE; /* -v flag (verbose) */
-static boolean_t Tflag = B_FALSE;
-static boolean_t Kflag = B_FALSE;
+static boolean_t Tflag = B_FALSE; /* -T flag (tokenspec) */
+static boolean_t Kflag = B_FALSE; /* -K flag (keylabel) */
 
-static char *keyfile = NULL;	/* name of keyfile */
-static char *inputfile = NULL;	/* name of input file */
-static char *outputfile = NULL;	/* name of output file */
-static char *token_label = NULL;
-static char *key_label = NULL;
+static char *keyfile = NULL;	 /* name of keyfile */
+static char *inputfile = NULL;	 /* name of input file */
+static char *outputfile = NULL;	 /* name of output file */
+static char *token_label = NULL; /* name of PKCS#11 token */
+static char *key_label = NULL;   /* name of PKCS#11 token key label */
 
 static int status_pos = 0; /* current position of progress bar element */
 
@@ -198,7 +200,7 @@
 	boolean_t errflag = B_FALSE;
 
 	(void) setlocale(LC_ALL, "");
-#if !defined(TEXT_DOMAIN)	/* Should be defiend by cc -D */
+#if !defined(TEXT_DOMAIN)	/* Should be defined by cc -D */
 #define	TEXT_DOMAIN "SYS_TEST"	/* Use this only if it weren't */
 #endif
 	(void) textdomain(TEXT_DOMAIN);
@@ -435,10 +437,10 @@
 	boolean_t inoutsame = B_FALSE;	/* if both input & output are same */
 	CK_BYTE_PTR	pivbuf = NULL_PTR;
 	CK_ULONG	ivlen = 0L;
-	int mech_match = 0;
-	CK_ULONG	iterations = CK_PKCS5_PBKD2_ITERATIONS;
+	int		mech_match = 0;
+	uint32_t	iterations = CK_PKCS5_PBKD2_ITERATIONS;
 	CK_ULONG	keylen;
-	int version = SUNW_ENCRYPT_FILE_VERSION;
+	uint32_t	version = SUNW_ENCRYPT_FILE_VERSION;
 	CK_KEY_TYPE keytype;
 	KMF_RETURN kmfrv;
 	CK_SLOT_ID token_slot_id;
@@ -740,9 +742,11 @@
 		case 1:
 		/*
 		 * Version 1 output format:
+		 *  - Output format version 1 (4 bytes)
 		 *  - Iterations used in key gen function (4 bytes)
-		 *  - IV ( 'ivlen' bytes)
+		 *  - IV ('ivlen' bytes). The length algorithm-dependent
 		 *  - Salt data used in key gen (16 bytes)
+		 *  - Cipher text data (remainder of the file)
 		 *
 		 * An encrypted file has IV as first block (0 or
 		 * more bytes depending on mechanism) followed
@@ -898,8 +902,8 @@
 	/* Write the version header encrypt command */
 	if (cmd->type == CKA_ENCRYPT) {
 		/* convert to network order for storage */
-		int netversion = htonl(version);
-		CK_ULONG netiter;
+		uint32_t	netversion = htonl(version);
+		uint32_t	netiter;
 
 		if (write(outfd, &netversion, sizeof (netversion))
 		    != sizeof (netversion)) {
--- /dev/null	Wed Apr 30 17:52:03 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/i386/Makefile	Wed Apr 30 17:52:03 2008
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"@(#)Makefile	1.1	08/04/30 SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTPROG32) $(ROOTLINK32)
+
+
--- /dev/null	Wed Apr 30 17:52:07 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/sparc/Makefile	Wed Apr 30 17:52:07 2008
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"@(#)Makefile	1.1	08/04/30 SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTPROG32) $(ROOTLINK32)
--- /dev/null	Wed Apr 30 17:52:11 2008
+++ new/usr/src/cmd/cmd-crypto/decrypt/sparcv9/Makefile	Wed Apr 30 17:52:11 2008
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"@(#)Makefile	1.1	08/04/30 SMI"
+#
+
+include ../Makefile.com
+include ../../../Makefile.cmd.64
+
+install: all $(ROOTPROG64) $(ROOTLINK64)
--- old/usr/src/pkgdefs/SUNWcsu/prototype_com	Wed Apr 30 17:52:16 2008
+++ new/usr/src/pkgdefs/SUNWcsu/prototype_com	Wed Apr 30 17:52:15 2008
@@ -22,7 +22,7 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)prototype_com	1.570	08/03/26 SMI"
+# ident	"@(#)prototype_com	1.571	08/04/30 SMI"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
@@ -93,7 +93,7 @@
 f none usr/bin/cut 555 root bin
 f none usr/bin/date 555 root bin
 f none usr/bin/dd 555 root bin
-f none usr/bin/decrypt 555 root bin
+l none usr/bin/decrypt=../../usr/lib/isaexec
 f none usr/bin/devattr 555 root bin
 f none usr/bin/devfree 555 root bin
 f none usr/bin/devreserv 555 root bin
@@ -111,7 +111,7 @@
 f none usr/bin/edit 555 root bin
 f none usr/bin/egrep 555 root bin
 f none usr/bin/eject 555 root bin
-l none usr/bin/encrypt=../../usr/bin/decrypt
+l none usr/bin/encrypt=../../usr/lib/isaexec
 f none usr/bin/env 555 root bin
 l none usr/bin/ex=../../usr/bin/edit
 f none usr/bin/expr 555 root bin
--- old/usr/src/pkgdefs/SUNWcsu/prototype_i386	Wed Apr 30 17:52:25 2008
+++ new/usr/src/pkgdefs/SUNWcsu/prototype_i386	Wed Apr 30 17:52:24 2008
@@ -22,7 +22,7 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)prototype_i386	1.92	08/03/20 SMI"
+# ident	"@(#)prototype_i386	1.93	08/04/30 SMI"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
@@ -50,7 +50,9 @@
 f none usr/bin/i86/amt 555 root bin
 f none usr/bin/diskscan 555 root bin
 d none usr/bin/i86 755 root bin
+f none usr/bin/i86/decrypt 555 root bin
 f none usr/bin/i86/digest 555 root bin
+l none usr/bin/i86/encrypt=decrypt
 f none usr/bin/i86/ksh93 555 root bin
 f none usr/bin/i86/newtask 4555 root sys
 f none usr/bin/i86/nohup 555 root bin
@@ -107,7 +109,9 @@
 d none usr/bin/amd64 755 root bin
 f none usr/bin/amd64/amt 555 root bin
 f none usr/bin/amd64/crle 555 root bin
+f none usr/bin/amd64/decrypt 555 root bin
 f none usr/bin/amd64/digest 555 root bin
+l none usr/bin/amd64/encrypt=decrypt
 f none usr/bin/amd64/ksh93 555 root bin
 f none usr/bin/amd64/ls 555 root bin
 l none usr/bin/amd64/mac=digest
--- old/usr/src/pkgdefs/SUNWcsu/prototype_sparc	Wed Apr 30 17:52:33 2008
+++ new/usr/src/pkgdefs/SUNWcsu/prototype_sparc	Wed Apr 30 17:52:33 2008
@@ -22,7 +22,7 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)prototype_sparc	1.133	08/03/20 SMI"
+# ident	"@(#)prototype_sparc	1.134	08/04/30 SMI"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
@@ -50,12 +50,16 @@
 f none usr/bin/sparcv7/ksh93 555 root bin
 l none usr/bin/sparcv7/rksh93=ksh93
 f none usr/bin/sparcv7/savecore 555 root bin
+f none usr/bin/sparcv7/decrypt 555 root bin
 f none usr/bin/sparcv7/digest 555 root bin
+l none usr/bin/sparcv7/encrypt=decrypt
 l none usr/bin/sparcv7/mac=digest
 d none usr/bin/sparcv9 755 root bin
 f none usr/bin/sparcv9/amt 555 root bin
 f none usr/bin/sparcv9/crle 555 root bin
+f none usr/bin/sparcv9/decrypt 555 root bin
 f none usr/bin/sparcv9/digest 555 root bin
+l none usr/bin/sparcv9/encrypt=decrypt
 f none usr/bin/sparcv9/ksh93 555 root bin
 f none usr/bin/sparcv9/ls 555 root bin
 l none usr/bin/sparcv9/mac=digest
