summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorda73024 <none@none>2008-01-03 14:03:27 -0800
committerda73024 <none@none>2008-01-03 14:03:27 -0800
commit160abee025ef30c34521b981edd40ffcaab560aa (patch)
treed339b6785d5e83db93d24d4ac4c56f0ae34fcc99
parent44d788f4c8bf218e9e993dd88f3a674bb11f8eee (diff)
downloadillumos-gate-160abee025ef30c34521b981edd40ffcaab560aa.tar.gz
5072961 Need an optimized MD5 implementation for amd64
6189743 Need an ARCFOUR implementation optimized for AMD64 6617458 amd64/rsa is a false positive reported by wsdiff
-rw-r--r--usr/src/common/crypto/arcfour/amd64/arcfour_crypt_amd64.s165
-rw-r--r--usr/src/common/crypto/arcfour/arcfour_crypt.c19
-rw-r--r--usr/src/common/crypto/md5/amd64/md5_amd64.pl352
-rw-r--r--usr/src/common/crypto/md5/md5.c28
-rw-r--r--usr/src/lib/libmd/Makefile.com4
-rw-r--r--usr/src/lib/libmd/amd64/Makefile16
-rw-r--r--usr/src/lib/pkcs11/Makefile.softtoken.amd6413
-rw-r--r--usr/src/uts/common/sys/crypto/common.h13
-rw-r--r--usr/src/uts/intel/aes/Makefile4
-rw-r--r--usr/src/uts/intel/aes256/Makefile9
-rw-r--r--usr/src/uts/intel/arcfour/Makefile19
-rw-r--r--usr/src/uts/intel/arcfour2048/Makefile23
-rw-r--r--usr/src/uts/intel/blowfish/Makefile4
-rw-r--r--usr/src/uts/intel/blowfish448/Makefile9
-rw-r--r--usr/src/uts/intel/des/Makefile4
-rw-r--r--usr/src/uts/intel/md5/Makefile20
-rw-r--r--usr/src/uts/intel/rsa/Makefile8
-rw-r--r--usr/src/uts/sparc/aes/Makefile4
-rw-r--r--usr/src/uts/sparc/aes256/Makefile9
-rw-r--r--usr/src/uts/sparc/arcfour/Makefile4
-rw-r--r--usr/src/uts/sparc/arcfour2048/Makefile9
-rw-r--r--usr/src/uts/sparc/blowfish/Makefile4
-rw-r--r--usr/src/uts/sparc/blowfish448/Makefile9
-rw-r--r--usr/src/uts/sparc/des/Makefile4
-rw-r--r--usr/src/uts/sparc/rsa/Makefile6
-rw-r--r--usr/src/uts/sun4u/aes/Makefile4
-rw-r--r--usr/src/uts/sun4u/aes256/Makefile9
-rw-r--r--usr/src/uts/sun4u/arcfour/Makefile4
-rw-r--r--usr/src/uts/sun4u/arcfour2048/Makefile9
-rw-r--r--usr/src/uts/sun4u/des/Makefile4
-rw-r--r--usr/src/uts/sun4u/rsa/Makefile6
-rw-r--r--usr/src/uts/sun4v/arcfour/Makefile4
-rw-r--r--usr/src/uts/sun4v/arcfour2048/Makefile4
33 files changed, 701 insertions, 102 deletions
diff --git a/usr/src/common/crypto/arcfour/amd64/arcfour_crypt_amd64.s b/usr/src/common/crypto/arcfour/amd64/arcfour_crypt_amd64.s
new file mode 100644
index 0000000000..660ef0a896
--- /dev/null
+++ b/usr/src/common/crypto/arcfour/amd64/arcfour_crypt_amd64.s
@@ -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 "%Z%%M% %I% %E% 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 */
diff --git a/usr/src/common/crypto/arcfour/arcfour_crypt.c b/usr/src/common/crypto/arcfour/arcfour_crypt.c
index daa57259de..5660246590 100644
--- a/usr/src/common/crypto/arcfour/arcfour_crypt.c
+++ b/usr/src/common/crypto/arcfour/arcfour_crypt.c
@@ -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,7 +19,7 @@
* 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.
*/
@@ -28,6 +27,14 @@
#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 @@ arcfour_key_init(ARCFour_key *key, uchar_t *keyval, int keyvallen)
}
+#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 @@ arcfour_crypt(ARCFour_key *key, uchar_t *in, uchar_t *out, size_t len)
/* EXPORT DELETE END */
}
+#endif /* !USE_PSR_VERSION_OF_ARCFOUR_CRYPT */
diff --git a/usr/src/common/crypto/md5/amd64/md5_amd64.pl b/usr/src/common/crypto/md5/amd64/md5_amd64.pl
new file mode 100644
index 0000000000..09300bc388
--- /dev/null
+++ b/usr/src/common/crypto/md5/amd64/md5_amd64.pl
@@ -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 "%Z%%M% %I% %E% 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;
diff --git a/usr/src/common/crypto/md5/md5.c b/usr/src/common/crypto/md5/md5.c
index 528a4e1c6a..0f23a08133 100644
--- a/usr/src/common/crypto/md5/md5.c
+++ b/usr/src/common/crypto/md5/md5.c
@@ -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.
*/
@@ -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 @@ MD5Update(MD5_CTX *ctx, const void *inpp, unsigned int input_len)
#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 @@ MD5Update(MD5_CTX *ctx, const void *inpp, unsigned int input_len)
/* 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,17 +291,30 @@ MD5Update(MD5_CTX *ctx, const void *inpp, unsigned int input_len)
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
/*
@@ -367,6 +389,7 @@ md5_calc(unsigned char *output, unsigned char *input, unsigned int inlen)
#endif /* !_KERNEL */
+#if !defined(__amd64)
/*
* sparc register window optimization:
*
@@ -635,6 +658,7 @@ MD5Transform(uint32_t a, uint32_t b, uint32_t c, uint32_t d,
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()
diff --git a/usr/src/lib/libmd/Makefile.com b/usr/src/lib/libmd/Makefile.com
index a32420fa42..66988ae31f 100644
--- a/usr/src/lib/libmd/Makefile.com
+++ b/usr/src/lib/libmd/Makefile.com
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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
diff --git a/usr/src/lib/libmd/amd64/Makefile b/usr/src/lib/libmd/amd64/Makefile
index 217f07b1d8..ba2f71ea21 100644
--- a/usr/src/lib/libmd/amd64/Makefile
+++ b/usr/src/lib/libmd/amd64/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -27,7 +27,21 @@
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)
diff --git a/usr/src/lib/pkcs11/Makefile.softtoken.amd64 b/usr/src/lib/pkcs11/Makefile.softtoken.amd64
index 0bb7ac7aff..f77bb0c4af 100644
--- a/usr/src/lib/pkcs11/Makefile.softtoken.amd64
+++ b/usr/src/lib/pkcs11/Makefile.softtoken.amd64
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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 @@ $(BIGNUM_PSR_PICS) := CFLAGS += $(C_BIGPICFLAGS) $(BIGNUM_CFG)
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) $<
diff --git a/usr/src/uts/common/sys/crypto/common.h b/usr/src/uts/common/sys/crypto/common.h
index 917bbf9b36..87e17d8f00 100644
--- a/usr/src/uts/common/sys/crypto/common.h
+++ b/usr/src/uts/common/sys/crypto/common.h
@@ -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.
*/
@@ -185,13 +185,18 @@ typedef uint32_t crypto_keysize_unit_t;
#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 {
diff --git a/usr/src/uts/intel/aes/Makefile b/usr/src/uts/intel/aes/Makefile
index 5badc87e8f..2cc82ac389 100644
--- a/usr/src/uts/intel/aes/Makefile
+++ b/usr/src/uts/intel/aes/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/intel/aes256/Makefile b/usr/src/uts/intel/aes256/Makefile
index bc22132b13..b2400eefca 100644
--- a/usr/src/uts/intel/aes256/Makefile
+++ b/usr/src/uts/intel/aes256/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/intel/arcfour/Makefile b/usr/src/uts/intel/arcfour/Makefile
index 2a504c5e63..15bd43c85e 100644
--- a/usr/src/uts/intel/arcfour/Makefile
+++ b/usr/src/uts/intel/arcfour/Makefile
@@ -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 "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% 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 @@ install: $(INSTALL_DEPS)
# 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))
+
diff --git a/usr/src/uts/intel/arcfour2048/Makefile b/usr/src/uts/intel/arcfour2048/Makefile
index 076fdc962d..a8798c2f2e 100644
--- a/usr/src/uts/intel/arcfour2048/Makefile
+++ b/usr/src/uts/intel/arcfour2048/Makefile
@@ -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 "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% 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 @@ install: $(INSTALL_DEPS)
# 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))
diff --git a/usr/src/uts/intel/blowfish/Makefile b/usr/src/uts/intel/blowfish/Makefile
index f3f0cd34d9..8e88cf57af 100644
--- a/usr/src/uts/intel/blowfish/Makefile
+++ b/usr/src/uts/intel/blowfish/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/intel/blowfish448/Makefile b/usr/src/uts/intel/blowfish448/Makefile
index 5355cf762f..0855f104ec 100644
--- a/usr/src/uts/intel/blowfish448/Makefile
+++ b/usr/src/uts/intel/blowfish448/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/intel/des/Makefile b/usr/src/uts/intel/des/Makefile
index 866d515ddf..f330fb2a66 100644
--- a/usr/src/uts/intel/des/Makefile
+++ b/usr/src/uts/intel/des/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/intel/md5/Makefile b/usr/src/uts/intel/md5/Makefile
index c955d4f9f8..a87d5972ad 100644
--- a/usr/src/uts/intel/md5/Makefile
+++ b/usr/src/uts/intel/md5/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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,7 +57,7 @@ include $(UTSBASE)/intel/Makefile.intel
#
# Override defaults
#
-
+CLEANFILES += md5_amd64.s
#
# Define targets
@@ -103,3 +107,13 @@ $(ROOTLINK): $(ROOT_MISC_DIR) $(ROOTMODULE)
# 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))
diff --git a/usr/src/uts/intel/rsa/Makefile b/usr/src/uts/intel/rsa/Makefile
index b52048ed54..82bd1d36ce 100644
--- a/usr/src/uts/intel/rsa/Makefile
+++ b/usr/src/uts/intel/rsa/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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 @@ install: $(INSTALL_DEPS)
#
include $(UTSBASE)/intel/Makefile.targ
-BIGNUMDIR = $(SRC)/common/bignum
+BIGNUMDIR = $(COMMONBASE)/bignum
include Makefile.$(CLASS)
diff --git a/usr/src/uts/sparc/aes/Makefile b/usr/src/uts/sparc/aes/Makefile
index deb124608a..a62867b7a9 100644
--- a/usr/src/uts/sparc/aes/Makefile
+++ b/usr/src/uts/sparc/aes/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/aes256/Makefile b/usr/src/uts/sparc/aes256/Makefile
index e841896250..d765d1ddd3 100644
--- a/usr/src/uts/sparc/aes256/Makefile
+++ b/usr/src/uts/sparc/aes256/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/arcfour/Makefile b/usr/src/uts/sparc/arcfour/Makefile
index 14fb89d7e1..5ca76fd7c3 100644
--- a/usr/src/uts/sparc/arcfour/Makefile
+++ b/usr/src/uts/sparc/arcfour/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/arcfour2048/Makefile b/usr/src/uts/sparc/arcfour2048/Makefile
index ffc5767f08..282da19dfd 100644
--- a/usr/src/uts/sparc/arcfour2048/Makefile
+++ b/usr/src/uts/sparc/arcfour2048/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/blowfish/Makefile b/usr/src/uts/sparc/blowfish/Makefile
index ba235b9d72..3f71dc127e 100644
--- a/usr/src/uts/sparc/blowfish/Makefile
+++ b/usr/src/uts/sparc/blowfish/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/blowfish448/Makefile b/usr/src/uts/sparc/blowfish448/Makefile
index 77a2e69433..23a94c8ba6 100644
--- a/usr/src/uts/sparc/blowfish448/Makefile
+++ b/usr/src/uts/sparc/blowfish448/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/des/Makefile b/usr/src/uts/sparc/des/Makefile
index 4f6f504bea..b1427cc78c 100644
--- a/usr/src/uts/sparc/des/Makefile
+++ b/usr/src/uts/sparc/des/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sparc/rsa/Makefile b/usr/src/uts/sparc/rsa/Makefile
index 74b44229f8..de405af542 100644
--- a/usr/src/uts/sparc/rsa/Makefile
+++ b/usr/src/uts/sparc/rsa/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4u/aes/Makefile b/usr/src/uts/sun4u/aes/Makefile
index 12e97f2e62..ae4686793c 100644
--- a/usr/src/uts/sun4u/aes/Makefile
+++ b/usr/src/uts/sun4u/aes/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4u/aes256/Makefile b/usr/src/uts/sun4u/aes256/Makefile
index dd7a4fc81a..4811efd19e 100644
--- a/usr/src/uts/sun4u/aes256/Makefile
+++ b/usr/src/uts/sun4u/aes256/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4u/arcfour/Makefile b/usr/src/uts/sun4u/arcfour/Makefile
index c8bf4e52fd..62fe6f2733 100644
--- a/usr/src/uts/sun4u/arcfour/Makefile
+++ b/usr/src/uts/sun4u/arcfour/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4u/arcfour2048/Makefile b/usr/src/uts/sun4u/arcfour2048/Makefile
index 2a4ea30735..476d43a6eb 100644
--- a/usr/src/uts/sun4u/arcfour2048/Makefile
+++ b/usr/src/uts/sun4u/arcfour2048/Makefile
@@ -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,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4u/des/Makefile b/usr/src/uts/sun4u/des/Makefile
index aa6ce07a38..fa5f4881ad 100644
--- a/usr/src/uts/sun4u/des/Makefile
+++ b/usr/src/uts/sun4u/des/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4u/rsa/Makefile b/usr/src/uts/sun4u/rsa/Makefile
index 075b407732..f30d9db276 100644
--- a/usr/src/uts/sun4u/rsa/Makefile
+++ b/usr/src/uts/sun4u/rsa/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4v/arcfour/Makefile b/usr/src/uts/sun4v/arcfour/Makefile
index 2111424952..18f3b59868 100644
--- a/usr/src/uts/sun4v/arcfour/Makefile
+++ b/usr/src/uts/sun4v/arcfour/Makefile
@@ -21,7 +21,7 @@
#
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.
diff --git a/usr/src/uts/sun4v/arcfour2048/Makefile b/usr/src/uts/sun4v/arcfour2048/Makefile
index 3cd7b549d1..57be7ca3ae 100644
--- a/usr/src/uts/sun4v/arcfour2048/Makefile
+++ b/usr/src/uts/sun4v/arcfour2048/Makefile
@@ -19,7 +19,7 @@
# 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 "%Z%%M% %I% %E% SMI"
@@ -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.