--- /dev/null	Wed Jan  2 14:48:52 2008
+++ new/usr/src/common/crypto/arcfour/amd64/arcfour_crypt_amd64.s	Wed Jan  2 14:48:52 2008
@@ -0,0 +1,165 @@
+#if !defined(lint) && !defined(__lint)
+/  ARCFOUR implementation optimized for AMD64.
+/
+/  Author: Marc Bevand <bevand_m (at) epita.fr>
+/  Licence: I hereby disclaim the copyright on this code and place it
+/  in the public domain.
+/
+/  The code has been designed to be easily integrated into openssl:
+/  the exported RC4() function can replace the actual implementations
+/  openssl already contains. Please note that when linking with openssl,
+/  it requires that sizeof(RC4_INT) == 8. So openssl must be compiled
+/  with -DRC4_INT='unsigned long'.
+/
+/  The throughput achieved by this code is about 320 MBytes/sec, on
+/  a 1.8 GHz AMD Opteron (rev C0) processor.
+
+
+/ ***** BEGIN LICENSE BLOCK *****
+/ Version: MPL 1.1/GPL 2.0/LGPL 2.1
+/
+/ The contents of this file are subject to the Mozilla Public License Version
+/ 1.1 (the "License"); you may not use this file except in compliance with
+/ the License. You may obtain a copy of the License at
+/ http://www.mozilla.org/MPL/
+/
+/ Software distributed under the License is distributed on an "AS IS" basis,
+/ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+/ for the specific language governing rights and limitations under the
+/ License.
+/
+/ The Original Code is "Marc Bevand's fast AMD64 ARCFOUR source"
+/
+/ The Initial Developer of the Original Code is
+/ Marc Bevand <bevand_m@epita.fr> .
+/ Portions created by the Initial Developer are
+/ Copyright (C) 2004 the Initial Developer. All Rights Reserved.
+/
+/ Contributor(s):
+/
+/ Alternatively, the contents of this file may be used under the terms of
+/ either the GNU General Public License Version 2 or later (the "GPL"), or
+/ the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+/ in which case the provisions of the GPL or the LGPL are applicable instead
+/ of those above. If you wish to allow use of your version of this file only
+/ under the terms of either the GPL or the LGPL, and not to allow others to
+/ use your version of this file under the terms of the MPL, indicate your
+/ decision by deleting the provisions above and replace them with the notice
+/ and other provisions required by the GPL or the LGPL. If you do not delete
+/ the provisions above, a recipient may use your version of this file under
+/ the terms of any one of the MPL, the GPL or the LGPL.
+/
+/ ***** END LICENSE BLOCK *****
+
+	.ident	"@(#)arcfour_crypt_amd64.s	1.1	08/01/02 SMI"
+
+/
+/ void arcfour_crypt(ARCFour_key *key, uchar_t *in,
+/		uchar_t *out, size_t len);
+/
+/ The following is Marc Bevand's RC4 implementation optimized for
+/ AMD64.  It has been lifted intact, except for minor interface
+/ changes to get along with Solaris crypto common code (the parameter
+/ order and the key struct element order are both different).
+/ This function works for both aligned and unaligned data ('in' and 'out').
+/ The key and key elements must be aligned.
+/
+/ Register Usage
+/ rax		data[x]
+/ rbx		ARG(len)
+/ rcx		key->i (aka x)
+/ rdx		key->j (aka y)
+/ rsi		ARG(in)
+/ rdi		ARG(out)
+/ rbp		key->arr (aka data or d)
+/ rsp		stack
+/ r8		8 bytes of rc4 stream
+/ r9		temp
+/ r10-r15 	unused
+/
+
+#include <sys/asm_linkage.h>
+
+
+	ENTRY_NP(arcfour_crypt)
+	/* EXPORT DELETE START */
+					/ load parameters
+	push	%rbp
+	push	%rbx
+	mov	%rdi,		%rbp	/ rbp = ARG(key)
+					/ rsi = ARG(in)
+	mov	%rdx,		%rdi	/ rdi = ARG(out)
+	mov	%rcx,		%rbx	/ rbx = ARG(len)
+
+					/ load key indices and key
+	mov	2048(%rbp),	%rcx	/ rcx x = key->i
+	mov	2056(%rbp),	%rdx	/ rdx y = key->j
+					/ rbp d = key->arr
+	inc	%rcx			/ x++
+	and	$255,		%rcx	/ x &= 0xff
+	lea	-8(%rbx,%rsi),	%rbx	/ rbx = in+len-8
+	mov	%rbx,		%r9	/ tmp = in+len-8
+	mov	(%rbp,%rcx,8),	%rax	/ tx = d[x]
+	cmp	%rsi,		%rbx	/ cmp in with in+len-8
+	jl	.Lend			/ jump if (in+len-8 < in)
+
+.Lstart:
+	add	$8,		%rsi		/ increment in
+	add	$8,		%rdi		/ increment out
+
+	/ generate the next 8 bytes of the rc4 stream into %r8
+	mov	$8,		%r11		/ byte counter
+1:	add	%al,		%dl		/ y += tx
+	mov	(%rbp,%rdx,8),	%ebx		/ ty = d[y]
+	mov	%ebx,		(%rbp,%rcx,8)	/ d[x] = ty
+	add	%al,		%bl		/ val = ty + tx
+	mov	%eax,		(%rbp,%rdx,8)	/ d[y] = tx
+	inc	%cl				/ x++		(NEXT ROUND)
+	mov	(%rbp,%rcx,8),	%eax		/ tx = d[x]	(NEXT ROUND)
+	movb	(%rbp,%rbx,8),	%r8b		/ val = d[val]
+	dec	%r11b
+	ror	$8,		%r8		/ (ror does not change ZF)
+	jnz	1b
+
+	/ xor 8 bytes
+	xor	-8(%rsi),	%r8
+	cmp	%r9,		%rsi		/ cmp in+len-8 with in
+	mov	%r8,		-8(%rdi)
+	jle	.Lstart				/ jump if (in <= in+len-8)
+
+.Lend:
+	add	$8,		%r9		/ tmp = in+len
+
+	/ handle the last bytes, one by one
+1:	cmp	%rsi,		%r9		/ cmp in with in+len
+	jle	.Lfinished			/ jump if (in+len <= in)
+	add	%al,		%dl		/ y += tx
+	mov	(%rbp,%rdx,8),	%ebx		/ ty = d[y]
+	mov	%ebx,		(%rbp,%rcx,8)	/ d[x] = ty
+	add	%al,		%bl		/ val = ty + tx
+	mov	%eax,		(%rbp,%rdx,8)	/ d[y] = tx
+	inc	%cl				/ x++		(NEXT ROUND)
+	mov	(%rbp,%rcx,8),	%eax		/ tx = d[x]	(NEXT ROUND)
+	movb	(%rbp,%rbx,8),	%r8b		/ val = d[val]
+	xor	(%rsi),		%r8b		/ xor 1 byte
+	movb	%r8b,		(%rdi)
+	inc	%rsi				/ in++
+	inc	%rdi				/ out++
+	jmp	1b
+
+.Lfinished:					/ save key indices i & j
+	dec	%rcx				/ x--
+	movb	%dl,		2056(%rbp)	/ key->j = y
+	movb	%cl,		2048(%rbp)	/ key->i = x
+	pop	%rbx
+	pop	%rbp
+
+	/* EXPORT DELETE END */
+
+	ret
+	SET_SIZE(arcfour_crypt)
+
+#else
+	/* LINTED */
+	/* Nothing to be linted in this file--it's pure assembly source. */
+#endif /* !lint && !__lint */
--- old/usr/src/common/crypto/arcfour/arcfour_crypt.c	Wed Jan  2 14:48:53 2008
+++ new/usr/src/common/crypto/arcfour/arcfour_crypt.c	Wed Jan  2 14:48:53 2008
@@ -2,9 +2,8 @@
  * 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.
+ * 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.
@@ -20,14 +19,22 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"@(#)arcfour_crypt.c	1.5	05/08/23 SMI"
+#pragma ident	"@(#)arcfour_crypt.c	1.6	08/01/02 SMI"
 
 #include "arcfour.h"
 
+#if defined(__amd64)
+/*
+ * Use hand-tuned, processor-specific assembly version of arcfour_crypt()
+ * for 64-bit x86:
+ */
+#define	USE_PSR_VERSION_OF_ARCFOUR_CRYPT
+#endif /* __amd64 */
+
 /* Initialize the key stream 'key' using the key value */
 void
 arcfour_key_init(ARCFour_key *key, uchar_t *keyval, int keyvallen)
@@ -61,8 +68,9 @@
 }
 
 
+#if !defined(USE_PSR_VERSION_OF_ARCFOUR_CRYPT)
 /*
- * Encipher 'in' using 'key.
+ * Encipher 'in' using 'key'.
  * in and out can point to the same location
  */
 void
@@ -130,3 +138,4 @@
 
 /* EXPORT DELETE END */
 }
+#endif	/* !USE_PSR_VERSION_OF_ARCFOUR_CRYPT */
--- /dev/null	Wed Jan  2 14:48:54 2008
+++ new/usr/src/common/crypto/md5/amd64/md5_amd64.pl	Wed Jan  2 14:48:54 2008
@@ -0,0 +1,352 @@
+#!/usr/bin/perl -w
+use strict;
+my $code .= <<EOF;
+#if !defined(lint) && !defined(__lint)
+/
+/ MD5 optimized for AMD64.
+/
+/ Author: Marc Bevand <bevand_m (at) epita.fr>
+/ Licence: I hereby disclaim the copyright on this code and place it
+/ in the public domain.
+/
+
+	.ident	"@(#)md5_amd64.pl	1.1	08/01/02 SMI"
+
+/
+/ The following is Marc Bevand's MD5 implementation optimized for
+/ AMD64.  It has been lifted intact, except for changing the comment
+/ character, adding comments, and a kludge to generate valid "lea"
+/ instructions that are not generated by the Solaris "as" assembler
+/ (CR 6628627).
+/
+/ typedef struct {
+/	uint32_t state[4];	/* state (ABCD) */
+/	uint32_t count[2];	/* number of bits, modulo 2^64 (lsb first) */
+/	union	{
+/		uint8_t		buf8[64];	/* undigested input */
+/		uint32_t	buf32[16];	/* realigned input */
+/		} buf_un;
+/	} MD5_CTX;
+/
+/ void md5_block_asm_host_order(MD5_CTX *ctx, const void *inpp,
+/        unsigned int input_length_in_blocks);
+/
+/ Registers used:
+/	rax  A		r8  old A
+/	rbx  B		r9  old B
+/	rcx  C		r10 tmp
+/	rdx  D		r11 tmp
+/	rsi  ptr	r12 tmp
+/	rdi  end	r13 -
+/	rbp  -		r14 old C
+/	rsp  stack	r15 old D
+/
+
+EOF
+
+
+sub lea_offset_register_r10d_ebx
+# Workaround for a Solaris "gas" assembler bug where compiling the source
+# errors out and does not generate a valid "lea" instruction.  Specifically,
+#	lea OFFSET(REGISTER,%r10d),REGISTER
+#
+# For Solaris as, "as -a32" must be used to compile this.
+# For Solaris gas 2.15, this errors out with this message:
+# Error: `0xf57c0faf(%eax,%r10d)' is not a valid 64 bit base/index expression
+# This should be fixed in Solaris gas 2.16.
+# It assembles with the Linux "as --64" gas 2.17 assembler and runs OK.
+#
+# For the ONBLD NV tools, the aw wrapper script fails when -a32 is used:
+# /ws/onnv-tools/onbld/bin/i386/aw -xarch=amd64 -P -a32 -o lea.o lea.s
+# aw: as->gas mapping failed at or near arg '-a32'
+#
+# For more information, see CRs 6644870 and 6628627.
+# Note2: Solaris "as" uses "/" for comments; Linux "as" uses "#" for comments.
+{
+	use Switch;
+	my ($offset, $register, $comment) = @_;
+
+	# Failed "lea" instruction.
+	# This instruction errors out from the Solaris as assembler.
+	# It assembles with the Linux "as --64" assembler and runs OK.
+	$code .= "	/ lea $offset($register,%r10d),$register"
+						. "	$comment\n";
+
+	# Workaround #1 (not used)
+	# One workaround is to generate two "add" instructions that are
+	# functionally equivalent to "lea."  The problem is this workaround
+	# is about 4.5% slower than a lea, so is not used.
+	#$code .= "	add	%r10d,$register\n";
+	#$code .= "	add	\&0x%0x,$offset\n";
+
+	# Workaround #2 (used)
+	# This workaround hand-generates hex machine code for lea.
+	$code .= "	/ Solaris as assembly bug CR 6628627 errors out for\n";
+	$code .= "	/ the above, so we specify the machine code in hex:\n";
+	$code .= "	.byte	0x67,0x42,0x8d	/ lea offset(reg,%r10d),reg\n";
+
+	switch ($register) {
+	case "%eax"	{ $code .= "	.byte	0x84,0x10	/ reg=%eax\n"; }
+	case "%ebx"	{ $code .= "	.byte	0x9c,0x13	/ reg=%ebx\n"; }
+	case "%ecx"	{ $code .= "	.byte	0x8c,0x11	/ reg=%ecx\n"; }
+	case "%edx"	{ $code .= "	.byte	0x94,0x12	/ reg=%edx\n"; }
+	else		{ $code .= "ERROR: unknown register $register\n"; }
+	}
+
+	$code .= "	.long	$offset	/ offset\n";
+}
+
+
+
+# round1_step() does:
+#   dst = x + ((dst + F(x,y,z) + X[k] + T_i) <<< s)
+#   %r10d = X[k_next]
+#   %r11d = z' (copy of z for the next step)
+# Each round1_step() takes about 5.3 clocks (9 instructions, 1.7 IPC)
+sub round1_step
+{
+    my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
+    $code .= "	mov	0*4(%rsi),	%r10d		/* (NEXT STEP) X[0] */\n" if ($pos == -1);
+    $code .= "	mov	%edx,		%r11d		/* (NEXT STEP) z' = %edx */\n" if ($pos == -1);
+    $code .= "	xor	$y,		%r11d		/* y ^ ... */\n";
+	#lea	$T_i($dst,%r10d),$dst		/* Const + dst + ... */
+	lea_offset_register_r10d_ebx($T_i, $dst, "/* Const + dst + ... */");
+    $code .= <<EOF;
+	and	$x,		%r11d		/* x & ... */
+	xor	$z,		%r11d		/* z ^ ... */
+	mov	$k_next*4(%rsi),%r10d		/* (NEXT STEP) X[$k_next] */
+	add	%r11d,		$dst		/* dst += ... */
+	rol	\$$s,		$dst		/* dst <<< s */
+	mov	$y,		%r11d		/* (NEXT STEP) z' = $y */
+	add	$x,		$dst		/* dst += x */
+EOF
+}
+
+# round2_step() does:
+#   dst = x + ((dst + G(x,y,z) + X[k] + T_i) <<< s)
+#   %r10d = X[k_next]
+#   %r11d = z' (copy of z for the next step)
+#   %r12d = z' (copy of z for the next step)
+# Each round2_step() takes about 5.4 clocks (11 instructions, 2.0 IPC)
+sub round2_step
+{
+    my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
+    $code .= "	mov	1*4(%rsi),	%r10d		/* (NEXT STEP) X[1] */\n" if ($pos == -1);
+    $code .= "	mov	%edx,		%r11d		/* (NEXT STEP) z' = %edx */\n" if ($pos == -1);
+    $code .= "	mov	%edx,		%r12d		/* (NEXT STEP) z' = %edx */\n" if ($pos == -1);
+    $code .= "	not	%r11d				/* not z */\n";
+	#lea	$T_i($dst,%r10d),$dst		/* Const + dst + ... */
+	lea_offset_register_r10d_ebx($T_i, $dst, "/* Const + dst + ... */");
+    $code .= <<EOF;
+	and	$x,		%r12d		/* x & z */
+	and	$y,		%r11d		/* y & (not z) */
+	mov	$k_next*4(%rsi),%r10d		/* (NEXT STEP) X[$k_next] */
+	or	%r11d,		%r12d		/* (y & (not z)) | (x & z) */
+	mov	$y,		%r11d		/* (NEXT STEP) z' = $y */
+	add	%r12d,		$dst		/* dst += ... */
+	mov	$y,		%r12d		/* (NEXT STEP) z' = $y */
+	rol	\$$s,		$dst		/* dst <<< s */
+	add	$x,		$dst		/* dst += x */
+EOF
+}
+
+# round3_step() does:
+#   dst = x + ((dst + H(x,y,z) + X[k] + T_i) <<< s)
+#   %r10d = X[k_next]
+#   %r11d = y' (copy of y for the next step)
+# Each round3_step() takes about 4.2 clocks (8 instructions, 1.9 IPC)
+sub round3_step
+{
+    my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
+    $code .= "	mov	5*4(%rsi),	%r10d		/* (NEXT STEP) X[5] */\n" if ($pos == -1);
+    $code .= "	mov	%ecx,		%r11d		/* (NEXT STEP) y' = %ecx */\n" if ($pos == -1);
+	#lea	$T_i($dst,%r10d),$dst		/* Const + dst + ... */
+	lea_offset_register_r10d_ebx($T_i, $dst, "/* Const + dst + ... */");
+    $code .= <<EOF;
+	mov	$k_next*4(%rsi),%r10d		/* (NEXT STEP) X[$k_next] */
+	xor	$z,		%r11d		/* z ^ ... */
+	xor	$x,		%r11d		/* x ^ ... */
+	add	%r11d,		$dst		/* dst += ... */
+	rol	\$$s,		$dst		/* dst <<< s */
+	mov	$x,		%r11d		/* (NEXT STEP) y' = $x */
+	add	$x,		$dst		/* dst += x */
+EOF
+}
+
+# round4_step() does:
+#   dst = x + ((dst + I(x,y,z) + X[k] + T_i) <<< s)
+#   %r10d = X[k_next]
+#   %r11d = not z' (copy of not z for the next step)
+# Each round4_step() takes about 5.2 clocks (9 instructions, 1.7 IPC)
+sub round4_step
+{
+    my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
+    $code .= "	mov	0*4(%rsi),	%r10d		/* (NEXT STEP) X[0] */\n" if ($pos == -1);
+    $code .= "	mov	\$0xffffffff,	%r11d\n" if ($pos == -1);
+    $code .= "	xor	%edx,		%r11d		/* (NEXT STEP) not z' = not %edx*/\n"
+    if ($pos == -1);
+	#lea	$T_i($dst,%r10d),$dst		/* Const + dst + ... */
+	lea_offset_register_r10d_ebx($T_i, $dst, "/* Const + dst + ... */");
+    $code .= <<EOF;
+	or	$x,		%r11d		/* x | ... */
+	xor	$y,		%r11d		/* y ^ ... */
+	add	%r11d,		$dst		/* dst += ... */
+	mov	$k_next*4(%rsi),%r10d		/* (NEXT STEP) X[$k_next] */
+	mov	\$0xffffffff,	%r11d
+	rol	\$$s,		$dst		/* dst <<< s */
+	xor	$y,		%r11d		/* (NEXT STEP) not z' = not $y */
+	add	$x,		$dst		/* dst += x */
+EOF
+}
+
+
+#
+# Execution begins here.
+#
+
+my $output = shift;
+open STDOUT,">$output" or die "can't open $output: $!";
+
+$code .= <<EOF;
+
+#include <sys/asm_linkage.h>
+
+	ENTRY_NP(md5_block_asm_host_order)
+	push	%rbp
+	push	%rbx
+	push	%r12
+	push	%r13
+	push	%r14
+	push	%r15
+
+	/ rdi = arg #1 (ctx, MD5_CTX pointer)
+	/ rsi = arg #2 (ptr, data pointer)
+	/ rdx = arg #3 (nbr, number of 64-byte blocks to process)
+	mov	%rdi,		%rbp	/ rbp = ctx
+	shl	\$6,		%rdx	/ rdx = nbr in bytes
+	lea	(%rsi,%rdx),	%rdi	/ rdi = end
+	mov	0*4(%rbp),	%eax	/ eax = ctx->A
+	mov	1*4(%rbp),	%ebx	/ ebx = ctx->B
+	mov	2*4(%rbp),	%ecx	/ ecx = ctx->C
+	mov	3*4(%rbp),	%edx	/ edx = ctx->D
+	push	%rbp			/ save ctx
+	/ end is 'rdi'
+	/ ptr is 'rsi'
+	/ A is 'eax'
+	/ B is 'ebx'
+	/ C is 'ecx'
+	/ D is 'edx'
+
+	cmp	%rdi,		%rsi		/ cmp end with ptr
+	je	1f				/ jmp if ptr == end
+
+	/ BEGIN of loop over 64-byte blocks
+2:	/ save old values of A, B, C, D
+	mov	%eax,		%r8d
+	mov	%ebx,		%r9d
+	mov	%ecx,		%r14d
+	mov	%edx,		%r15d
+EOF
+round1_step(-1,'%eax','%ebx','%ecx','%edx', '1','0xd76aa478', '7');
+round1_step( 0,'%edx','%eax','%ebx','%ecx', '2','0xe8c7b756','12');
+round1_step( 0,'%ecx','%edx','%eax','%ebx', '3','0x242070db','17');
+round1_step( 0,'%ebx','%ecx','%edx','%eax', '4','0xc1bdceee','22');
+round1_step( 0,'%eax','%ebx','%ecx','%edx', '5','0xf57c0faf', '7');
+round1_step( 0,'%edx','%eax','%ebx','%ecx', '6','0x4787c62a','12');
+round1_step( 0,'%ecx','%edx','%eax','%ebx', '7','0xa8304613','17');
+round1_step( 0,'%ebx','%ecx','%edx','%eax', '8','0xfd469501','22');
+round1_step( 0,'%eax','%ebx','%ecx','%edx', '9','0x698098d8', '7');
+round1_step( 0,'%edx','%eax','%ebx','%ecx','10','0x8b44f7af','12');
+round1_step( 0,'%ecx','%edx','%eax','%ebx','11','0xffff5bb1','17');
+round1_step( 0,'%ebx','%ecx','%edx','%eax','12','0x895cd7be','22');
+round1_step( 0,'%eax','%ebx','%ecx','%edx','13','0x6b901122', '7');
+round1_step( 0,'%edx','%eax','%ebx','%ecx','14','0xfd987193','12');
+round1_step( 0,'%ecx','%edx','%eax','%ebx','15','0xa679438e','17');
+round1_step( 1,'%ebx','%ecx','%edx','%eax', '0','0x49b40821','22');
+
+round2_step(-1,'%eax','%ebx','%ecx','%edx', '6','0xf61e2562', '5');
+round2_step( 0,'%edx','%eax','%ebx','%ecx','11','0xc040b340', '9');
+round2_step( 0,'%ecx','%edx','%eax','%ebx', '0','0x265e5a51','14');
+round2_step( 0,'%ebx','%ecx','%edx','%eax', '5','0xe9b6c7aa','20');
+round2_step( 0,'%eax','%ebx','%ecx','%edx','10','0xd62f105d', '5');
+round2_step( 0,'%edx','%eax','%ebx','%ecx','15', '0x2441453', '9');
+round2_step( 0,'%ecx','%edx','%eax','%ebx', '4','0xd8a1e681','14');
+round2_step( 0,'%ebx','%ecx','%edx','%eax', '9','0xe7d3fbc8','20');
+round2_step( 0,'%eax','%ebx','%ecx','%edx','14','0x21e1cde6', '5');
+round2_step( 0,'%edx','%eax','%ebx','%ecx', '3','0xc33707d6', '9');
+round2_step( 0,'%ecx','%edx','%eax','%ebx', '8','0xf4d50d87','14');
+round2_step( 0,'%ebx','%ecx','%edx','%eax','13','0x455a14ed','20');
+round2_step( 0,'%eax','%ebx','%ecx','%edx', '2','0xa9e3e905', '5');
+round2_step( 0,'%edx','%eax','%ebx','%ecx', '7','0xfcefa3f8', '9');
+round2_step( 0,'%ecx','%edx','%eax','%ebx','12','0x676f02d9','14');
+round2_step( 1,'%ebx','%ecx','%edx','%eax', '0','0x8d2a4c8a','20');
+
+round3_step(-1,'%eax','%ebx','%ecx','%edx', '8','0xfffa3942', '4');
+round3_step( 0,'%edx','%eax','%ebx','%ecx','11','0x8771f681','11');
+round3_step( 0,'%ecx','%edx','%eax','%ebx','14','0x6d9d6122','16');
+round3_step( 0,'%ebx','%ecx','%edx','%eax', '1','0xfde5380c','23');
+round3_step( 0,'%eax','%ebx','%ecx','%edx', '4','0xa4beea44', '4');
+round3_step( 0,'%edx','%eax','%ebx','%ecx', '7','0x4bdecfa9','11');
+round3_step( 0,'%ecx','%edx','%eax','%ebx','10','0xf6bb4b60','16');
+round3_step( 0,'%ebx','%ecx','%edx','%eax','13','0xbebfbc70','23');
+round3_step( 0,'%eax','%ebx','%ecx','%edx', '0','0x289b7ec6', '4');
+round3_step( 0,'%edx','%eax','%ebx','%ecx', '3','0xeaa127fa','11');
+round3_step( 0,'%ecx','%edx','%eax','%ebx', '6','0xd4ef3085','16');
+round3_step( 0,'%ebx','%ecx','%edx','%eax', '9', '0x4881d05','23');
+round3_step( 0,'%eax','%ebx','%ecx','%edx','12','0xd9d4d039', '4');
+round3_step( 0,'%edx','%eax','%ebx','%ecx','15','0xe6db99e5','11');
+round3_step( 0,'%ecx','%edx','%eax','%ebx', '2','0x1fa27cf8','16');
+round3_step( 1,'%ebx','%ecx','%edx','%eax', '0','0xc4ac5665','23');
+
+round4_step(-1,'%eax','%ebx','%ecx','%edx', '7','0xf4292244', '6');
+round4_step( 0,'%edx','%eax','%ebx','%ecx','14','0x432aff97','10');
+round4_step( 0,'%ecx','%edx','%eax','%ebx', '5','0xab9423a7','15');
+round4_step( 0,'%ebx','%ecx','%edx','%eax','12','0xfc93a039','21');
+round4_step( 0,'%eax','%ebx','%ecx','%edx', '3','0x655b59c3', '6');
+round4_step( 0,'%edx','%eax','%ebx','%ecx','10','0x8f0ccc92','10');
+round4_step( 0,'%ecx','%edx','%eax','%ebx', '1','0xffeff47d','15');
+round4_step( 0,'%ebx','%ecx','%edx','%eax', '8','0x85845dd1','21');
+round4_step( 0,'%eax','%ebx','%ecx','%edx','15','0x6fa87e4f', '6');
+round4_step( 0,'%edx','%eax','%ebx','%ecx', '6','0xfe2ce6e0','10');
+round4_step( 0,'%ecx','%edx','%eax','%ebx','13','0xa3014314','15');
+round4_step( 0,'%ebx','%ecx','%edx','%eax', '4','0x4e0811a1','21');
+round4_step( 0,'%eax','%ebx','%ecx','%edx','11','0xf7537e82', '6');
+round4_step( 0,'%edx','%eax','%ebx','%ecx', '2','0xbd3af235','10');
+round4_step( 0,'%ecx','%edx','%eax','%ebx', '9','0x2ad7d2bb','15');
+round4_step( 1,'%ebx','%ecx','%edx','%eax', '0','0xeb86d391','21');
+$code .= <<EOF;
+	/ add old values of A, B, C, D
+	add	%r8d,	%eax
+	add	%r9d,	%ebx
+	add	%r14d,	%ecx
+	add	%r15d,	%edx
+
+	/ loop control
+	add	\$64,		%rsi		/ ptr += 64
+	cmp	%rdi,		%rsi		/ cmp end with ptr
+	jb	2b				/ jmp if ptr < end
+	/ END of loop over 64-byte blocks
+
+1:	pop	%rbp				/ restore ctx
+	mov	%eax,		0*4(%rbp)	/ ctx->A = A
+	mov	%ebx,		1*4(%rbp)	/ ctx->B = B
+	mov	%ecx,		2*4(%rbp)	/ ctx->C = C
+	mov	%edx,		3*4(%rbp)	/ ctx->D = D
+
+	pop	%r15
+	pop	%r14
+	pop	%r13
+	pop	%r12
+	pop	%rbx
+	pop	%rbp
+	ret
+	SET_SIZE(md5_block_asm_host_order)
+
+
+#else
+	/* LINTED */
+	/* Nothing to be linted in this file--it's pure assembly source. */
+#endif /* !lint && !__lint */
+EOF
+
+print $code;
--- old/usr/src/common/crypto/md5/md5.c	Wed Jan  2 14:48:54 2008
+++ new/usr/src/common/crypto/md5/md5.c	Wed Jan  2 14:48:54 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -9,7 +9,7 @@
  * below.
  */
 
-#pragma ident	"@(#)md5.c	1.27	07/04/10 SMI"
+#pragma ident	"@(#)md5.c	1.28	08/01/02 SMI"
 
 /*
  * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
@@ -51,8 +51,14 @@
 #endif /* _KERNEL */
 
 static void Encode(uint8_t *, const uint32_t *, size_t);
+
+#if !defined(__amd64)
 static void MD5Transform(uint32_t, uint32_t, uint32_t, uint32_t, MD5_CTX *,
     const uint8_t [64]);
+#else
+void md5_block_asm_host_order(MD5_CTX *ctx, const void *inpp,
+    unsigned int input_length_in_blocks);
+#endif /* !defined(__amd64) */
 
 static uint8_t PADDING[64] = { 0x80, /* all zeros */ };
 
@@ -243,6 +249,9 @@
 #ifdef	sun4v
 	uint32_t		old_asi;
 #endif	/* sun4v */
+#if defined(__amd64)
+	uint32_t		block_count;
+#endif /* !defined(__amd64) */
 	const unsigned char 	*input = (const unsigned char *)inpp;
 
 	/* compute (number of bytes computed so far) mod 64 */
@@ -250,7 +259,7 @@
 
 	/* update number of bits hashed into this MD5 computation so far */
 	if ((ctx->count[0] += (input_len << 3)) < (input_len << 3))
-	    ctx->count[1]++;
+		ctx->count[1]++;
 	ctx->count[1] += (input_len >> 29);
 
 	buf_len = 64 - buf_index;
@@ -282,18 +291,31 @@
 		if (buf_index) {
 			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
 
+#if !defined(__amd64)
 			MD5Transform(ctx->state[0], ctx->state[1],
 			    ctx->state[2], ctx->state[3], ctx,
 			    ctx->buf_un.buf8);
+#else
+			md5_block_asm_host_order(ctx, ctx->buf_un.buf8, 1);
+#endif /* !defined(__amd64) */
 
 			i = buf_len;
 		}
 
+#if !defined(__amd64)
 		for (; i + 63 < input_len; i += 64)
 			MD5Transform(ctx->state[0], ctx->state[1],
 			    ctx->state[2], ctx->state[3], ctx, &input[i]);
 
+#else
+		block_count = (input_len - i) >> 6;
+		if (block_count > 0) {
+			md5_block_asm_host_order(ctx, &input[i], block_count);
+			i += block_count << 6;
+		}
+#endif /* !defined(__amd64) */
 
+
 #ifdef sun4v
 		/*
 		 * Restore old %ASI value
@@ -367,6 +389,7 @@
 
 #endif	/* !_KERNEL */
 
+#if !defined(__amd64)
 /*
  * sparc register window optimization:
  *
@@ -635,6 +658,7 @@
 	x_0 = x_1  = x_2  = x_3  = x_4  = x_5  = x_6  = x_7 = x_8 = 0;
 	x_9 = x_10 = x_11 = x_12 = x_13 = x_14 = x_15 = 0;
 }
+#endif /* !defined(__amd64) */
 
 /*
  * Encode()
--- old/usr/src/lib/libmd/Makefile.com	Wed Jan  2 14:48:55 2008
+++ new/usr/src/lib/libmd/Makefile.com	Wed Jan  2 14:48:55 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)Makefile.com	1.2	06/07/29 SMI"
+# ident	"@(#)Makefile.com	1.3	08/01/02 SMI"
 #
 
 # $LIBRARY is set in lower makefiles so we can have platform and
@@ -31,7 +31,7 @@
 #LIBRARY= libmd.a
 VERS= .1
 
-OBJECTS= md4.o md5.o sha1.o sha2.o
+OBJECTS= md4.o md5.o $(MD5_PSR_OBJECTS) sha1.o sha2.o
 
 # Use $(SRC) to include makefiles rather than ../../ because the 
 # platform subdirs are one level deeper so it would be ../../../ for them
--- old/usr/src/lib/libmd/amd64/Makefile	Wed Jan  2 14:48:55 2008
+++ new/usr/src/lib/libmd/amd64/Makefile	Wed Jan  2 14:48:55 2008
@@ -19,15 +19,29 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)Makefile	1.1	06/03/28 SMI"
+# ident	"@(#)Makefile	1.2	08/01/02 SMI"
 #
 
 LIBRARY= libmd.a
 
+MD5_PSR_OBJECTS = md5_amd64.o
+
 include ../Makefile.com
 include $(SRC)/lib/Makefile.lib.64
 
+CLEANFILES += md5_amd64.s
+
+# This prevents <sys/asm_linkage.h> from including C source:
+AS_CPPFLAGS += -D_ASM
+
 install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
+
+md5_amd64.s: $(COMDIR)/md5/amd64/md5_amd64.pl
+	$(PERL) $? $@
+
+pics/md5_amd64.o: md5_amd64.s
+	$(COMPILE.s) -o $@ md5_amd64.s
+	$(POST_PROCESS_O)
--- old/usr/src/lib/pkcs11/Makefile.softtoken.amd64	Wed Jan  2 14:48:56 2008
+++ new/usr/src/lib/pkcs11/Makefile.softtoken.amd64	Wed Jan  2 14:48:56 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"@(#)Makefile.softtoken.amd64	1.3	05/06/08 SMI"
+# ident	"@(#)Makefile.softtoken.amd64	1.4	08/01/02 SMI"
 #
 # lib/pkcs11/Makefile.softtoken.amd64
 #
@@ -30,7 +29,7 @@
 # specific to amd64, common to pkcs11_softtoken and pkcs11_softtoken_extra
 
 AES_PSR_OBJECTS =
-ARCFOUR_PSR_OBJECTS =
+ARCFOUR_PSR_OBJECTS = arcfour_crypt_amd64.o
 DES_PSR_OBJECTS =
 RSA_PSR_OBJECTS =
 SHA1_PSR_OBJECTS =
@@ -52,6 +51,10 @@
 
 LINTFLAGS64 += $(BIGNUM_CFG)
 
+pics/arcfour_crypt_amd64.o: $(ARCFOURDIR)/amd64/arcfour_crypt_amd64.s
+	$(COMPILE.s) -o $@ $(AS_BIGPICFLAGS) \
+		$(ARCFOURDIR)/amd64/arcfour_crypt_amd64.s
+	$(POST_PROCESS_O)
 
 pics/%.o: $(BIGNUMDIR)/$(MACH64)/%.c
 	$(COMPILE.c) -o $@ $(C_BIGPICFLAGS) $(BIGNUM_CFG) $<
--- old/usr/src/uts/common/sys/crypto/common.h	Wed Jan  2 14:48:56 2008
+++ new/usr/src/uts/common/sys/crypto/common.h	Wed Jan  2 14:48:56 2008
@@ -19,7 +19,7 @@
  * 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.
  */
 
@@ -26,7 +26,7 @@
 #ifndef _SYS_CRYPTO_COMMON_H
 #define	_SYS_CRYPTO_COMMON_H
 
-#pragma ident	"@(#)common.h	1.24	07/12/10 SMI"
+#pragma ident	"@(#)common.h	1.25	08/01/02 SMI"
 
 /*
  * Header file for the common data structures of the cryptographic framework
@@ -185,13 +185,18 @@
 #define	SUN_CKM_ECDSA			"CKM_ECDSA"
 
 /* Shared operation context format for CKM_RC4 */
+#if defined(__amd64)
+typedef uint64_t arcfour_key_int_t;
+#else
+typedef uchar_t arcfour_key_int_t;
+#endif /* __amd64 */
+
 typedef struct {
-	uchar_t arr[256];
-	uchar_t i, j;
+	arcfour_key_int_t arr[256];
+	arcfour_key_int_t i, j;
 	uint64_t pad;		/* For 64-bit alignment */
 } arcfour_state_t;
 
-
 /* Data arguments of cryptographic operations */
 
 typedef enum crypto_data_format {
--- old/usr/src/uts/intel/aes/Makefile	Wed Jan  2 14:48:57 2008
+++ new/usr/src/uts/intel/aes/Makefile	Wed Jan  2 14:48:57 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.7	06/11/02 SMI"
+#ident	"@(#)Makefile	1.8	08/01/02 SMI"
 #
 #	This makefile drives the production of the AES KEF provider.
 #
@@ -33,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/aes
+COM_DIR = $(COMMONBASE)/crypto/aes
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/intel/aes256/Makefile	Wed Jan  2 14:48:58 2008
+++ new/usr/src/uts/intel/aes256/Makefile	Wed Jan  2 14:48:58 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	05/06/08 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the AES KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/aes
+COM_DIR = $(COMMONBASE)/crypto/aes
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/intel/arcfour/Makefile	Wed Jan  2 14:48:58 2008
+++ new/usr/src/uts/intel/arcfour/Makefile	Wed Jan  2 14:48:58 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	06/11/02 SMI"
+# ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the ARCFOUR KEF provider.
 #
@@ -33,14 +33,17 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
 #
 MODULE		= arcfour
-OBJECTS		= $(ARCFOURPROV_OBJS:%=$(OBJS_DIR)/%)
 LINTS		= $(ARCFOURPROV_OBJS:%.o=$(LINTS_DIR)/%.ln)
+ARCFOURPROV_OBJS_32 =
+ARCFOURPROV_OBJS_64 = arcfour_crypt_amd64.o
+ARCFOURPROV_OBJS += $(ARCFOURPROV_OBJS_$(CLASS))
+OBJECTS		= $(ARCFOURPROV_OBJS:%=$(OBJS_DIR)/%)
 ROOTMODULE	= $(ROOT_CRYPTO_DIR)/$(MODULE)
 
 #
@@ -95,3 +98,11 @@
 #	Include common targets.
 #
 include $(UTSBASE)/intel/Makefile.targ
+
+$(OBJS_DIR)/arcfour_crypt_amd64.o: $(COM_DIR)/amd64/arcfour_crypt_amd64.s
+	$(COMPILE.s) -o $@ $(COM_DIR)/amd64/arcfour_crypt_amd64.s
+	$(POST_PROCESS_O)
+
+$(OBJS_DIR)/arcfour_crypt_amd64.ln: $(COM_DIR)/amd64/arcfour_crypt_amd64.s
+	@($(LHEAD) $(LINT.c) $(COM_DIR)/amd64/arcfour_crypt_amd64.s $(LTAIL))
+
--- old/usr/src/uts/intel/arcfour2048/Makefile	Wed Jan  2 14:48:59 2008
+++ new/usr/src/uts/intel/arcfour2048/Makefile	Wed Jan  2 14:48:59 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	05/06/08 SMI"
+# ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the ARCFOUR KEF provider.
 #
@@ -34,14 +33,17 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
 #
 MODULE		= arcfour2048
-OBJECTS		= $(ARCFOURPROV_OBJS:%=$(OBJS_DIR)/%)
 LINTS		= $(ARCFOURPROV_OBJS:%.o=$(LINTS_DIR)/%.ln)
+ARCFOURPROV_OBJS_32 =
+ARCFOURPROV_OBJS_64 = arcfour_crypt_amd64.o
+ARCFOURPROV_OBJS += $(ARCFOURPROV_OBJS_$(CLASS))
+OBJECTS		= $(ARCFOURPROV_OBJS:%=$(OBJS_DIR)/%)
 ROOTMODULE	= $(ROOT_CRYPTO_DIR)/$(MODULE)
 
 #
@@ -89,3 +91,10 @@
 #	Include common targets.
 #
 include $(UTSBASE)/intel/Makefile.targ
+
+$(OBJS_DIR)/arcfour_crypt_amd64.o: $(COM_DIR)/amd64/arcfour_crypt_amd64.s
+	$(COMPILE.s) -o $@ $(COM_DIR)/amd64/arcfour_crypt_amd64.s
+	$(POST_PROCESS_O)
+
+$(OBJS_DIR)/arcfour_crypt_amd64.ln: $(COM_DIR)/amd64/arcfour_crypt_amd64.s
+	@($(LHEAD) $(LINT.s) $(COM_DIR)/amd64/arcfour_crypt_amd64.s $(LTAIL))
--- old/usr/src/uts/intel/blowfish/Makefile	Wed Jan  2 14:48:59 2008
+++ new/usr/src/uts/intel/blowfish/Makefile	Wed Jan  2 14:48:59 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.7	06/11/02 SMI"
+#ident	"@(#)Makefile	1.8	08/01/02 SMI"
 #
 #	This makefile drives the production of the Blowfish KEF provider.
 #
@@ -33,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/blowfish
+COM_DIR = $(COMMONBASE)/crypto/blowfish
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/intel/blowfish448/Makefile	Wed Jan  2 14:49:00 2008
+++ new/usr/src/uts/intel/blowfish448/Makefile	Wed Jan  2 14:49:00 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	05/06/08 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the Blowfish KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/blowfish
+COM_DIR = $(COMMONBASE)/crypto/blowfish
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/intel/des/Makefile	Wed Jan  2 14:49:00 2008
+++ new/usr/src/uts/intel/des/Makefile	Wed Jan  2 14:49:00 2008
@@ -21,10 +21,10 @@
 #
 # uts/intel/des/Makefile
 #
-# 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.14	07/03/11 SMI"
+#ident	"@(#)Makefile	1.15	08/01/02 SMI"
 #
 #	This makefile drives the production of the des crypto kernel module.
 #
@@ -35,7 +35,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/des
+COM_DIR = $(COMMONBASE)/crypto/des
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/intel/md5/Makefile	Wed Jan  2 14:49:01 2008
+++ new/usr/src/uts/intel/md5/Makefile	Wed Jan  2 14:49:01 2008
@@ -21,10 +21,10 @@
 #
 # uts/intel/md5/Makefile
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.9	06/11/02 SMI"
+#ident	"@(#)Makefile	1.10	08/01/02 SMI"
 #
 #	This makefile drives the production of the md5 crypto kernel module.
 #
@@ -35,13 +35,17 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
+COMDIR = $(COMMONBASE)/crypto/md5
 
 #
 #	Define the module and object file sets.
 #
 MODULE		= md5
-OBJECTS		= $(MD5_OBJS:%=$(OBJS_DIR)/%)
 LINTS		= $(MD5_OBJS:%.o=$(LINTS_DIR)/%.ln)
+MD5_OBJS_32	=
+MD5_OBJS_64	= md5_amd64.o
+MD5_OBJS	+= $(MD5_OBJS_$(CLASS))
+OBJECTS		= $(MD5_OBJS:%=$(OBJS_DIR)/%)
 ROOTMODULE	= $(ROOT_CRYPTO_DIR)/$(MODULE)
 ROOTLINK	= $(ROOT_MISC_DIR)/$(MODULE)
 
@@ -53,8 +57,8 @@
 #
 #	Override defaults
 #
+CLEANFILES += md5_amd64.s
 
-
 #
 #	Define targets
 #
@@ -103,3 +107,13 @@
 #	Include common targets.
 #
 include $(UTSBASE)/intel/Makefile.targ
+
+md5_amd64.s: $(COMDIR)/amd64/md5_amd64.pl
+	$(PERL) $? $@
+
+$(OBJS_DIR)/md5_amd64.o: md5_amd64.s
+	$(COMPILE.s) -o $@ md5_amd64.s
+	$(POST_PROCESS_O)
+
+$(OBJS_DIR)/md5_amd64.ln: md5_amd64.s
+	@($(LHEAD) $(LINT.c) md5_amd64.s $(LTAIL))
--- old/usr/src/uts/intel/rsa/Makefile	Wed Jan  2 14:49:01 2008
+++ new/usr/src/uts/intel/rsa/Makefile	Wed Jan  2 14:49:01 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.11	06/11/02 SMI"
+#ident	"@(#)Makefile	1.12	08/01/02 SMI"
 #
 #	This makefile drives the production of the RSA KEF provider.
 #
@@ -33,8 +33,8 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM1_DIR = $(SRC)/common/bignum
-COM2_DIR = $(SRC)/common/crypto/rsa
+COM1_DIR = $(COMMONBASE)/bignum
+COM2_DIR = $(COMMONBASE)/crypto/rsa
 
 #
 #	Define the module and object file sets.
@@ -106,6 +106,6 @@
 #
 include $(UTSBASE)/intel/Makefile.targ
 
-BIGNUMDIR = $(SRC)/common/bignum
+BIGNUMDIR = $(COMMONBASE)/bignum
 
 include Makefile.$(CLASS)
--- old/usr/src/uts/sparc/aes/Makefile	Wed Jan  2 14:49:02 2008
+++ new/usr/src/uts/sparc/aes/Makefile	Wed Jan  2 14:49:02 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	06/11/02 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the AES KEF provider.
 #
@@ -33,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/aes
+COM_DIR = $(COMMONBASE)/crypto/aes
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/aes256/Makefile	Wed Jan  2 14:49:02 2008
+++ new/usr/src/uts/sparc/aes256/Makefile	Wed Jan  2 14:49:02 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	05/06/08 SMI"
+#ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the AES KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/aes
+COM_DIR = $(COMMONBASE)/crypto/aes
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/arcfour/Makefile	Wed Jan  2 14:49:03 2008
+++ new/usr/src/uts/sparc/arcfour/Makefile	Wed Jan  2 14:49:03 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	06/11/02 SMI"
+#ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the ARCFOUR KEF provider.
 #
@@ -33,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/arcfour2048/Makefile	Wed Jan  2 14:49:03 2008
+++ new/usr/src/uts/sparc/arcfour2048/Makefile	Wed Jan  2 14:49:03 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.4	05/06/08 SMI"
+#ident	"@(#)Makefile	1.5	08/01/02 SMI"
 #
 #	This makefile drives the production of the ARCFOUR KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/blowfish/Makefile	Wed Jan  2 14:49:04 2008
+++ new/usr/src/uts/sparc/blowfish/Makefile	Wed Jan  2 14:49:04 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	06/11/02 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the blowfish KEF provider.
 #
@@ -33,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/blowfish
+COM_DIR = $(COMMONBASE)/crypto/blowfish
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/blowfish448/Makefile	Wed Jan  2 14:49:05 2008
+++ new/usr/src/uts/sparc/blowfish448/Makefile	Wed Jan  2 14:49:05 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	05/06/08 SMI"
+#ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the blowfish KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/blowfish
+COM_DIR = $(COMMONBASE)/crypto/blowfish
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/des/Makefile	Wed Jan  2 14:49:05 2008
+++ new/usr/src/uts/sparc/des/Makefile	Wed Jan  2 14:49:05 2008
@@ -21,10 +21,10 @@
 #
 # uts/sparc/des/Makefile
 #
-# 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.14	07/03/11 SMI"
+#ident	"@(#)Makefile	1.15	08/01/02 SMI"
 #
 #	This makefile drives the production of the des crypto kernel module.
 #
@@ -35,7 +35,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/des
+COM_DIR = $(COMMONBASE)/crypto/des
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sparc/rsa/Makefile	Wed Jan  2 14:49:06 2008
+++ new/usr/src/uts/sparc/rsa/Makefile	Wed Jan  2 14:49:06 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.9	06/11/02 SMI"
+#ident	"@(#)Makefile	1.10	08/01/02 SMI"
 #
 #	This makefile drives the production of the RSA KEF provider.
 #
@@ -33,8 +33,8 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM1_DIR = $(SRC)/common/bignum
-COM2_DIR = $(SRC)/common/crypto/rsa
+COM1_DIR = $(COMMONBASE)/bignum
+COM2_DIR = $(COMMONBASE)/crypto/rsa
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4u/aes/Makefile	Wed Jan  2 14:49:06 2008
+++ new/usr/src/uts/sun4u/aes/Makefile	Wed Jan  2 14:49:06 2008
@@ -21,10 +21,10 @@
 #
 # uts/sun4u/aes/Makefile
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	06/11/02 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the aes kernel module.
 #
@@ -35,7 +35,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/aes
+COM_DIR = $(COMMONBASE)/crypto/aes
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4u/aes256/Makefile	Wed Jan  2 14:49:07 2008
+++ new/usr/src/uts/sun4u/aes256/Makefile	Wed Jan  2 14:49:07 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	05/06/08 SMI"
+#ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the AES KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/aes
+COM_DIR = $(COMMONBASE)/crypto/aes
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4u/arcfour/Makefile	Wed Jan  2 14:49:07 2008
+++ new/usr/src/uts/sun4u/arcfour/Makefile	Wed Jan  2 14:49:07 2008
@@ -21,10 +21,10 @@
 #
 # uts/sun4u/arcfour/Makefile
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	06/11/02 SMI"
+#ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the arcfour kernel module.
 #
@@ -35,7 +35,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4u/arcfour2048/Makefile	Wed Jan  2 14:49:08 2008
+++ new/usr/src/uts/sun4u/arcfour2048/Makefile	Wed Jan  2 14:49:08 2008
@@ -2,9 +2,8 @@
 # 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.
+# 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.
@@ -20,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.4	05/06/08 SMI"
+#ident	"@(#)Makefile	1.5	08/01/02 SMI"
 #
 #	This makefile drives the production of the arcfour KEF provider.
 #
@@ -34,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4u/des/Makefile	Wed Jan  2 14:49:08 2008
+++ new/usr/src/uts/sun4u/des/Makefile	Wed Jan  2 14:49:08 2008
@@ -21,10 +21,10 @@
 #
 # uts/sun4u/des/Makefile
 #
-# 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.6	07/03/13 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the des kernel module.
 #
@@ -35,7 +35,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/des
+COM_DIR = $(COMMONBASE)/crypto/des
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4u/rsa/Makefile	Wed Jan  2 14:49:09 2008
+++ new/usr/src/uts/sun4u/rsa/Makefile	Wed Jan  2 14:49:09 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.4	06/11/02 SMI"
+#ident	"@(#)Makefile	1.5	08/01/02 SMI"
 #
 #	This makefile drives the production of the RSA KEF provider.
 #
@@ -33,8 +33,8 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM1_DIR = $(SRC)/common/bignum
-COM2_DIR = $(SRC)/common/crypto/rsa
+COM1_DIR = $(COMMONBASE)/bignum
+COM2_DIR = $(COMMONBASE)/crypto/rsa
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4v/arcfour/Makefile	Wed Jan  2 14:49:10 2008
+++ new/usr/src/uts/sun4v/arcfour/Makefile	Wed Jan  2 14:49:09 2008
@@ -21,10 +21,10 @@
 #
 # uts/sun4v/arcfour/Makefile
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.6	06/11/02 SMI"
+#ident	"@(#)Makefile	1.7	08/01/02 SMI"
 #
 #	This makefile drives the production of the arcfour kernel module.
 #
@@ -35,7 +35,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
--- old/usr/src/uts/sun4v/arcfour2048/Makefile	Wed Jan  2 14:49:10 2008
+++ new/usr/src/uts/sun4v/arcfour2048/Makefile	Wed Jan  2 14:49:10 2008
@@ -19,10 +19,10 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"@(#)Makefile	1.5	06/08/15 SMI"
+#ident	"@(#)Makefile	1.6	08/01/02 SMI"
 #
 #	This makefile drives the production of the arcfour KEF provider.
 #
@@ -33,7 +33,7 @@
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
 #
 UTSBASE	= ../..
-COM_DIR = $(SRC)/common/crypto/arcfour
+COM_DIR = $(COMMONBASE)/crypto/arcfour
 
 #
 #	Define the module and object file sets.
