changeset 1694:d5b31941a4a5

PSARC 2005/426 libmd - message digest library 4795652 /usr/include/security should be listed in Targetdirs 4937832 x86 optimization of SHA-1 6188861 provide libmd - message digest library
author darrenm
date Tue, 28 Mar 2006 08:45:30 -0800
parents c9671580f19b
children 830625bc1d6f
files deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/md4.c deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/md4.h deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.c deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.h deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1_consts.h deleted_files/usr/src/common/net/wanboot/crypt/sha1.c deleted_files/usr/src/lib/libmd5/spec/Makefile deleted_files/usr/src/lib/libmd5/spec/Makefile.targ deleted_files/usr/src/lib/libmd5/spec/amd64/Makefile deleted_files/usr/src/lib/libmd5/spec/i386/Makefile deleted_files/usr/src/lib/libmd5/spec/md5.spec deleted_files/usr/src/lib/libmd5/spec/sparc/Makefile deleted_files/usr/src/lib/libmd5/spec/sparcv9/Makefile deleted_files/usr/src/lib/libmd5/spec/versions deleted_files/usr/src/lib/libmd5_psr/Makefile deleted_files/usr/src/lib/libmd5_psr/Makefile.com deleted_files/usr/src/lib/libmd5_psr/Makefile.targ deleted_files/usr/src/lib/libmd5_psr/inc.flg deleted_files/usr/src/lib/libmd5_psr/sparc/Makefile deleted_files/usr/src/lib/libmd5_psr/sparc/sun4u/Makefile deleted_files/usr/src/lib/libmd5_psr/sparcv9/Makefile deleted_files/usr/src/lib/libmd5_psr/sparcv9/sun4u/Makefile deleted_files/usr/src/lib/libmd5_psr/spec/Makefile deleted_files/usr/src/lib/libmd5_psr/spec/Makefile.com deleted_files/usr/src/lib/libmd5_psr/spec/sparc/Makefile deleted_files/usr/src/lib/libmd5_psr/spec/sparc/sun4u/Makefile deleted_files/usr/src/lib/libmd5_psr/spec/sparc/versions-sun4u deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/Makefile deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/md_psr-sun4u.spec deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/sun4u/Makefile deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/versions-sun4u deleted_files/usr/src/lib/libmd_psr/spec/sparc/md_psr-sun4u.spec usr/src/Makefile.lint usr/src/Targetdirs usr/src/cmd/bart/Makefile usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile usr/src/cmd/cmd-inet/usr.bin/pppd/md4.c usr/src/cmd/cmd-inet/usr.bin/pppd/md4.h usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.c usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.h usr/src/cmd/cmd-inet/usr.bin/pppd/sha1_consts.h usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile usr/src/cmd/ipf/tools/Makefile.tools usr/src/cmd/volmgt/vold/Makefile usr/src/cmd/volmgt/vold/md4.h usr/src/cmd/volmgt/vold/vold_md4.c usr/src/cmd/xntpd/Makefile.cmd usr/src/common/crypto/md4/md4.c usr/src/common/crypto/md5/md5.c usr/src/common/crypto/md5/md5_byteswap.h usr/src/common/crypto/sha1/sha1.c usr/src/common/crypto/sha2/sha2.c usr/src/common/net/wanboot/crypt/sha1.c usr/src/head/Makefile usr/src/head/md5.h usr/src/lib/Makefile usr/src/lib/crypt_modules/bsdmd5/Makefile.com usr/src/lib/crypt_modules/sunmd5/Makefile.com usr/src/lib/libbsm/Makefile.com usr/src/lib/libinetsvc/Makefile.com usr/src/lib/libldap4/Makefile.com usr/src/lib/libldap5/Makefile.com usr/src/lib/libmd/Makefile usr/src/lib/libmd/Makefile.com usr/src/lib/libmd/amd64/Makefile usr/src/lib/libmd/common/llib-lmd usr/src/lib/libmd/common/md4.h usr/src/lib/libmd/common/md5.h usr/src/lib/libmd/common/sha1.h usr/src/lib/libmd/common/sha2.h usr/src/lib/libmd/i386/Makefile usr/src/lib/libmd/inc.flg usr/src/lib/libmd/sparc/Makefile usr/src/lib/libmd/sparcv9/Makefile usr/src/lib/libmd/spec/Makefile usr/src/lib/libmd/spec/Makefile.targ usr/src/lib/libmd/spec/amd64/Makefile usr/src/lib/libmd/spec/i386/Makefile usr/src/lib/libmd/spec/md.spec usr/src/lib/libmd/spec/sparc/Makefile usr/src/lib/libmd/spec/sparcv9/Makefile usr/src/lib/libmd/spec/versions usr/src/lib/libmd/sun4u/Makefile usr/src/lib/libmd/sun4u/Makefile.com usr/src/lib/libmd/sun4u/Makefile.links usr/src/lib/libmd/sun4u/sparc/Makefile usr/src/lib/libmd/sun4u/sparc/mapfile usr/src/lib/libmd/sun4u/sparcv9/Makefile usr/src/lib/libmd/sun4u/sparcv9/mapfile usr/src/lib/libmd/sun4v/Makefile usr/src/lib/libmd/sun4v/Makefile.com usr/src/lib/libmd/sun4v/Makefile.links usr/src/lib/libmd/sun4v/sparc/Makefile usr/src/lib/libmd/sun4v/sparc/mapfile usr/src/lib/libmd/sun4v/sparcv9/Makefile usr/src/lib/libmd/sun4v/sparcv9/mapfile usr/src/lib/libmd5/Makefile usr/src/lib/libmd5/Makefile.com usr/src/lib/libmd5/amd64/Makefile usr/src/lib/libmd5/common/llib-lmd5 usr/src/lib/libmd5/common/mapfile-vers usr/src/lib/libmd5/llib-lmd5 usr/src/lib/libmd5/sparc/Makefile usr/src/lib/libmd5/sparcv9/Makefile usr/src/lib/libmd5/spec/Makefile usr/src/lib/libmd5/spec/Makefile.targ usr/src/lib/libmd5/spec/amd64/Makefile usr/src/lib/libmd5/spec/i386/Makefile usr/src/lib/libmd5/spec/md5.spec usr/src/lib/libmd5/spec/sparc/Makefile usr/src/lib/libmd5/spec/sparcv9/Makefile usr/src/lib/libmd5/spec/versions usr/src/lib/libmd5_psr/Makefile usr/src/lib/libmd5_psr/Makefile.com usr/src/lib/libmd5_psr/Makefile.targ usr/src/lib/libmd5_psr/inc.flg usr/src/lib/libmd5_psr/sparc/Makefile usr/src/lib/libmd5_psr/sparc/sun4u/Makefile usr/src/lib/libmd5_psr/sparcv9/Makefile usr/src/lib/libmd5_psr/sparcv9/sun4u/Makefile usr/src/lib/libmd5_psr/spec/Makefile usr/src/lib/libmd5_psr/spec/Makefile.com usr/src/lib/libmd5_psr/spec/sparc/Makefile usr/src/lib/libmd5_psr/spec/sparc/md5_psr-sun4u.spec usr/src/lib/libmd5_psr/spec/sparc/sun4u/Makefile usr/src/lib/libmd5_psr/spec/sparc/versions-sun4u usr/src/lib/libmd5_psr/spec/sparcv9/Makefile usr/src/lib/libmd5_psr/spec/sparcv9/md5_psr-sun4u.spec usr/src/lib/libmd5_psr/spec/sparcv9/sun4u/Makefile usr/src/lib/libmd5_psr/spec/sparcv9/versions-sun4u usr/src/lib/libnsl/Makefile.com usr/src/lib/libresolv2/dnssafe/Makefile.com usr/src/lib/librt/Makefile.com usr/src/lib/librt/common/pos4obj.c usr/src/lib/libsasl/Makefile.com usr/src/lib/libwanbootutil/Makefile.com usr/src/lib/libwanbootutil/spec/wanbootutil.spec usr/src/lib/pkcs11/Makefile.softtoken.com usr/src/lib/pkcs11/Makefile.softtoken.sparc usr/src/lib/pkcs11/Makefile.softtoken.sparcv9 usr/src/pkgdefs/SUNWarcr/prototype_com usr/src/pkgdefs/SUNWarcr/prototype_i386 usr/src/pkgdefs/SUNWarcr/prototype_sparc usr/src/pkgdefs/SUNWcar.u/prototype_com usr/src/pkgdefs/SUNWcar.v/prototype_com usr/src/pkgdefs/SUNWcsl/prototype_com usr/src/pkgdefs/SUNWcsl/prototype_i386 usr/src/pkgdefs/SUNWcsl/prototype_sparc usr/src/pkgdefs/SUNWcslr/prototype_com usr/src/pkgdefs/SUNWcslr/prototype_i386 usr/src/pkgdefs/SUNWcslr/prototype_sparc usr/src/pkgdefs/SUNWhea/prototype_com usr/src/stand/lib/Makefile.targ usr/src/stand/lib/scrypt/Makefile usr/src/uts/common/Makefile.files usr/src/uts/common/crypto/io/md5_mod.c usr/src/uts/common/crypto/io/sha1_mod.c usr/src/uts/common/crypto/io/sha2_mod.c usr/src/uts/common/sys/sha1.h usr/src/uts/common/sys/sha2.h usr/src/uts/sun4v/md5/Makefile
diffstat 161 files changed, 10567 insertions(+), 9010 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/md4.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,288 @@
+/*
+** ********************************************************************
+** md4.c -- Implementation of MD4 Message Digest Algorithm           **
+** Updated: 2/16/90 by Ronald L. Rivest                              **
+** (C) 1990 RSA Data Security, Inc.                                  **
+** ********************************************************************
+ *
+ * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+/*
+** To use MD4:
+**   -- Include md4.h in your program
+**   -- Declare an MDstruct MD to hold the state of the digest
+**          computation.
+**   -- Initialize MD using MDbegin(&MD)
+**   -- For each full block (64 bytes) X you wish to process, call
+**          MD4Update(&MD,X,512)
+**      (512 is the number of bits in a full block.)
+**   -- For the last block (less than 64 bytes) you wish to process,
+**          MD4Update(&MD,X,n)
+**      where n is the number of bits in the partial block. A partial
+**      block terminates the computation, so every MD computation
+**      should terminate by processing a partial block, even if it
+**      has n = 0.
+**   -- The message digest is available in MD.buffer[0] ...
+**      MD.buffer[3].  (Least-significant byte of each word
+**      should be output first.)
+**   -- You can print out the digest using MDprint(&MD)
+*/
+
+/* Implementation notes:
+** This implementation assumes that ints are 32-bit quantities.
+*/
+
+#define TRUE  1
+#define FALSE 0
+
+/* Compile-time includes
+*/
+#include <stdio.h>
+#include "md4.h"
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#define RCSID	"$Id: $"
+
+#if !defined(lint) && !defined(_lint)
+static const char rcsid[] = RCSID;
+#endif
+
+/* Compile-time declarations of MD4 "magic constants".
+*/
+#define I0  0x67452301       /* Initial values for MD buffer */
+#define I1  0xefcdab89
+#define I2  0x98badcfe
+#define I3  0x10325476
+#define C2  013240474631     /* round 2 constant = sqrt(2) in octal */
+#define C3  015666365641     /* round 3 constant = sqrt(3) in octal */
+/* C2 and C3 are from Knuth, The Art of Programming, Volume 2
+** (Seminumerical Algorithms), Second Edition (1981), Addison-Wesley.
+** Table 2, page 660.
+*/
+
+#define fs1  3               /* round 1 shift amounts */
+#define fs2  7
+#define fs3 11
+#define fs4 19
+#define gs1  3               /* round 2 shift amounts */
+#define gs2  5
+#define gs3  9
+#define gs4 13
+#define hs1  3               /* round 3 shift amounts */
+#define hs2  9
+#define hs3 11
+#define hs4 15
+
+/* Compile-time macro declarations for MD4.
+** Note: The "rot" operator uses the variable "tmp".
+** It assumes tmp is declared as unsigned int, so that the >>
+** operator will shift in zeros rather than extending the sign bit.
+*/
+#define f(X,Y,Z)             ((X&Y) | ((~X)&Z))
+#define g(X,Y,Z)             ((X&Y) | (X&Z) | (Y&Z))
+#define h(X,Y,Z)             (X^Y^Z)
+#define rot(X,S)             (tmp=X,(tmp<<S) | (tmp>>(32-S)))
+#define ff(A,B,C,D,i,s)      A = rot((A + f(B,C,D) + X[i]),s)
+#define gg(A,B,C,D,i,s)      A = rot((A + g(B,C,D) + X[i] + C2),s)
+#define hh(A,B,C,D,i,s)      A = rot((A + h(B,C,D) + X[i] + C3),s)
+
+/* MD4Init(MDp)
+** Initialize message digest buffer MDp.
+** This is a user-callable routine.
+*/
+void
+MD4Init(MDp)
+MD4_CTX *MDp;
+{
+  int i;
+  MDp->buffer[0] = I0;
+  MDp->buffer[1] = I1;
+  MDp->buffer[2] = I2;
+  MDp->buffer[3] = I3;
+  for (i=0;i<8;i++) MDp->count[i] = 0;
+  MDp->done = 0;
+}
+
+/* MDblock(MDp,X)
+** Update message digest buffer MDp->buffer using 16-word data block X.
+** Assumes all 16 words of X are full of data.
+** Does not update MDp->count.
+** This routine is not user-callable.
+*/
+static void
+MDblock(MD4_CTX *MDp, const unsigned char *Xb)
+{
+  register unsigned int tmp, A, B, C, D;
+  unsigned int X[16];
+  int i;
+
+  for (i = 0; i < 16; ++i) {
+    X[i] = Xb[0] + (Xb[1] << 8) + (Xb[2] << 16) + (Xb[3] << 24);
+    Xb += 4;
+  }
+
+  A = MDp->buffer[0];
+  B = MDp->buffer[1];
+  C = MDp->buffer[2];
+  D = MDp->buffer[3];
+  /* Update the message digest buffer */
+  ff(A , B , C , D ,  0 , fs1); /* Round 1 */
+  ff(D , A , B , C ,  1 , fs2);
+  ff(C , D , A , B ,  2 , fs3);
+  ff(B , C , D , A ,  3 , fs4);
+  ff(A , B , C , D ,  4 , fs1);
+  ff(D , A , B , C ,  5 , fs2);
+  ff(C , D , A , B ,  6 , fs3);
+  ff(B , C , D , A ,  7 , fs4);
+  ff(A , B , C , D ,  8 , fs1);
+  ff(D , A , B , C ,  9 , fs2);
+  ff(C , D , A , B , 10 , fs3);
+  ff(B , C , D , A , 11 , fs4);
+  ff(A , B , C , D , 12 , fs1);
+  ff(D , A , B , C , 13 , fs2);
+  ff(C , D , A , B , 14 , fs3);
+  ff(B , C , D , A , 15 , fs4);
+  gg(A , B , C , D ,  0 , gs1); /* Round 2 */
+  gg(D , A , B , C ,  4 , gs2);
+  gg(C , D , A , B ,  8 , gs3);
+  gg(B , C , D , A , 12 , gs4);
+  gg(A , B , C , D ,  1 , gs1);
+  gg(D , A , B , C ,  5 , gs2);
+  gg(C , D , A , B ,  9 , gs3);
+  gg(B , C , D , A , 13 , gs4);
+  gg(A , B , C , D ,  2 , gs1);
+  gg(D , A , B , C ,  6 , gs2);
+  gg(C , D , A , B , 10 , gs3);
+  gg(B , C , D , A , 14 , gs4);
+  gg(A , B , C , D ,  3 , gs1);
+  gg(D , A , B , C ,  7 , gs2);
+  gg(C , D , A , B , 11 , gs3);
+  gg(B , C , D , A , 15 , gs4);
+  hh(A , B , C , D ,  0 , hs1); /* Round 3 */
+  hh(D , A , B , C ,  8 , hs2);
+  hh(C , D , A , B ,  4 , hs3);
+  hh(B , C , D , A , 12 , hs4);
+  hh(A , B , C , D ,  2 , hs1);
+  hh(D , A , B , C , 10 , hs2);
+  hh(C , D , A , B ,  6 , hs3);
+  hh(B , C , D , A , 14 , hs4);
+  hh(A , B , C , D ,  1 , hs1);
+  hh(D , A , B , C ,  9 , hs2);
+  hh(C , D , A , B ,  5 , hs3);
+  hh(B , C , D , A , 13 , hs4);
+  hh(A , B , C , D ,  3 , hs1);
+  hh(D , A , B , C , 11 , hs2);
+  hh(C , D , A , B ,  7 , hs3);
+  hh(B , C , D , A , 15 , hs4);
+  MDp->buffer[0] += A;
+  MDp->buffer[1] += B;
+  MDp->buffer[2] += C;
+  MDp->buffer[3] += D;
+}
+
+/* MD4Update(MDp,X,count)
+** Input: X -- a pointer to an array of unsigned characters.
+**        count -- the number of bits of X to use.
+**          (if not a multiple of 8, uses high bits of last byte.)
+** Update MDp using the number of bits of X given by count.
+** This is the basic input routine for an MD4 user.
+** The routine completes the MD computation when count < 512, so
+** every MD computation should end with one call to MD4Update with a
+** count less than 512.  A call with count 0 will be ignored if the
+** MD has already been terminated (done != 0), so an extra call with
+** count 0 can be given as a "courtesy close" to force termination
+** if desired.
+*/
+void
+MD4Update(MDp,X,count)
+MD4_CTX *MDp;
+const unsigned char *X;
+unsigned int count;
+{
+  unsigned int i, tmp, bit, byte, mask;
+  unsigned char XX[64];
+  unsigned char *p;
+
+  /* return with no error if this is a courtesy close with count
+  ** zero and MDp->done is true.
+  */
+  if (count == 0 && MDp->done) return;
+  /* check to see if MD is already done and report error */
+  if (MDp->done)
+  { (void) printf("\nError: MD4Update MD already done."); return; }
+
+  /* Add count to MDp->count */
+  tmp = count;
+  p = MDp->count;
+  while (tmp)
+  { tmp += *p;
+  *p++ = tmp;
+  tmp = tmp >> 8;
+  }
+
+  /* Process data */
+  if (count == 512)
+  { /* Full block of data to handle */
+    MDblock(MDp,X);
+  }
+  else if (count > 512) /* Check for count too large */
+  {
+    (void) printf("\nError: MD4Update called with illegal count value %d.",
+	   count);
+    return;
+  }
+  else /* partial block -- must be last block so finish up */
+  {
+    /* Find out how many bytes and residual bits there are */
+    byte = count >> 3;
+    bit =  count & 7;
+    /* Copy X into XX since we need to modify it */
+    for (i=0;i<=byte;i++)   XX[i] = X[i];
+    for (i=byte+1;i<64;i++) XX[i] = 0;
+    /* Add padding '1' bit and low-order zeros in last byte */
+    mask = 1 << (7 - bit);
+    XX[byte] = (XX[byte] | mask) & ~( mask - 1);
+    /* If room for bit count, finish up with this block */
+    if (byte <= 55)
+    {
+      for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
+      MDblock(MDp,XX);
+    }
+    else /* need to do two blocks to finish up */
+    {
+      MDblock(MDp,XX);
+      for (i=0;i<56;i++) XX[i] = 0;
+      for (i=0;i<8;i++)  XX[56+i] = MDp->count[i];
+      MDblock(MDp,XX);
+    }
+    /* Set flag saying we're done with MD computation */
+    MDp->done = 1;
+  }
+}
+
+/*
+** Finish up MD4 computation and return message digest.
+*/
+void
+MD4Final(buf, MD)
+unsigned char *buf;
+MD4_CTX *MD;
+{
+  int i, j;
+  unsigned int w;
+
+  MD4Update(MD, NULL, 0);
+  for (i = 0; i < 4; ++i) {
+    w = MD->buffer[i];
+    for (j = 0; j < 4; ++j) {
+      *buf++ = w;
+      w >>= 8;
+    }
+  }
+}
+
+/*
+** End of md4.c
+****************************(cut)***********************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/md4.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,61 @@
+/*
+** ********************************************************************
+** md4.h -- Header file for implementation of                        **
+** MD4 Message Digest Algorithm                                      **
+** Updated: 2/13/90 by Ronald L. Rivest                              **
+** (C) 1990 RSA Data Security, Inc.                                  **
+** ********************************************************************
+ *
+ * Copyright (c) 2000 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#ifndef __P
+# if defined(__STDC__) || defined(__GNUC__)
+#  define __P(x) x
+# else
+#  define __P(x) ()
+# endif
+#endif
+
+
+/* MDstruct is the data structure for a message digest computation.
+*/
+typedef struct {
+	unsigned int buffer[4]; /* Holds 4-word result of MD computation */
+	unsigned char count[8]; /* Number of bits processed so far */
+	unsigned int done;      /* Nonzero means MD computation finished */
+} MD4_CTX;
+
+/* MD4Init(MD4_CTX *)
+** Initialize the MD4_CTX prepatory to doing a message digest
+** computation.
+*/
+extern void MD4Init __P((MD4_CTX *MD));
+
+/* MD4Update(MD,X,count)
+** Input: X -- a pointer to an array of unsigned characters.
+**        count -- the number of bits of X to use (an unsigned int).
+** Updates MD using the first "count" bits of X.
+** The array pointed to by X is not modified.
+** If count is not a multiple of 8, MD4Update uses high bits of
+** last byte.
+** This is the basic input routine for a user.
+** The routine terminates the MD computation when count < 512, so
+** every MD computation should end with one call to MD4Update with a
+** count less than 512.  Zero is OK for a count.
+*/
+extern void MD4Update __P((MD4_CTX *MD, const unsigned char *X,
+    unsigned int count));
+
+/* MD4Final(buf, MD)
+** Returns message digest from MD and terminates the message
+** digest computation.
+*/
+extern void MD4Final __P((unsigned char *, MD4_CTX *));
+
+/*
+** End of md4.h
+****************************(cut)***********************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,755 @@
+/*
+ * Copyright (c) 1998-2001 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+/*
+ * The basic framework for this code came from the reference
+ * implementation for MD5.  That implementation is Copyright (C)
+ * 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD5 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ *
+ * NOTE: Cleaned-up and optimized, version of SHA1, based on the FIPS 180-1
+ * standard, available at http://www.itl.nist.gov/div897/pubs/fip180-1.htm
+ * Not as fast as one would like -- further optimizations are encouraged
+ * and appreciated.
+ */
+
+#include <strings.h>
+#include <sys/types.h>
+#include "sha1.h"
+#include "sha1_consts.h"
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#define	RCSID	"$Id: $"
+
+#if !defined(lint) && !defined(_lint)
+static const char rcsid[] = RCSID;
+#endif
+
+static void Encode(uint8_t *, uint32_t *, size_t);
+static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
+    SHA1_CTX *, const uint8_t *);
+
+static uint8_t PADDING[64] = { 0x80, /* all zeros */ };
+
+/*
+ * F, G, and H are the basic SHA1 functions.
+ */
+#define	F(b, c, d)	(((b) & (c)) | ((~b) & (d)))
+#define	G(b, c, d)	((b) ^ (c) ^ (d))
+#define	H(b, c, d)	(((b) & (c)) | ((b) & (d)) | ((c) & (d)))
+
+/*
+ * ROTATE_LEFT rotates x left n bits.
+ */
+#define	ROTATE_LEFT(x, n)	\
+	(((x) << (n)) | ((x) >> ((sizeof (x) * NBBY)-(n))))
+
+/*
+ * SHA1Init()
+ *
+ * purpose: initializes the sha1 context and begins and sha1 digest operation
+ *   input: SHA1_CTX *	: the context to initialize.
+ *  output: void
+ */
+
+void
+SHA1Init(SHA1_CTX *ctx)
+{
+	ctx->count[0] = ctx->count[1] = 0;
+
+	/*
+	 * load magic initialization constants. Tell lint
+	 * that these constants are unsigned by using U.
+	 */
+
+	ctx->state[0] = 0x67452301U;
+	ctx->state[1] = 0xefcdab89U;
+	ctx->state[2] = 0x98badcfeU;
+	ctx->state[3] = 0x10325476U;
+	ctx->state[4] = 0xc3d2e1f0U;
+}
+
+/*
+ * SHA1Update()
+ *
+ * purpose: continues an sha1 digest operation, using the message block
+ *          to update the context.
+ *   input: SHA1_CTX *	: the context to update
+ *          uint8_t *	: the message block
+ *          uint32_t    : the length of the message block in bytes
+ *  output: void
+ */
+
+void
+SHA1Update(SHA1_CTX *ctx, const uint8_t *input, uint32_t input_len)
+{
+	uint32_t i, buf_index, buf_len;
+
+	/* compute number of bytes mod 64 */
+	buf_index = (ctx->count[1] >> 3) & 0x3F;
+
+	/* update number of bits */
+	if ((ctx->count[1] += (input_len << 3)) < (input_len << 3))
+		ctx->count[0]++;
+
+	ctx->count[0] += (input_len >> 29);
+
+	buf_len = 64 - buf_index;
+
+	/* transform as many times as possible */
+	i = 0;
+	if (input_len >= buf_len) {
+
+		/*
+		 * general optimization:
+		 *
+		 * only do initial bcopy() and SHA1Transform() if
+		 * buf_index != 0.  if buf_index == 0, we're just
+		 * wasting our time doing the bcopy() since there
+		 * wasn't any data left over from a previous call to
+		 * SHA1Update().
+		 */
+
+		if (buf_index) {
+			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
+
+
+			SHA1Transform(ctx->state[0], ctx->state[1],
+			    ctx->state[2], ctx->state[3], ctx->state[4], ctx,
+			    ctx->buf_un.buf8);
+
+			i = buf_len;
+		}
+
+		for (; i + 63 < input_len; i += 64)
+			SHA1Transform(ctx->state[0], ctx->state[1],
+			    ctx->state[2], ctx->state[3], ctx->state[4],
+			    ctx, &input[i]);
+
+		/*
+		 * general optimization:
+		 *
+		 * if i and input_len are the same, return now instead
+		 * of calling bcopy(), since the bcopy() in this case
+		 * will be an expensive nop.
+		 */
+
+		if (input_len == i)
+			return;
+
+		buf_index = 0;
+	}
+
+	/* buffer remaining input */
+	bcopy(&input[i], &ctx->buf_un.buf8[buf_index], input_len - i);
+}
+
+/*
+ * SHA1Final()
+ *
+ * purpose: ends an sha1 digest operation, finalizing the message digest and
+ *          zeroing the context.
+ *   input: uint8_t *	: a buffer to store the digest in
+ *          SHA1_CTX *  : the context to finalize, save, and zero
+ *  output: void
+ */
+
+void
+SHA1Final(uint8_t *digest, SHA1_CTX *ctx)
+{
+	uint8_t		bitcount_be[sizeof (ctx->count)];
+	uint32_t	index = (ctx->count[1] >> 3) & 0x3f;
+
+	/* store bit count, big endian */
+	Encode(bitcount_be, ctx->count, sizeof (bitcount_be));
+
+	/* pad out to 56 mod 64 */
+	SHA1Update(ctx, PADDING, ((index < 56) ? 56 : 120) - index);
+
+	/* append length (before padding) */
+	SHA1Update(ctx, bitcount_be, sizeof (bitcount_be));
+
+	/* store state in digest */
+	Encode(digest, ctx->state, sizeof (ctx->state));
+
+	/* zeroize sensitive information */
+	bzero(ctx, sizeof (*ctx));
+}
+
+/*
+ * sparc optimization:
+ *
+ * on the sparc, we can load big endian 32-bit data easily.  note that
+ * special care must be taken to ensure the address is 32-bit aligned.
+ * in the interest of speed, we don't check to make sure, since
+ * careful programming can guarantee this for us.
+ */
+
+#if	defined(__sparc)
+
+#define	LOAD_LITTLE_32(addr)	(*(uint32_t *)(addr))
+
+#else	/* little endian -- will work on big endian, but slowly */
+
+#define	LOAD_LITTLE_32(addr)	\
+	(((addr)[0] << 24) | ((addr)[1] << 16) | ((addr)[2] << 8) | (addr)[3])
+#endif
+
+/*
+ * sparc register window optimization:
+ *
+ * `a', `b', `c', `d', and `e' are passed into SHA1Transform
+ * explicitly since it increases the number of registers available to
+ * the compiler.  under this scheme, these variables can be held in
+ * %i0 - %i4, which leaves more local and out registers available.
+ */
+
+/*
+ * SHA1Transform()
+ *
+ * purpose: sha1 transformation -- updates the digest based on `block'
+ *   input: uint32_t	: bytes  1 -  4 of the digest
+ *          uint32_t	: bytes  5 -  8 of the digest
+ *          uint32_t	: bytes  9 - 12 of the digest
+ *          uint32_t	: bytes 12 - 16 of the digest
+ *          uint32_t	: bytes 16 - 20 of the digest
+ *          SHA1_CTX *	: the context to update
+ *          uint8_t [64]: the block to use to update the digest
+ *  output: void
+ */
+
+void
+SHA1Transform(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e,
+    SHA1_CTX *ctx, const uint8_t blk[64])
+{
+	/*
+	 * sparc optimization:
+	 *
+	 * while it is somewhat counter-intuitive, on sparc, it is
+	 * more efficient to place all the constants used in this
+	 * function in an array and load the values out of the array
+	 * than to manually load the constants.  this is because
+	 * setting a register to a 32-bit value takes two ops in most
+	 * cases: a `sethi' and an `or', but loading a 32-bit value
+	 * from memory only takes one `ld' (or `lduw' on v9).  while
+	 * this increases memory usage, the compiler can find enough
+	 * other things to do while waiting to keep the pipeline does
+	 * not stall.  additionally, it is likely that many of these
+	 * constants are cached so that later accesses do not even go
+	 * out to the bus.
+	 *
+	 * this array is declared `static' to keep the compiler from
+	 * having to bcopy() this array onto the stack frame of
+	 * SHA1Transform() each time it is called -- which is
+	 * unacceptably expensive.
+	 *
+	 * the `const' is to ensure that callers are good citizens and
+	 * do not try to munge the array.  since these routines are
+	 * going to be called from inside multithreaded kernelland,
+	 * this is a good safety check. -- `sha1_consts' will end up in
+	 * .rodata.
+	 *
+	 * unfortunately, loading from an array in this manner hurts
+	 * performance under intel.  so, there is a macro,
+	 * SHA1_CONST(), used in SHA1Transform(), that either expands to
+	 * a reference to this array, or to the actual constant,
+	 * depending on what platform this code is compiled for.
+	 */
+
+#if	defined(__sparc)
+	static const uint32_t sha1_consts[] = {
+		SHA1_CONST_0,	SHA1_CONST_1,	SHA1_CONST_2,	SHA1_CONST_3,
+	};
+#endif
+
+	/*
+	 * general optimization:
+	 *
+	 * use individual integers instead of using an array.  this is a
+	 * win, although the amount it wins by seems to vary quite a bit.
+	 */
+
+	uint32_t	w_0, w_1, w_2,  w_3,  w_4,  w_5,  w_6,  w_7;
+	uint32_t	w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15;
+
+	/*
+	 * sparc optimization:
+	 *
+	 * if `block' is already aligned on a 4-byte boundary, use
+	 * LOAD_LITTLE_32() directly.  otherwise, bcopy() into a
+	 * buffer that *is* aligned on a 4-byte boundary and then do
+	 * the LOAD_LITTLE_32() on that buffer.  benchmarks have shown
+	 * that using the bcopy() is better than loading the bytes
+	 * individually and doing the endian-swap by hand.
+	 *
+	 * even though it's quite tempting to assign to do:
+	 *
+	 * blk = bcopy(ctx->buf_un.buf32, blk, sizeof (ctx->buf_un.buf32));
+	 *
+	 * and only have one set of LOAD_LITTLE_32()'s, the compiler
+	 * *does not* like that, so please resist the urge.
+	 */
+
+#if	defined(__sparc)
+	if ((uintptr_t)blk & 0x3) {		/* not 4-byte aligned? */
+		bcopy(blk, ctx->buf_un.buf32,  sizeof (ctx->buf_un.buf32));
+		w_15 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 15);
+		w_14 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 14);
+		w_13 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 13);
+		w_12 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 12);
+		w_11 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 11);
+		w_10 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 10);
+		w_9  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  9);
+		w_8  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  8);
+		w_7  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  7);
+		w_6  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  6);
+		w_5  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  5);
+		w_4  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  4);
+		w_3  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  3);
+		w_2  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  2);
+		w_1  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  1);
+		w_0  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  0);
+	} else
+#endif
+	{
+		/*LINTED*/
+		w_15 = LOAD_LITTLE_32(blk + 60);
+		/*LINTED*/
+		w_14 = LOAD_LITTLE_32(blk + 56);
+		/*LINTED*/
+		w_13 = LOAD_LITTLE_32(blk + 52);
+		/*LINTED*/
+		w_12 = LOAD_LITTLE_32(blk + 48);
+		/*LINTED*/
+		w_11 = LOAD_LITTLE_32(blk + 44);
+		/*LINTED*/
+		w_10 = LOAD_LITTLE_32(blk + 40);
+		/*LINTED*/
+		w_9  = LOAD_LITTLE_32(blk + 36);
+		/*LINTED*/
+		w_8  = LOAD_LITTLE_32(blk + 32);
+		/*LINTED*/
+		w_7  = LOAD_LITTLE_32(blk + 28);
+		/*LINTED*/
+		w_6  = LOAD_LITTLE_32(blk + 24);
+		/*LINTED*/
+		w_5  = LOAD_LITTLE_32(blk + 20);
+		/*LINTED*/
+		w_4  = LOAD_LITTLE_32(blk + 16);
+		/*LINTED*/
+		w_3  = LOAD_LITTLE_32(blk + 12);
+		/*LINTED*/
+		w_2  = LOAD_LITTLE_32(blk +  8);
+		/*LINTED*/
+		w_1  = LOAD_LITTLE_32(blk +  4);
+		/*LINTED*/
+		w_0  = LOAD_LITTLE_32(blk +  0);
+	}
+
+	/*
+	 * general optimization:
+	 *
+	 * even though this approach is described in the standard as
+	 * being slower algorithmically, it is 30-40% faster than the
+	 * "faster" version under SPARC, because this version has more
+	 * of the constraints specified at compile-time and uses fewer
+	 * variables (and therefore has better register utilization)
+	 * than its "speedier" brother.  (i've tried both, trust me)
+	 *
+	 * for either method given in the spec, there is an "assignment"
+	 * phase where the following takes place:
+	 *
+	 *	tmp = (main_computation);
+	 *	e = d; d = c; c = rotate_left(b, 30); b = a; a = tmp;
+	 *
+	 * we can make the algorithm go faster by not doing this work,
+	 * but just pretending that `d' is now `e', etc. this works
+	 * really well and obviates the need for a temporary variable.
+	 * however, we still explictly perform the rotate action,
+	 * since it is cheaper on SPARC to do it once than to have to
+	 * do it over and over again.
+	 */
+
+	/* round 1 */
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_0 + SHA1_CONST(0); /* 0 */
+	b = ROTATE_LEFT(b, 30);
+
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_1 + SHA1_CONST(0); /* 1 */
+	a = ROTATE_LEFT(a, 30);
+
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_2 + SHA1_CONST(0); /* 2 */
+	e = ROTATE_LEFT(e, 30);
+
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_3 + SHA1_CONST(0); /* 3 */
+	d = ROTATE_LEFT(d, 30);
+
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_4 + SHA1_CONST(0); /* 4 */
+	c = ROTATE_LEFT(c, 30);
+
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_5 + SHA1_CONST(0); /* 5 */
+	b = ROTATE_LEFT(b, 30);
+
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_6 + SHA1_CONST(0); /* 6 */
+	a = ROTATE_LEFT(a, 30);
+
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_7 + SHA1_CONST(0); /* 7 */
+	e = ROTATE_LEFT(e, 30);
+
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_8 + SHA1_CONST(0); /* 8 */
+	d = ROTATE_LEFT(d, 30);
+
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_9 + SHA1_CONST(0); /* 9 */
+	c = ROTATE_LEFT(c, 30);
+
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_10 + SHA1_CONST(0); /* 10 */
+	b = ROTATE_LEFT(b, 30);
+
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_11 + SHA1_CONST(0); /* 11 */
+	a = ROTATE_LEFT(a, 30);
+
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_12 + SHA1_CONST(0); /* 12 */
+	e = ROTATE_LEFT(e, 30);
+
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_13 + SHA1_CONST(0); /* 13 */
+	d = ROTATE_LEFT(d, 30);
+
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_14 + SHA1_CONST(0); /* 14 */
+	c = ROTATE_LEFT(c, 30);
+
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_15 + SHA1_CONST(0); /* 15 */
+	b = ROTATE_LEFT(b, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 16 */
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_0 + SHA1_CONST(0);
+	a = ROTATE_LEFT(a, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 17 */
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_1 + SHA1_CONST(0);
+	e = ROTATE_LEFT(e, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 18 */
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_2 + SHA1_CONST(0);
+	d = ROTATE_LEFT(d, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 19 */
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_3 + SHA1_CONST(0);
+	c = ROTATE_LEFT(c, 30);
+
+	/* round 2 */
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 20 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_4 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 21 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_5 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 22 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_6 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 23 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_7 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 24 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_8 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 25 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_9 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 26 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_10 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 27 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_11 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 28 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_12 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 29 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_13 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 30 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_14 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 31 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_15 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 32 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_0 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 33 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_1 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 34 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_2 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 35 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_3 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 36 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_4 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 37 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_5 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 38 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_6 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 39 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_7 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	/* round 3 */
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 40 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_8 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 41 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_9 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 42 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_10 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 43 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_11 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 44 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_12 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 45 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_13 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 46 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_14 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 47 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_15 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 48 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_0 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 49 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_1 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 50 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_2 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 51 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_3 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 52 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_4 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 53 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_5 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 54 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_6 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 55 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_7 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 56 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_8 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 57 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_9 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 58 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_10 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 59 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_11 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	/* round 4 */
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 60 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_12 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 61 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_13 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 62 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_14 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 63 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_15 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 64 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_0 + SHA1_CONST(3);
+	c = ROTATE_LEFT(c, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 65 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_1 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 66 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_2 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 67 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_3 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 68 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_4 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 69 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_5 + SHA1_CONST(3);
+	c = ROTATE_LEFT(c, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 70 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_6 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 71 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_7 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 72 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_8 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 73 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_9 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 74 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_10 + SHA1_CONST(3);
+	c = ROTATE_LEFT(c, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 75 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_11 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 76 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_12 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 77 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_13 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 78 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_14 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 79 */
+
+	ctx->state[0] += ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_15 +
+	    SHA1_CONST(3);
+	ctx->state[1] += b;
+	ctx->state[2] += ROTATE_LEFT(c, 30);
+	ctx->state[3] += d;
+	ctx->state[4] += e;
+
+	/* zeroize sensitive information */
+	w_0 = w_1 = w_2 = w_3 = w_4 = w_5 = w_6 = w_7 = w_8 = 0;
+	w_9 = w_10 = w_11 = w_12 = w_13 = w_14 = w_15 = 0;
+}
+
+/*
+ * devpro compiler optimization:
+ *
+ * the compiler can generate better code if it knows that `input' and
+ * `output' do not point to the same source.  there is no portable
+ * way to tell the compiler this, but the sun compiler recognizes the
+ * `_Restrict' keyword to indicate this condition.  use it if possible.
+ */
+
+#ifdef	__RESTRICT
+#define	restrict	_Restrict
+#else
+#define	restrict	/* nothing */
+#endif
+
+/*
+ * Encode()
+ *
+ * purpose: to convert a list of numbers from little endian to big endian
+ *   input: uint8_t *	: place to store the converted big endian numbers
+ *	    uint32_t *	: place to get numbers to convert from
+ *          size_t	: the length of the input in bytes
+ *  output: void
+ */
+
+static void
+Encode(uint8_t *restrict output, uint32_t *restrict input, size_t len)
+{
+	size_t		i, j;
+
+	for (i = 0, j = 0; j < len; i++, j += 4) {
+
+#if	defined(__sparc)
+
+		/*LINTED*/
+		*(uint32_t *)(output + j) = input[i];
+
+#else	/* little endian -- will work on big endian, but slowly */
+
+		output[j]	= (input[i] >> 24) & 0xff;
+		output[j + 1]	= (input[i] >> 16) & 0xff;
+		output[j + 2]	= (input[i] >>  8) & 0xff;
+		output[j + 3]	= input[i] & 0xff;
+
+#endif
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1998, 2000 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _SHA1_H
+#define	_SHA1_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <sys/types.h>		/* for uint_* */
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#if defined(sun) && !defined(_SYS_INT_TYPES_H) && !defined(_UINT32_T)
+/* Backward compatibility */
+typedef uint_t uint32_t;
+typedef ushort_t uint16_t;
+typedef uchar_t uint8_t;
+typedef unsigned long uintptr_t;
+#define	_UINT32_T
+#endif
+
+#ifdef __linux__
+#include <stdint.h>
+#endif
+
+/* SHA-1 context. */
+typedef struct 	{
+	uint32_t state[5];	/* state (ABCDE) */
+	uint32_t count[2];	/* number of bits, modulo 2^64 (msb first) */
+	union 	{
+		uint8_t		buf8[64];	/* undigested input */
+		uint32_t	buf32[16];	/* realigned input */
+	} buf_un;
+} SHA1_CTX;
+
+void SHA1Init(SHA1_CTX *);
+void SHA1Update(SHA1_CTX *, const uint8_t *, uint32_t);
+void SHA1Final(uint8_t *, SHA1_CTX *);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _SHA1_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1_consts.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef	_SHA1_CONSTS_H
+#define	_SHA1_CONSTS_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/*
+ * as explained in sha1.c, loading 32-bit constants on a sparc is expensive
+ * since it involves both a `sethi' and an `or'.  thus, we instead use `ld'
+ * to load the constants from an array called `sha1_consts'.  however, on
+ * intel (and perhaps other processors), it is cheaper to load the constant
+ * directly.  thus, the c code in SHA1Transform() uses the macro SHA1_CONST()
+ * which either expands to a constant or an array reference, depending on
+ * the architecture the code is being compiled for.
+ */
+
+#include <sys/types.h>		/* uint32_t */
+
+extern	const uint32_t	sha1_consts[];
+
+#if	defined(__sparc)
+#define	SHA1_CONST(x)		(sha1_consts[x])
+#else
+#define	SHA1_CONST(x)		(SHA1_CONST_ ## x)
+#endif
+
+/* constants, as provided in FIPS 180-1 */
+
+#define	SHA1_CONST_0		0x5a827999U
+#define	SHA1_CONST_1		0x6ed9eba1U
+#define	SHA1_CONST_2		0x8f1bbcdcU
+#define	SHA1_CONST_3		0xca62c1d6U
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _SHA1_CONSTS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/common/net/wanboot/crypt/sha1.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,775 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+/*
+ * The basic framework for this code came from the reference
+ * implementation for MD5.  That implementation is Copyright (C)
+ * 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD5 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ *
+ * NOTE: Cleaned-up and optimized, version of SHA1, based on the FIPS 180-1
+ * standard, available at http://www.itl.nist.gov/div897/pubs/fip180-1.htm
+ * Not as fast as one would like -- further optimizations are encouraged
+ * and appreciated.
+ */
+
+#include <sys/types.h>
+#include <strings.h>
+#include <sys/sha1.h>
+#include <sys/sha1_consts.h>
+
+#define	RCSID	"$Id: $"
+#if !defined(lint) && !defined(_lint)
+static const char rcsid[] = RCSID;
+#endif
+
+static void Encode(uint8_t *, uint32_t *, size_t);
+static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
+    SHA1_CTX *, const uint8_t *);
+
+static uint8_t PADDING[64] = { 0x80, /* all zeros */ };
+
+/*
+ * F, G, and H are the basic SHA1 functions.
+ */
+#define	F(b, c, d)	(((b) & (c)) | ((~b) & (d)))
+#define	G(b, c, d)	((b) ^ (c) ^ (d))
+#define	H(b, c, d)	(((b) & (c)) | ((b) & (d)) | ((c) & (d)))
+
+/*
+ * ROTATE_LEFT rotates x left n bits.
+ */
+#define	ROTATE_LEFT(x, n)	\
+	(((x) << (n)) | ((x) >> ((sizeof (x) * NBBY)-(n))))
+
+/*
+ * SHA1Init()
+ *
+ * purpose: initializes the sha1 context and begins and sha1 digest operation
+ *   input: SHA1_CTX *	: the context to initializes.
+ *  output: void
+ */
+
+void
+SHA1Init(SHA1_CTX *ctx)
+{
+	ctx->count[0] = ctx->count[1] = 0;
+
+	/*
+	 * load magic initialization constants. Tell lint
+	 * that these constants are unsigned by using U.
+	 */
+
+	ctx->state[0] = 0x67452301U;
+	ctx->state[1] = 0xefcdab89U;
+	ctx->state[2] = 0x98badcfeU;
+	ctx->state[3] = 0x10325476U;
+	ctx->state[4] = 0xc3d2e1f0U;
+}
+
+/*
+ * SHA1Update()
+ *
+ * purpose: continues an sha1 digest operation, using the message block
+ *          to update the context.
+ *   input: SHA1_CTX *	: the context to update
+ *          uint8_t *	: the message block
+ *          uint32_t    : the length of the message block in bytes
+ *  output: void
+ */
+
+void
+SHA1Update(SHA1_CTX *ctx, const uint8_t *input, uint32_t input_len)
+{
+	uint32_t i, buf_index, buf_len;
+
+	/* check for noop */
+	if (input_len == 0)
+		return;
+
+	/* compute number of bytes mod 64 */
+	buf_index = (ctx->count[1] >> 3) & 0x3F;
+
+	/* update number of bits */
+	if ((ctx->count[1] += (input_len << 3)) < (input_len << 3))
+		ctx->count[0]++;
+
+	ctx->count[0] += (input_len >> 29);
+
+	buf_len = 64 - buf_index;
+
+	/* transform as many times as possible */
+	i = 0;
+	if (input_len >= buf_len) {
+
+		/*
+		 * general optimization:
+		 *
+		 * only do initial bcopy() and SHA1Transform() if
+		 * buf_index != 0.  if buf_index == 0, we're just
+		 * wasting our time doing the bcopy() since there
+		 * wasn't any data left over from a previous call to
+		 * SHA1Update().
+		 */
+
+		if (buf_index) {
+			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
+
+
+			SHA1Transform(ctx->state[0], ctx->state[1],
+			    ctx->state[2], ctx->state[3], ctx->state[4], ctx,
+			    ctx->buf_un.buf8);
+
+			i = buf_len;
+		}
+
+		for (; i + 63 < input_len; i += 64)
+			SHA1Transform(ctx->state[0], ctx->state[1],
+			    ctx->state[2], ctx->state[3], ctx->state[4],
+			    ctx, &input[i]);
+
+		/*
+		 * general optimization:
+		 *
+		 * if i and input_len are the same, return now instead
+		 * of calling bcopy(), since the bcopy() in this case
+		 * will be an expensive nop.
+		 */
+
+		if (input_len == i)
+			return;
+
+		buf_index = 0;
+	}
+
+	/* buffer remaining input */
+	bcopy(&input[i], &ctx->buf_un.buf8[buf_index], input_len - i);
+}
+
+/*
+ * SHA1Final()
+ *
+ * purpose: ends an sha1 digest operation, finalizing the message digest and
+ *          zeroing the context.
+ *   input: uint8_t *	: a buffer to store the digest in
+ *          SHA1_CTX *  : the context to finalize, save, and zero
+ *  output: void
+ */
+
+void
+SHA1Final(uint8_t *digest, SHA1_CTX *ctx)
+{
+	uint8_t		bitcount_be[sizeof (ctx->count)];
+	uint32_t	index = (ctx->count[1] >> 3) & 0x3f;
+
+	/* store bit count, big endian */
+	Encode(bitcount_be, ctx->count, sizeof (bitcount_be));
+
+	/* pad out to 56 mod 64 */
+	SHA1Update(ctx, PADDING, ((index < 56) ? 56 : 120) - index);
+
+	/* append length (before padding) */
+	SHA1Update(ctx, bitcount_be, sizeof (bitcount_be));
+
+	/* store state in digest */
+	Encode(digest, ctx->state, sizeof (ctx->state));
+
+	/* zeroize sensitive information */
+	bzero(ctx, sizeof (*ctx));
+}
+
+/*
+ * sparc optimization:
+ *
+ * on the sparc, we can load big endian 32-bit data easily.  note that
+ * special care must be taken to ensure the address is 32-bit aligned.
+ * in the interest of speed, we don't check to make sure, since
+ * careful programming can guarantee this for us.
+ */
+
+#if	defined(__sparc)
+
+#define	LOAD_LITTLE_32(addr)	(*(uint32_t *)(addr))
+
+#else	/* little endian -- will work on big endian, but slowly */
+
+#define	LOAD_LITTLE_32(addr)	\
+	(((addr)[0] << 24) | ((addr)[1] << 16) | ((addr)[2] << 8) | (addr)[3])
+#endif
+
+/*
+ * sparc register window optimization:
+ *
+ * `a', `b', `c', `d', and `e' are passed into SHA1Transform
+ * explicitly since it increases the number of registers available to
+ * the compiler.  under this scheme, these variables can be held in
+ * %i0 - %i4, which leaves more local and out registers available.
+ */
+
+/*
+ * SHA1Transform()
+ *
+ * purpose: sha1 transformation -- updates the digest based on `block'
+ *   input: uint32_t	: bytes  1 -  4 of the digest
+ *          uint32_t	: bytes  5 -  8 of the digest
+ *          uint32_t	: bytes  9 - 12 of the digest
+ *          uint32_t	: bytes 12 - 16 of the digest
+ *          uint32_t	: bytes 16 - 20 of the digest
+ *          SHA1_CTX *	: the context to update
+ *          uint8_t [64]: the block to use to update the digest
+ *  output: void
+ */
+
+void
+SHA1Transform(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e,
+    SHA1_CTX *ctx, const uint8_t blk[64])
+{
+	/*
+	 * sparc optimization:
+	 *
+	 * while it is somewhat counter-intuitive, on sparc, it is
+	 * more efficient to place all the constants used in this
+	 * function in an array and load the values out of the array
+	 * than to manually load the constants.  this is because
+	 * setting a register to a 32-bit value takes two ops in most
+	 * cases: a `sethi' and an `or', but loading a 32-bit value
+	 * from memory only takes one `ld' (or `lduw' on v9).  while
+	 * this increases memory usage, the compiler can find enough
+	 * other things to do while waiting to keep the pipeline does
+	 * not stall.  additionally, it is likely that many of these
+	 * constants are cached so that later accesses do not even go
+	 * out to the bus.
+	 *
+	 * this array is declared `static' to keep the compiler from
+	 * having to bcopy() this array onto the stack frame of
+	 * SHA1Transform() each time it is called -- which is
+	 * unacceptably expensive.
+	 *
+	 * the `const' is to ensure that callers are good citizens and
+	 * do not try to munge the array.  since these routines are
+	 * going to be called from inside multithreaded kernelland,
+	 * this is a good safety check. -- `sha1_consts' will end up in
+	 * .rodata.
+	 *
+	 * unfortunately, loading from an array in this manner hurts
+	 * performance under intel.  so, there is a macro,
+	 * SHA1_CONST(), used in SHA1Transform(), that either expands to
+	 * a reference to this array, or to the actual constant,
+	 * depending on what platform this code is compiled for.
+	 */
+
+#if	defined(__sparc)
+	static const uint32_t sha1_consts[] = {
+		SHA1_CONST_0,	SHA1_CONST_1,	SHA1_CONST_2,	SHA1_CONST_3,
+	};
+#endif
+
+	/*
+	 * general optimization:
+	 *
+	 * use individual integers instead of using an array.  this is a
+	 * win, although the amount it wins by seems to vary quite a bit.
+	 */
+
+	uint32_t	w_0, w_1, w_2,  w_3,  w_4,  w_5,  w_6,  w_7;
+	uint32_t	w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15;
+
+	/*
+	 * sparc optimization:
+	 *
+	 * if `block' is already aligned on a 4-byte boundary, use
+	 * LOAD_LITTLE_32() directly.  otherwise, bcopy() into a
+	 * buffer that *is* aligned on a 4-byte boundary and then do
+	 * the LOAD_LITTLE_32() on that buffer.  benchmarks have shown
+	 * that using the bcopy() is better than loading the bytes
+	 * individually and doing the endian-swap by hand.
+	 *
+	 * even though it's quite tempting to assign to do:
+	 *
+	 * blk = bcopy(ctx->buf_un.buf32, blk, sizeof (ctx->buf_un.buf32));
+	 *
+	 * and only have one set of LOAD_LITTLE_32()'s, the compiler
+	 * *does not* like that, so please resist the urge.
+	 */
+
+#if	defined(__sparc)
+	if ((uintptr_t)blk & 0x3) {		/* not 4-byte aligned? */
+		bcopy(blk, ctx->buf_un.buf32,  sizeof (ctx->buf_un.buf32));
+		w_15 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 15);
+		w_14 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 14);
+		w_13 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 13);
+		w_12 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 12);
+		w_11 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 11);
+		w_10 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 10);
+		w_9  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  9);
+		w_8  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  8);
+		w_7  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  7);
+		w_6  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  6);
+		w_5  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  5);
+		w_4  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  4);
+		w_3  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  3);
+		w_2  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  2);
+		w_1  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  1);
+		w_0  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  0);
+	} else {
+		/*LINTED*/
+		w_15 = LOAD_LITTLE_32(blk + 60);
+		/*LINTED*/
+		w_14 = LOAD_LITTLE_32(blk + 56);
+		/*LINTED*/
+		w_13 = LOAD_LITTLE_32(blk + 52);
+		/*LINTED*/
+		w_12 = LOAD_LITTLE_32(blk + 48);
+		/*LINTED*/
+		w_11 = LOAD_LITTLE_32(blk + 44);
+		/*LINTED*/
+		w_10 = LOAD_LITTLE_32(blk + 40);
+		/*LINTED*/
+		w_9  = LOAD_LITTLE_32(blk + 36);
+		/*LINTED*/
+		w_8  = LOAD_LITTLE_32(blk + 32);
+		/*LINTED*/
+		w_7  = LOAD_LITTLE_32(blk + 28);
+		/*LINTED*/
+		w_6  = LOAD_LITTLE_32(blk + 24);
+		/*LINTED*/
+		w_5  = LOAD_LITTLE_32(blk + 20);
+		/*LINTED*/
+		w_4  = LOAD_LITTLE_32(blk + 16);
+		/*LINTED*/
+		w_3  = LOAD_LITTLE_32(blk + 12);
+		/*LINTED*/
+		w_2  = LOAD_LITTLE_32(blk +  8);
+		/*LINTED*/
+		w_1  = LOAD_LITTLE_32(blk +  4);
+		/*LINTED*/
+		w_0  = LOAD_LITTLE_32(blk +  0);
+	}
+#else
+	w_15 = LOAD_LITTLE_32(blk + 60);
+	w_14 = LOAD_LITTLE_32(blk + 56);
+	w_13 = LOAD_LITTLE_32(blk + 52);
+	w_12 = LOAD_LITTLE_32(blk + 48);
+	w_11 = LOAD_LITTLE_32(blk + 44);
+	w_10 = LOAD_LITTLE_32(blk + 40);
+	w_9  = LOAD_LITTLE_32(blk + 36);
+	w_8  = LOAD_LITTLE_32(blk + 32);
+	w_7  = LOAD_LITTLE_32(blk + 28);
+	w_6  = LOAD_LITTLE_32(blk + 24);
+	w_5  = LOAD_LITTLE_32(blk + 20);
+	w_4  = LOAD_LITTLE_32(blk + 16);
+	w_3  = LOAD_LITTLE_32(blk + 12);
+	w_2  = LOAD_LITTLE_32(blk +  8);
+	w_1  = LOAD_LITTLE_32(blk +  4);
+	w_0  = LOAD_LITTLE_32(blk +  0);
+#endif
+	/*
+	 * general optimization:
+	 *
+	 * even though this approach is described in the standard as
+	 * being slower algorithmically, it is 30-40% faster than the
+	 * "faster" version under SPARC, because this version has more
+	 * of the constraints specified at compile-time and uses fewer
+	 * variables (and therefore has better register utilization)
+	 * than its "speedier" brother.  (i've tried both, trust me)
+	 *
+	 * for either method given in the spec, there is an "assignment"
+	 * phase where the following takes place:
+	 *
+	 *	tmp = (main_computation);
+	 *	e = d; d = c; c = rotate_left(b, 30); b = a; a = tmp;
+	 *
+	 * we can make the algorithm go faster by not doing this work,
+	 * but just pretending that `d' is now `e', etc. this works
+	 * really well and obviates the need for a temporary variable.
+	 * however, we still explictly perform the rotate action,
+	 * since it is cheaper on SPARC to do it once than to have to
+	 * do it over and over again.
+	 */
+
+	/* round 1 */
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_0 + SHA1_CONST(0); /* 0 */
+	b = ROTATE_LEFT(b, 30);
+
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_1 + SHA1_CONST(0); /* 1 */
+	a = ROTATE_LEFT(a, 30);
+
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_2 + SHA1_CONST(0); /* 2 */
+	e = ROTATE_LEFT(e, 30);
+
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_3 + SHA1_CONST(0); /* 3 */
+	d = ROTATE_LEFT(d, 30);
+
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_4 + SHA1_CONST(0); /* 4 */
+	c = ROTATE_LEFT(c, 30);
+
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_5 + SHA1_CONST(0); /* 5 */
+	b = ROTATE_LEFT(b, 30);
+
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_6 + SHA1_CONST(0); /* 6 */
+	a = ROTATE_LEFT(a, 30);
+
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_7 + SHA1_CONST(0); /* 7 */
+	e = ROTATE_LEFT(e, 30);
+
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_8 + SHA1_CONST(0); /* 8 */
+	d = ROTATE_LEFT(d, 30);
+
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_9 + SHA1_CONST(0); /* 9 */
+	c = ROTATE_LEFT(c, 30);
+
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_10 + SHA1_CONST(0); /* 10 */
+	b = ROTATE_LEFT(b, 30);
+
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_11 + SHA1_CONST(0); /* 11 */
+	a = ROTATE_LEFT(a, 30);
+
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_12 + SHA1_CONST(0); /* 12 */
+	e = ROTATE_LEFT(e, 30);
+
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_13 + SHA1_CONST(0); /* 13 */
+	d = ROTATE_LEFT(d, 30);
+
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_14 + SHA1_CONST(0); /* 14 */
+	c = ROTATE_LEFT(c, 30);
+
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_15 + SHA1_CONST(0); /* 15 */
+	b = ROTATE_LEFT(b, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 16 */
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_0 + SHA1_CONST(0);
+	a = ROTATE_LEFT(a, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 17 */
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_1 + SHA1_CONST(0);
+	e = ROTATE_LEFT(e, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 18 */
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_2 + SHA1_CONST(0);
+	d = ROTATE_LEFT(d, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 19 */
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_3 + SHA1_CONST(0);
+	c = ROTATE_LEFT(c, 30);
+
+	/* round 2 */
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 20 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_4 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 21 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_5 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 22 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_6 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 23 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_7 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 24 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_8 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 25 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_9 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 26 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_10 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 27 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_11 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 28 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_12 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 29 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_13 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 30 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_14 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 31 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_15 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 32 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_0 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 33 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_1 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 34 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_2 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 35 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_3 + SHA1_CONST(1);
+	b = ROTATE_LEFT(b, 30);
+
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 36 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_4 + SHA1_CONST(1);
+	a = ROTATE_LEFT(a, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 37 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_5 + SHA1_CONST(1);
+	e = ROTATE_LEFT(e, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 38 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_6 + SHA1_CONST(1);
+	d = ROTATE_LEFT(d, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 39 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_7 + SHA1_CONST(1);
+	c = ROTATE_LEFT(c, 30);
+
+	/* round 3 */
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 40 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_8 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 41 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_9 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 42 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_10 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 43 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_11 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 44 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_12 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 45 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_13 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 46 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_14 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 47 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_15 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 48 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_0 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 49 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_1 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 50 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_2 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 51 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_3 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 52 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_4 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 53 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_5 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 54 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_6 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 55 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_7 + SHA1_CONST(2);
+	b = ROTATE_LEFT(b, 30);
+
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 56 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_8 + SHA1_CONST(2);
+	a = ROTATE_LEFT(a, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 57 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_9 + SHA1_CONST(2);
+	e = ROTATE_LEFT(e, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 58 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_10 + SHA1_CONST(2);
+	d = ROTATE_LEFT(d, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 59 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_11 + SHA1_CONST(2);
+	c = ROTATE_LEFT(c, 30);
+
+	/* round 4 */
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 60 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_12 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 61 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_13 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 62 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_14 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 63 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_15 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 64 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_0 + SHA1_CONST(3);
+	c = ROTATE_LEFT(c, 30);
+
+	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 65 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_1 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 66 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_2 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 67 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_3 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 68 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_4 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 69 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_5 + SHA1_CONST(3);
+	c = ROTATE_LEFT(c, 30);
+
+	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 70 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_6 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 71 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_7 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 72 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_8 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 73 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_9 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 74 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_10 + SHA1_CONST(3);
+	c = ROTATE_LEFT(c, 30);
+
+	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 75 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_11 + SHA1_CONST(3);
+	b = ROTATE_LEFT(b, 30);
+
+	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 76 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_12 + SHA1_CONST(3);
+	a = ROTATE_LEFT(a, 30);
+
+	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 77 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_13 + SHA1_CONST(3);
+	e = ROTATE_LEFT(e, 30);
+
+	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 78 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_14 + SHA1_CONST(3);
+	d = ROTATE_LEFT(d, 30);
+
+	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 79 */
+
+	ctx->state[0] += ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_15 +
+	    SHA1_CONST(3);
+	ctx->state[1] += b;
+	ctx->state[2] += ROTATE_LEFT(c, 30);
+	ctx->state[3] += d;
+	ctx->state[4] += e;
+
+	/* zeroize sensitive information */
+	w_0 = w_1 = w_2 = w_3 = w_4 = w_5 = w_6 = w_7 = w_8 = 0;
+	w_9 = w_10 = w_11 = w_12 = w_13 = w_14 = w_15 = 0;
+}
+
+/*
+ * devpro compiler optimization:
+ *
+ * the compiler can generate better code if it knows that `input' and
+ * `output' do not point to the same source.  there is no portable
+ * way to tell the compiler this, but the sun compiler recognizes the
+ * `_Restrict' keyword to indicate this condition.  use it if possible.
+ */
+
+#ifdef	__RESTRICT
+#define	restrict	_Restrict
+#else
+#define	restrict	/* nothing */
+#endif
+
+/*
+ * Encode()
+ *
+ * purpose: to convert a list of numbers from little endian to big endian
+ *   input: uint8_t *	: place to store the converted big endian numbers
+ *	    uint32_t *	: place to get numbers to convert from
+ *          size_t	: the length of the input in bytes
+ *  output: void
+ */
+
+static void
+Encode(uint8_t *restrict output, uint32_t *restrict input, size_t len)
+{
+	size_t		i, j;
+
+	for (i = 0, j = 0; j < len; i++, j += 4) {
+
+#if	defined(__sparc)
+
+		/*LINTED*/
+		*(uint32_t *)(output + j) = input[i];
+
+#else	/* little endian -- will work on big endian, but slowly */
+
+		output[j]	= (input[i] >> 24) & 0xff;
+		output[j + 1]	= (input[i] >> 16) & 0xff;
+		output[j + 2]	= (input[i] >>  8) & 0xff;
+		output[j + 3]	= input[i] & 0xff;
+
+#endif
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5/spec/Makefile
+#
+
+include $(SRC)/lib/Makefile.spec.arch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/Makefile.targ	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,36 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5/spec/Makefile.targ
+#
+
+LIBRARY= libmd5.a
+VERS= .1
+
+OBJECTS= md5.o
+
+SPECCPP += -I../../
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/amd64/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,44 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+
+# Uncomment the following if the linker complains
+#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS)
+
+include $(SRC)/lib/Makefile.spec
+
+.KEEP_STATE:
+
+install: $(ROOTABILIB64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/i386/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,45 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5/spec/i386/Makefile
+#
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+
+# Uncomment the following if the linker complains
+#i386_C_PICFLAGS  = -K PIC
+
+include $(SRC)/lib/Makefile.spec
+
+.KEEP_STATE:
+
+install: $(ROOTABILIB)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/md5.spec	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,55 @@
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# lib/libmd5/spec/md5.spec
+#
+
+function	MD5Init
+include		<md5.h>
+declaration	void MD5Init(MD5_CTX *context)
+version		SUNW_1.1
+end
+
+function	MD5Update
+include		<md5.h>
+declaration	void MD5Update(MD5_CTX *context, \
+				const void *input, \
+				unsigned int inputLen)
+version		SUNW_1.1
+end
+
+function	MD5Final
+include		<md5.h>
+declaration	void MD5Final(unsigned char digest[16], MD5_CTX *context)
+version		SUNW_1.1
+end
+
+function	md5_calc
+declaration	void md5_calc(unsigned char *output, \
+				unsigned char *input, \
+				unsigned int inlen)
+version		SUNW_1.1
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,45 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5/spec/sparc/Makefile
+#
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+
+# Uncomment the following if the linker complains
+#sparc_C_PICFLAGS  = -K PIC
+
+include $(SRC)/lib/Makefile.spec
+
+.KEEP_STATE:
+
+install: $(ROOTABILIB)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5/spec/sparcv9/Makefile
+#
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+
+# Uncomment the following if the linker complains
+#sparcv9_C_PICFLAGS  = -K PIC
+
+include $(SRC)/lib/Makefile.spec
+
+.KEEP_STATE:
+
+install: $(ROOTABILIB64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5/spec/versions	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,39 @@
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+sparc {
+	SUNW_1.1;
+}
+sparcv9 {
+	SUNW_1.1;
+}
+i386 {
+	SUNW_1.1;
+}
+amd64 {
+	SUNW_1.1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,57 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/Makefile
+#
+
+include $(SRC)/Makefile.master
+
+SUBDIRS= spec .WAIT $(MACH) $(BUILD64) $(MACH64)
+
+all :=		TARGET= all
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+install :=	TARGET= install
+
+.KEEP_STATE:
+
+.PARALLEL: $(MACH) $(MACH64)
+
+all clean clobber install: $(SUBDIRS)
+
+spec $(MACH) $(MACH64): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+#
+# Empty targets.
+# lint is an empty target since md5.c is already linted
+# up and down in the kernel and a lint library is already
+# created in lib/libmd5.
+#
+_msg install_h check lint:
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,100 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# lib/libmd5_psr/Makefile.com
+#
+
+#
+# Create default so empty rules don't confuse make
+#
+CLASS= 32
+
+LIBRARY= libmd5_psr.a
+VERS= .1
+
+OBJECTS= md5.o
+COMMON= $(SRC)/common/crypto/md5
+
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/Makefile.psm
+
+#
+# Macros to help build the shared object
+#
+LIBS= $(DYNLIB)
+DYNFLAGS += $(BDIRECT)
+LDLIBS += -lc
+CPPFLAGS += -D__RESTRICT
+
+#
+# Macros for the mapfile. Other makefiles need to include this file
+# after setting MAPDIR
+#
+MAPFILE=	$(MAPDIR)/mapfile-$(PLATFORM)
+DYNFLAGS +=	-M$(MAPFILE)
+CLOBBERFILES +=	$(MAPFILE)
+
+#
+# Used when building links in /platform/$(PLATFORM)/lib 
+#
+LINKED_PLATFORMS	= SUNW,Ultra-2
+LINKED_PLATFORMS	+= SUNW,Ultra-4
+LINKED_PLATFORMS	+= SUNW,Ultra-5_10
+LINKED_PLATFORMS	+= SUNW,Ultra-30
+LINKED_PLATFORMS	+= SUNW,Ultra-60
+LINKED_PLATFORMS	+= SUNW,Ultra-80
+LINKED_PLATFORMS	+= SUNW,Ultra-250
+LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise
+LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise-10000
+LINKED_PLATFORMS	+= SUNW,UltraAX-i2
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIi-Netract
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-40
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-60
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-100
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-1000
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-1500
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-2500
+LINKED_PLATFORMS	+= SUNW,A70
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V445
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V215
+LINKED_PLATFORMS	+= SUNW,Sun-Fire
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V240
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V250
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V440
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-280R
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-15000
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-880
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-480R
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V890
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V490
+LINKED_PLATFORMS	+= SUNW,Serverblade1
+LINKED_PLATFORMS	+= SUNW,Netra-T12
+LINKED_PLATFORMS	+= SUNW,Netra-T4
+LINKED_PLATFORMS	+= SUNW,Netra-CP2300
+LINKED_PLATFORMS	+= SUNW,Netra-CP3010
+
+.KEEP_STATE:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/Makefile.targ	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/Makefile.targ
+#
+
+#
+# This makefile defines common targets. Other makefiles should
+# include this after defining default targets.
+#
+
+include $(SRC)/lib/Makefile.targ
+include $(SRC)/Makefile.psm.targ
+
+INLINES= $(COMMON)/$(MACH)/$(PLATFORM)/byteswap.il
+
+$(MAPFILE):
+	@cd $(MAPDIR); pwd; $(MAKE) $(TARGET)
+
+pics/%.o: $(COMMON)/%.c $(INLINES)
+	$(COMPILE.c) $(INLINES) -o $@ $<
+	$(POST_PROCESS_O)
+
+$(DYNLIB):	$(MAPFILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/inc.flg	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#ident	"%Z%%M%	%I%	%E% SMI"
+
+find_files "s.*" usr/src/common/crypto/md5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,45 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/sparc/Makefile
+#
+
+SUBDIRS= sun4u
+
+all :=		TARGET= all
+install :=	TARGET= install
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+
+.KEEP_STATE:
+
+all install clean clobber : $(SUBDIRS)
+
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/sparc/sun4u/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,65 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Platform specific Makefile for libmd5_psr.
+#
+# PLATFORM is the target for the binary installation.
+#
+PLATFORM = sun4u
+
+MAPDIR = ../../spec/$(MACH)/$(PLATFORM)
+
+include ../../Makefile.com
+
+#
+# Defining sun4u turns on sun4u-specific optimization
+#
+CPPFLAGS += -Dsun4u
+CFLAGS += -xarch=v8plusa
+
+.KEEP_STATE:
+
+#
+# Used when building links in /platform/$(PLATFORM)/lib for libmd5_psr.so.1
+#
+MODULE	= libmd5_psr.so.1
+
+LIBMD5_PSR_DIRS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib)
+LIBMD5_PSR_LINKS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MODULE))
+INS.slink6 = $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/lib/$(MODULE) $@ $(CHOWNLINK) $(CHGRPLINK)
+
+$(LIBMD5_PSR_DIRS):
+	-$(INS.dir.root.bin)
+
+$(LIBMD5_PSR_LINKS): $(LIBMD5_PSR_DIRS)
+	-$(INS.slink6)
+
+all:		$(LIBS)
+
+install:	all $(LIBMD5_PSR_LINKS) $(ROOT_PSM_LIBS)
+
+include	../../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,44 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/sparcv9/Makefile
+#
+SUBDIRS= sun4u
+
+all :=		TARGET= all
+install :=	TARGET= install
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+
+.KEEP_STATE:
+
+all install clean clobber : $(SUBDIRS)
+
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/sparcv9/sun4u/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,62 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Platform specific Makefile for libmd5_psr.
+#
+# PLATFORM is the target for the binary installation.
+#
+PLATFORM = sun4u
+
+MAPDIR = ../../spec/$(MACH64)/$(PLATFORM)
+
+include ../../Makefile.com
+include $(SRC)/Makefile.master.64
+
+#
+# Defining sun4u turns on sun4u-specific optimization
+#
+CPPFLAGS += -Dsun4u
+
+.KEEP_STATE:
+
+MODULE  = libmd5_psr.so.1
+
+LIBMD5_PSR64_DIRS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MACH64))
+LIBMD5_PSR64_LINKS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MACH64)/$(MODULE))
+INS.slink7 = $(RM) -r $@; $(SYMLINK) ../../../$(PLATFORM)/lib/$(MACH64)/$(MODULE) $@ $(CHOWNLINK) $(CHGRPLINK)
+
+$(LIBMD5_PSR64_DIRS):
+	-$(INS.dir.root.bin)
+
+$(LIBMD5_PSR64_LINKS): $(LIBMD5_PSR64_DIRS)
+	-$(INS.slink7)
+
+all:		$(LIBS)
+
+install:	all $(LIBMD5_PSR64_LINKS) $(ROOT_PSM_LIB64_DIR)/$(LIBS) 
+
+include ../../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/spec/Makefile
+
+include	$(SRC)/lib/Makefile.spec.arch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,78 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd5_psr/spec/Makefile.com
+
+include $(SRC)/Makefile.psm
+
+MODULE=		abi
+
+#
+# links in /usr/platform
+#
+LINKED_PLATFORMS	= SUNW,Ultra-2
+LINKED_PLATFORMS	+= SUNW,Ultra-4
+LINKED_PLATFORMS	+= SUNW,Ultra-250
+LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise
+LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise-10000
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIi-Netract
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-40
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-60
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-100
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-1000
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-1500
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-2500
+LINKED_PLATFORMS	+= SUNW,A70
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V445
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V215
+LINKED_PLATFORMS	+= SUNW,Sun-Fire
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V240
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V250
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V440
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-280R
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-15000
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-880
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-480R
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V890
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V490
+LINKED_PLATFORMS	+= SUNW,Serverblade1
+LINKED_PLATFORMS	+= SUNW,Netra-T12
+LINKED_PLATFORMS	+= SUNW,Netra-T4
+LINKED_PLATFORMS	+= SUNW,Netra-CP2300
+LINKED_PLATFORMS	+= SUNW,Netra-CP3010
+
+LINKED_DIRS	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%)
+LINKED_LIB_DIRS	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib)
+LINKED_ABI_DIRS	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi)
+LINKED_ABI_DIRS64 = $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi/$(MACH64))
+ABI_LINKS32	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi/abi_$(DYNLIB))
+ABI_LINKS64	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi/$(MACH64)/abi_$(DYNLIB))
+ABI_LINKS	= $(ABI_LINKS$(CLASS))
+
+links:
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/spec/sparc/Makefile
+
+SUBDIRS=	sun4u
+
+all		:=	TARGET= all
+install		:=	TARGET= install
+clean		:=	TARGET= clean
+clobber		:=	TARGET= clobber
+lint		:=	TARGET= lint
+
+.KEEP_STATE:
+
+all install clean clobber lint: $(SUBDIRS)
+
+# spec files do not have msgs or catalogs
+_msg catalog:
+
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparc/sun4u/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,51 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd5_psr/sparc/spec/sun4u/Makefile
+
+.KEEP_STATE:
+
+LIBRARY	=	libmd5_psr.a
+VERS	=	.1
+
+PLATFORM=	sun4u
+CLASS=		32
+
+OBJECTS	=	md5_psr-$(PLATFORM).o
+
+SPECVERS =	-$(PLATFORM)
+
+include	$(SRC)/lib/Makefile.lib
+
+# Uncomment the following if the linker complains
+#sparc_C_PICFLAGS  = -K PIC
+
+include	$(SRC)/lib/Makefile.spec
+include $(SRC)/lib/Makefile.spec.psm
+include $(SRC)/lib/libmd5_psr/spec/Makefile.com
+
+install:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparc/versions-sun4u	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,32 @@
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# lib/libmd5_psr/spec/sparc/versions-sun4u
+#
+
+sparc {
+	SUNWprivate_1.1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright (c) 1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+# lib/libmd5_psr/spec/sparcv9/Makefile
+
+SUBDIRS=	sun4u
+
+all		:=	TARGET= all
+install		:=	TARGET= install
+clean		:=	TARGET= clean
+clobber		:=	TARGET= clobber
+lint		:=	TARGET= lint
+
+.KEEP_STATE:
+
+all install clean clobber lint: $(SUBDIRS)
+
+# spec files do not have msgs or catalogs
+_msg catalog:
+
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/md_psr-sun4u.spec	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,48 @@
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# lib/libmd5_psr/spec/sparcv9/md5_psr-sun4u.spec
+#
+
+function	MD5Init extends libmd5/spec/md5.spec
+arch		sparcv9
+version		SUNWprivate_1.1
+end
+
+function	MD5Update extends libmd5/spec/md5.spec
+arch		sparcv9
+version		SUNWprivate_1.1
+end
+
+function	MD5Final extends libmd5/spec/md5.spec
+arch		sparcv9
+version		SUNWprivate_1.1
+end
+
+function	md5_calc extends libmd5/spec/md5.spec
+arch		sparcv9
+version		SUNWprivate_1.1
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/sun4u/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,52 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd5_psr/sparcv9/spec/sun4u/Makefile
+
+.KEEP_STATE:
+
+LIBRARY	=	libmd5_psr.a
+VERS	=	.1
+
+PLATFORM=	sun4u
+CLASS=		64
+
+OBJECTS	=	md5_psr-$(PLATFORM).o
+
+SPECVERS=	-$(PLATFORM)
+
+include	$(SRC)/lib/Makefile.lib
+include	$(SRC)/lib/Makefile.lib.64
+include $(SRC)/lib/libmd5_psr/spec/Makefile.com
+
+# Uncomment the following if the linker complains
+#sparcv9_C_PICFLAGS  = -K PIC
+
+include	$(SRC)/lib/Makefile.spec
+include $(SRC)/lib/Makefile.spec.psm
+
+install:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd5_psr/spec/sparcv9/versions-sun4u	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,32 @@
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# lib/libmd5_psr/spec/sparcv9/versions-sun4u
+#
+
+sparcv9 {
+	SUNWprivate_1.1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deleted_files/usr/src/lib/libmd_psr/spec/sparc/md_psr-sun4u.spec	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,48 @@
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#
+# lib/libmd5_psr/spec/sparc/md5_psr-sun4u.spec
+#
+
+function	MD5Init extends libmd5/spec/md5.spec
+arch		sparc
+version		SUNWprivate_1.1
+end
+
+function	MD5Update extends libmd5/spec/md5.spec
+arch		sparc
+version		SUNWprivate_1.1
+end
+
+function	MD5Final extends libmd5/spec/md5.spec
+arch		sparc
+version		SUNWprivate_1.1
+end
+
+function	md5_calc extends libmd5/spec/md5.spec
+arch		sparc
+version		SUNWprivate_1.1
+end
--- a/usr/src/Makefile.lint	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/Makefile.lint	Tue Mar 28 08:45:30 2006 -0800
@@ -326,7 +326,7 @@
 	lib/liblm \
 	lib/libmacadm \
 	lib/libmalloc \
-	lib/libmd5 \
+	lib/libmd \
 	lib/libmp \
 	lib/libnsl \
 	lib/libnvpair \
--- a/usr/src/Targetdirs	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/Targetdirs	Tue Mar 28 08:45:30 2006 -0800
@@ -201,6 +201,7 @@
 	/usr/include/libmilter \
 	/usr/include/sasl \
 	/usr/include/tsol \
+	/usr/include/security \
 	/usr/lib \
 	/usr/lib/abi \
 	/usr/lib/class \
@@ -810,6 +811,8 @@
 $(ROOT)/usr/lib/libkstat.so.1:=		REALPATH=../../lib/libkstat.so.1
 $(ROOT)/usr/lib/libkstat.so:=		REALPATH=../../lib/libkstat.so.1
 $(ROOT)/usr/lib/liblddbg.so.4:=		REALPATH=../../lib/liblddbg.so.4
+$(ROOT)/usr/lib/libmd.so.1:=		REALPATH=../../lib/libmd.so.1
+$(ROOT)/usr/lib/libmd.so:=		REALPATH=../../lib/libmd.so.1
 $(ROOT)/usr/lib/libmd5.so.1:=		REALPATH=../../lib/libmd5.so.1
 $(ROOT)/usr/lib/libmd5.so:=		REALPATH=../../lib/libmd5.so.1
 $(ROOT)/usr/lib/libmeta.so.1:=		REALPATH=../../lib/libmeta.so.1
@@ -1080,6 +1083,10 @@
 	REALPATH=../../../lib/$(MACH64)/libkstat.so.1
 $(ROOT)/usr/lib/$(MACH64)/liblddbg.so.4:= \
 	REALPATH=../../../lib/$(MACH64)/liblddbg.so.4
+$(ROOT)/usr/lib/$(MACH64)/libmd.so.1:= \
+	REALPATH=../../../lib/$(MACH64)/libmd.so.1
+$(ROOT)/usr/lib/$(MACH64)/libmd.so:= \
+	REALPATH=../../../lib/$(MACH64)/libmd.so.1
 $(ROOT)/usr/lib/$(MACH64)/libmd5.so.1:= \
 	REALPATH=../../../lib/$(MACH64)/libmd5.so.1
 $(ROOT)/usr/lib/$(MACH64)/libmd5.so:= \
@@ -1382,6 +1389,8 @@
 	/usr/lib/libkstat.so \
 	/usr/lib/libkstat.so.1 \
 	/usr/lib/liblddbg.so.4 \
+	/usr/lib/libmd.so \
+	/usr/lib/libmd.so.1 \
 	/usr/lib/libmd5.so \
 	/usr/lib/libmd5.so.1 \
 	/usr/lib/libmeta.so \
@@ -1615,6 +1624,8 @@
 	/usr/lib/$(MACH64)/libkstat.so \
 	/usr/lib/$(MACH64)/libkstat.so.1 \
 	/usr/lib/$(MACH64)/liblddbg.so.4 \
+	/usr/lib/$(MACH64)/libmd.so \
+	/usr/lib/$(MACH64)/libmd.so.1 \
 	/usr/lib/$(MACH64)/libmd5.so \
 	/usr/lib/$(MACH64)/libmd5.so.1 \
 	/usr/lib/$(MACH64)/libmp.so \
--- a/usr/src/cmd/bart/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/cmd/bart/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -22,8 +21,8 @@
 #
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 #
-#  Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
-#  Use is subject to license terms.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
 
 PROG=	bart
 SRCS=	rules.c create.c compare.c main.c lutbl.c
@@ -31,7 +30,7 @@
 BART=	bart
 
 include ../Makefile.cmd
-LDLIBS +=	-lsec -lmd5
+LDLIBS +=	-lsec -lmd
 
 #
 # for messaging catalog
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -1,7 +1,7 @@
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # cmd/cmd-inet/usr.bin/pppd/Makefile
@@ -24,7 +24,7 @@
 clobber:=	TARGET= clobber
 lint:=		TARGET= lint
 
-LDLIBS +=	-lpam -lmd5 -lsocket -lnsl
+LDLIBS +=	-lpam -lmd -lsocket -lnsl
 
 #
 # We need absolute path to /etc/ppp/plugins and /usr/lib/inet/ppp, not
@@ -48,16 +48,15 @@
 CPPFLAGS +=	-DHAVE_CRYPT_H -DUSE_CRYPT
 CPPFLAGS +=	-DCHAPMS -DMSLANMAN
 CPPFLAGS +=	-DCHAPMSV2
-OBJS +=		chap_ms.o md4.o sha1.o
+OBJS +=		chap_ms.o
 EXOBJS +=	mschap_test.o
 CLOBBERFILES +=	mschap_test
 
 # This is used *only* for testing the portability of the libraries
 # required for MS-CHAPv1.  It is not needed in any normal system and
 # is not built by default.
-mschap_test:	mschap_test.o chap_ms.o md4.o sha1.o
-	$(LINK.c) -o mschap_test mschap_test.o chap_ms.o md4.o sha1.o \
-		$(LDFLAGS)
+mschap_test:	mschap_test.o chap_ms.o
+	$(LINK.c) -o mschap_test mschap_test.o chap_ms.o $(LDFLAGS)
 	@echo "Run with 'mschap_test 00000000000000000000000000000000 hello'"
 	@echo
 	@echo "Output should be:"
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/md4.c	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
-/*
-** ********************************************************************
-** md4.c -- Implementation of MD4 Message Digest Algorithm           **
-** Updated: 2/16/90 by Ronald L. Rivest                              **
-** (C) 1990 RSA Data Security, Inc.                                  **
-** ********************************************************************
- *
- * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-/*
-** To use MD4:
-**   -- Include md4.h in your program
-**   -- Declare an MDstruct MD to hold the state of the digest
-**          computation.
-**   -- Initialize MD using MDbegin(&MD)
-**   -- For each full block (64 bytes) X you wish to process, call
-**          MD4Update(&MD,X,512)
-**      (512 is the number of bits in a full block.)
-**   -- For the last block (less than 64 bytes) you wish to process,
-**          MD4Update(&MD,X,n)
-**      where n is the number of bits in the partial block. A partial
-**      block terminates the computation, so every MD computation
-**      should terminate by processing a partial block, even if it
-**      has n = 0.
-**   -- The message digest is available in MD.buffer[0] ...
-**      MD.buffer[3].  (Least-significant byte of each word
-**      should be output first.)
-**   -- You can print out the digest using MDprint(&MD)
-*/
-
-/* Implementation notes:
-** This implementation assumes that ints are 32-bit quantities.
-*/
-
-#define TRUE  1
-#define FALSE 0
-
-/* Compile-time includes
-*/
-#include <stdio.h>
-#include "md4.h"
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#define RCSID	"$Id: $"
-
-#if !defined(lint) && !defined(_lint)
-static const char rcsid[] = RCSID;
-#endif
-
-/* Compile-time declarations of MD4 "magic constants".
-*/
-#define I0  0x67452301       /* Initial values for MD buffer */
-#define I1  0xefcdab89
-#define I2  0x98badcfe
-#define I3  0x10325476
-#define C2  013240474631     /* round 2 constant = sqrt(2) in octal */
-#define C3  015666365641     /* round 3 constant = sqrt(3) in octal */
-/* C2 and C3 are from Knuth, The Art of Programming, Volume 2
-** (Seminumerical Algorithms), Second Edition (1981), Addison-Wesley.
-** Table 2, page 660.
-*/
-
-#define fs1  3               /* round 1 shift amounts */
-#define fs2  7
-#define fs3 11
-#define fs4 19
-#define gs1  3               /* round 2 shift amounts */
-#define gs2  5
-#define gs3  9
-#define gs4 13
-#define hs1  3               /* round 3 shift amounts */
-#define hs2  9
-#define hs3 11
-#define hs4 15
-
-/* Compile-time macro declarations for MD4.
-** Note: The "rot" operator uses the variable "tmp".
-** It assumes tmp is declared as unsigned int, so that the >>
-** operator will shift in zeros rather than extending the sign bit.
-*/
-#define f(X,Y,Z)             ((X&Y) | ((~X)&Z))
-#define g(X,Y,Z)             ((X&Y) | (X&Z) | (Y&Z))
-#define h(X,Y,Z)             (X^Y^Z)
-#define rot(X,S)             (tmp=X,(tmp<<S) | (tmp>>(32-S)))
-#define ff(A,B,C,D,i,s)      A = rot((A + f(B,C,D) + X[i]),s)
-#define gg(A,B,C,D,i,s)      A = rot((A + g(B,C,D) + X[i] + C2),s)
-#define hh(A,B,C,D,i,s)      A = rot((A + h(B,C,D) + X[i] + C3),s)
-
-/* MD4Init(MDp)
-** Initialize message digest buffer MDp.
-** This is a user-callable routine.
-*/
-void
-MD4Init(MDp)
-MD4_CTX *MDp;
-{
-  int i;
-  MDp->buffer[0] = I0;
-  MDp->buffer[1] = I1;
-  MDp->buffer[2] = I2;
-  MDp->buffer[3] = I3;
-  for (i=0;i<8;i++) MDp->count[i] = 0;
-  MDp->done = 0;
-}
-
-/* MDblock(MDp,X)
-** Update message digest buffer MDp->buffer using 16-word data block X.
-** Assumes all 16 words of X are full of data.
-** Does not update MDp->count.
-** This routine is not user-callable.
-*/
-static void
-MDblock(MD4_CTX *MDp, const unsigned char *Xb)
-{
-  register unsigned int tmp, A, B, C, D;
-  unsigned int X[16];
-  int i;
-
-  for (i = 0; i < 16; ++i) {
-    X[i] = Xb[0] + (Xb[1] << 8) + (Xb[2] << 16) + (Xb[3] << 24);
-    Xb += 4;
-  }
-
-  A = MDp->buffer[0];
-  B = MDp->buffer[1];
-  C = MDp->buffer[2];
-  D = MDp->buffer[3];
-  /* Update the message digest buffer */
-  ff(A , B , C , D ,  0 , fs1); /* Round 1 */
-  ff(D , A , B , C ,  1 , fs2);
-  ff(C , D , A , B ,  2 , fs3);
-  ff(B , C , D , A ,  3 , fs4);
-  ff(A , B , C , D ,  4 , fs1);
-  ff(D , A , B , C ,  5 , fs2);
-  ff(C , D , A , B ,  6 , fs3);
-  ff(B , C , D , A ,  7 , fs4);
-  ff(A , B , C , D ,  8 , fs1);
-  ff(D , A , B , C ,  9 , fs2);
-  ff(C , D , A , B , 10 , fs3);
-  ff(B , C , D , A , 11 , fs4);
-  ff(A , B , C , D , 12 , fs1);
-  ff(D , A , B , C , 13 , fs2);
-  ff(C , D , A , B , 14 , fs3);
-  ff(B , C , D , A , 15 , fs4);
-  gg(A , B , C , D ,  0 , gs1); /* Round 2 */
-  gg(D , A , B , C ,  4 , gs2);
-  gg(C , D , A , B ,  8 , gs3);
-  gg(B , C , D , A , 12 , gs4);
-  gg(A , B , C , D ,  1 , gs1);
-  gg(D , A , B , C ,  5 , gs2);
-  gg(C , D , A , B ,  9 , gs3);
-  gg(B , C , D , A , 13 , gs4);
-  gg(A , B , C , D ,  2 , gs1);
-  gg(D , A , B , C ,  6 , gs2);
-  gg(C , D , A , B , 10 , gs3);
-  gg(B , C , D , A , 14 , gs4);
-  gg(A , B , C , D ,  3 , gs1);
-  gg(D , A , B , C ,  7 , gs2);
-  gg(C , D , A , B , 11 , gs3);
-  gg(B , C , D , A , 15 , gs4);
-  hh(A , B , C , D ,  0 , hs1); /* Round 3 */
-  hh(D , A , B , C ,  8 , hs2);
-  hh(C , D , A , B ,  4 , hs3);
-  hh(B , C , D , A , 12 , hs4);
-  hh(A , B , C , D ,  2 , hs1);
-  hh(D , A , B , C , 10 , hs2);
-  hh(C , D , A , B ,  6 , hs3);
-  hh(B , C , D , A , 14 , hs4);
-  hh(A , B , C , D ,  1 , hs1);
-  hh(D , A , B , C ,  9 , hs2);
-  hh(C , D , A , B ,  5 , hs3);
-  hh(B , C , D , A , 13 , hs4);
-  hh(A , B , C , D ,  3 , hs1);
-  hh(D , A , B , C , 11 , hs2);
-  hh(C , D , A , B ,  7 , hs3);
-  hh(B , C , D , A , 15 , hs4);
-  MDp->buffer[0] += A;
-  MDp->buffer[1] += B;
-  MDp->buffer[2] += C;
-  MDp->buffer[3] += D;
-}
-
-/* MD4Update(MDp,X,count)
-** Input: X -- a pointer to an array of unsigned characters.
-**        count -- the number of bits of X to use.
-**          (if not a multiple of 8, uses high bits of last byte.)
-** Update MDp using the number of bits of X given by count.
-** This is the basic input routine for an MD4 user.
-** The routine completes the MD computation when count < 512, so
-** every MD computation should end with one call to MD4Update with a
-** count less than 512.  A call with count 0 will be ignored if the
-** MD has already been terminated (done != 0), so an extra call with
-** count 0 can be given as a "courtesy close" to force termination
-** if desired.
-*/
-void
-MD4Update(MDp,X,count)
-MD4_CTX *MDp;
-const unsigned char *X;
-unsigned int count;
-{
-  unsigned int i, tmp, bit, byte, mask;
-  unsigned char XX[64];
-  unsigned char *p;
-
-  /* return with no error if this is a courtesy close with count
-  ** zero and MDp->done is true.
-  */
-  if (count == 0 && MDp->done) return;
-  /* check to see if MD is already done and report error */
-  if (MDp->done)
-  { (void) printf("\nError: MD4Update MD already done."); return; }
-
-  /* Add count to MDp->count */
-  tmp = count;
-  p = MDp->count;
-  while (tmp)
-  { tmp += *p;
-  *p++ = tmp;
-  tmp = tmp >> 8;
-  }
-
-  /* Process data */
-  if (count == 512)
-  { /* Full block of data to handle */
-    MDblock(MDp,X);
-  }
-  else if (count > 512) /* Check for count too large */
-  {
-    (void) printf("\nError: MD4Update called with illegal count value %d.",
-	   count);
-    return;
-  }
-  else /* partial block -- must be last block so finish up */
-  {
-    /* Find out how many bytes and residual bits there are */
-    byte = count >> 3;
-    bit =  count & 7;
-    /* Copy X into XX since we need to modify it */
-    for (i=0;i<=byte;i++)   XX[i] = X[i];
-    for (i=byte+1;i<64;i++) XX[i] = 0;
-    /* Add padding '1' bit and low-order zeros in last byte */
-    mask = 1 << (7 - bit);
-    XX[byte] = (XX[byte] | mask) & ~( mask - 1);
-    /* If room for bit count, finish up with this block */
-    if (byte <= 55)
-    {
-      for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
-      MDblock(MDp,XX);
-    }
-    else /* need to do two blocks to finish up */
-    {
-      MDblock(MDp,XX);
-      for (i=0;i<56;i++) XX[i] = 0;
-      for (i=0;i<8;i++)  XX[56+i] = MDp->count[i];
-      MDblock(MDp,XX);
-    }
-    /* Set flag saying we're done with MD computation */
-    MDp->done = 1;
-  }
-}
-
-/*
-** Finish up MD4 computation and return message digest.
-*/
-void
-MD4Final(buf, MD)
-unsigned char *buf;
-MD4_CTX *MD;
-{
-  int i, j;
-  unsigned int w;
-
-  MD4Update(MD, NULL, 0);
-  for (i = 0; i < 4; ++i) {
-    w = MD->buffer[i];
-    for (j = 0; j < 4; ++j) {
-      *buf++ = w;
-      w >>= 8;
-    }
-  }
-}
-
-/*
-** End of md4.c
-****************************(cut)***********************************/
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/md4.h	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
-** ********************************************************************
-** md4.h -- Header file for implementation of                        **
-** MD4 Message Digest Algorithm                                      **
-** Updated: 2/13/90 by Ronald L. Rivest                              **
-** (C) 1990 RSA Data Security, Inc.                                  **
-** ********************************************************************
- *
- * Copyright (c) 2000 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifndef __P
-# if defined(__STDC__) || defined(__GNUC__)
-#  define __P(x) x
-# else
-#  define __P(x) ()
-# endif
-#endif
-
-
-/* MDstruct is the data structure for a message digest computation.
-*/
-typedef struct {
-	unsigned int buffer[4]; /* Holds 4-word result of MD computation */
-	unsigned char count[8]; /* Number of bits processed so far */
-	unsigned int done;      /* Nonzero means MD computation finished */
-} MD4_CTX;
-
-/* MD4Init(MD4_CTX *)
-** Initialize the MD4_CTX prepatory to doing a message digest
-** computation.
-*/
-extern void MD4Init __P((MD4_CTX *MD));
-
-/* MD4Update(MD,X,count)
-** Input: X -- a pointer to an array of unsigned characters.
-**        count -- the number of bits of X to use (an unsigned int).
-** Updates MD using the first "count" bits of X.
-** The array pointed to by X is not modified.
-** If count is not a multiple of 8, MD4Update uses high bits of
-** last byte.
-** This is the basic input routine for a user.
-** The routine terminates the MD computation when count < 512, so
-** every MD computation should end with one call to MD4Update with a
-** count less than 512.  Zero is OK for a count.
-*/
-extern void MD4Update __P((MD4_CTX *MD, const unsigned char *X,
-    unsigned int count));
-
-/* MD4Final(buf, MD)
-** Returns message digest from MD and terminates the message
-** digest computation.
-*/
-extern void MD4Final __P((unsigned char *, MD4_CTX *));
-
-/*
-** End of md4.h
-****************************(cut)***********************************/
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.c	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,755 +0,0 @@
-/*
- * Copyright (c) 1998-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-/*
- * The basic framework for this code came from the reference
- * implementation for MD5.  That implementation is Copyright (C)
- * 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- *
- * NOTE: Cleaned-up and optimized, version of SHA1, based on the FIPS 180-1
- * standard, available at http://www.itl.nist.gov/div897/pubs/fip180-1.htm
- * Not as fast as one would like -- further optimizations are encouraged
- * and appreciated.
- */
-
-#include <strings.h>
-#include <sys/types.h>
-#include "sha1.h"
-#include "sha1_consts.h"
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#define	RCSID	"$Id: $"
-
-#if !defined(lint) && !defined(_lint)
-static const char rcsid[] = RCSID;
-#endif
-
-static void Encode(uint8_t *, uint32_t *, size_t);
-static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
-    SHA1_CTX *, const uint8_t *);
-
-static uint8_t PADDING[64] = { 0x80, /* all zeros */ };
-
-/*
- * F, G, and H are the basic SHA1 functions.
- */
-#define	F(b, c, d)	(((b) & (c)) | ((~b) & (d)))
-#define	G(b, c, d)	((b) ^ (c) ^ (d))
-#define	H(b, c, d)	(((b) & (c)) | ((b) & (d)) | ((c) & (d)))
-
-/*
- * ROTATE_LEFT rotates x left n bits.
- */
-#define	ROTATE_LEFT(x, n)	\
-	(((x) << (n)) | ((x) >> ((sizeof (x) * NBBY)-(n))))
-
-/*
- * SHA1Init()
- *
- * purpose: initializes the sha1 context and begins and sha1 digest operation
- *   input: SHA1_CTX *	: the context to initialize.
- *  output: void
- */
-
-void
-SHA1Init(SHA1_CTX *ctx)
-{
-	ctx->count[0] = ctx->count[1] = 0;
-
-	/*
-	 * load magic initialization constants. Tell lint
-	 * that these constants are unsigned by using U.
-	 */
-
-	ctx->state[0] = 0x67452301U;
-	ctx->state[1] = 0xefcdab89U;
-	ctx->state[2] = 0x98badcfeU;
-	ctx->state[3] = 0x10325476U;
-	ctx->state[4] = 0xc3d2e1f0U;
-}
-
-/*
- * SHA1Update()
- *
- * purpose: continues an sha1 digest operation, using the message block
- *          to update the context.
- *   input: SHA1_CTX *	: the context to update
- *          uint8_t *	: the message block
- *          uint32_t    : the length of the message block in bytes
- *  output: void
- */
-
-void
-SHA1Update(SHA1_CTX *ctx, const uint8_t *input, uint32_t input_len)
-{
-	uint32_t i, buf_index, buf_len;
-
-	/* compute number of bytes mod 64 */
-	buf_index = (ctx->count[1] >> 3) & 0x3F;
-
-	/* update number of bits */
-	if ((ctx->count[1] += (input_len << 3)) < (input_len << 3))
-		ctx->count[0]++;
-
-	ctx->count[0] += (input_len >> 29);
-
-	buf_len = 64 - buf_index;
-
-	/* transform as many times as possible */
-	i = 0;
-	if (input_len >= buf_len) {
-
-		/*
-		 * general optimization:
-		 *
-		 * only do initial bcopy() and SHA1Transform() if
-		 * buf_index != 0.  if buf_index == 0, we're just
-		 * wasting our time doing the bcopy() since there
-		 * wasn't any data left over from a previous call to
-		 * SHA1Update().
-		 */
-
-		if (buf_index) {
-			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
-
-
-			SHA1Transform(ctx->state[0], ctx->state[1],
-			    ctx->state[2], ctx->state[3], ctx->state[4], ctx,
-			    ctx->buf_un.buf8);
-
-			i = buf_len;
-		}
-
-		for (; i + 63 < input_len; i += 64)
-			SHA1Transform(ctx->state[0], ctx->state[1],
-			    ctx->state[2], ctx->state[3], ctx->state[4],
-			    ctx, &input[i]);
-
-		/*
-		 * general optimization:
-		 *
-		 * if i and input_len are the same, return now instead
-		 * of calling bcopy(), since the bcopy() in this case
-		 * will be an expensive nop.
-		 */
-
-		if (input_len == i)
-			return;
-
-		buf_index = 0;
-	}
-
-	/* buffer remaining input */
-	bcopy(&input[i], &ctx->buf_un.buf8[buf_index], input_len - i);
-}
-
-/*
- * SHA1Final()
- *
- * purpose: ends an sha1 digest operation, finalizing the message digest and
- *          zeroing the context.
- *   input: uint8_t *	: a buffer to store the digest in
- *          SHA1_CTX *  : the context to finalize, save, and zero
- *  output: void
- */
-
-void
-SHA1Final(uint8_t *digest, SHA1_CTX *ctx)
-{
-	uint8_t		bitcount_be[sizeof (ctx->count)];
-	uint32_t	index = (ctx->count[1] >> 3) & 0x3f;
-
-	/* store bit count, big endian */
-	Encode(bitcount_be, ctx->count, sizeof (bitcount_be));
-
-	/* pad out to 56 mod 64 */
-	SHA1Update(ctx, PADDING, ((index < 56) ? 56 : 120) - index);
-
-	/* append length (before padding) */
-	SHA1Update(ctx, bitcount_be, sizeof (bitcount_be));
-
-	/* store state in digest */
-	Encode(digest, ctx->state, sizeof (ctx->state));
-
-	/* zeroize sensitive information */
-	bzero(ctx, sizeof (*ctx));
-}
-
-/*
- * sparc optimization:
- *
- * on the sparc, we can load big endian 32-bit data easily.  note that
- * special care must be taken to ensure the address is 32-bit aligned.
- * in the interest of speed, we don't check to make sure, since
- * careful programming can guarantee this for us.
- */
-
-#if	defined(__sparc)
-
-#define	LOAD_LITTLE_32(addr)	(*(uint32_t *)(addr))
-
-#else	/* little endian -- will work on big endian, but slowly */
-
-#define	LOAD_LITTLE_32(addr)	\
-	(((addr)[0] << 24) | ((addr)[1] << 16) | ((addr)[2] << 8) | (addr)[3])
-#endif
-
-/*
- * sparc register window optimization:
- *
- * `a', `b', `c', `d', and `e' are passed into SHA1Transform
- * explicitly since it increases the number of registers available to
- * the compiler.  under this scheme, these variables can be held in
- * %i0 - %i4, which leaves more local and out registers available.
- */
-
-/*
- * SHA1Transform()
- *
- * purpose: sha1 transformation -- updates the digest based on `block'
- *   input: uint32_t	: bytes  1 -  4 of the digest
- *          uint32_t	: bytes  5 -  8 of the digest
- *          uint32_t	: bytes  9 - 12 of the digest
- *          uint32_t	: bytes 12 - 16 of the digest
- *          uint32_t	: bytes 16 - 20 of the digest
- *          SHA1_CTX *	: the context to update
- *          uint8_t [64]: the block to use to update the digest
- *  output: void
- */
-
-void
-SHA1Transform(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e,
-    SHA1_CTX *ctx, const uint8_t blk[64])
-{
-	/*
-	 * sparc optimization:
-	 *
-	 * while it is somewhat counter-intuitive, on sparc, it is
-	 * more efficient to place all the constants used in this
-	 * function in an array and load the values out of the array
-	 * than to manually load the constants.  this is because
-	 * setting a register to a 32-bit value takes two ops in most
-	 * cases: a `sethi' and an `or', but loading a 32-bit value
-	 * from memory only takes one `ld' (or `lduw' on v9).  while
-	 * this increases memory usage, the compiler can find enough
-	 * other things to do while waiting to keep the pipeline does
-	 * not stall.  additionally, it is likely that many of these
-	 * constants are cached so that later accesses do not even go
-	 * out to the bus.
-	 *
-	 * this array is declared `static' to keep the compiler from
-	 * having to bcopy() this array onto the stack frame of
-	 * SHA1Transform() each time it is called -- which is
-	 * unacceptably expensive.
-	 *
-	 * the `const' is to ensure that callers are good citizens and
-	 * do not try to munge the array.  since these routines are
-	 * going to be called from inside multithreaded kernelland,
-	 * this is a good safety check. -- `sha1_consts' will end up in
-	 * .rodata.
-	 *
-	 * unfortunately, loading from an array in this manner hurts
-	 * performance under intel.  so, there is a macro,
-	 * SHA1_CONST(), used in SHA1Transform(), that either expands to
-	 * a reference to this array, or to the actual constant,
-	 * depending on what platform this code is compiled for.
-	 */
-
-#if	defined(__sparc)
-	static const uint32_t sha1_consts[] = {
-		SHA1_CONST_0,	SHA1_CONST_1,	SHA1_CONST_2,	SHA1_CONST_3,
-	};
-#endif
-
-	/*
-	 * general optimization:
-	 *
-	 * use individual integers instead of using an array.  this is a
-	 * win, although the amount it wins by seems to vary quite a bit.
-	 */
-
-	uint32_t	w_0, w_1, w_2,  w_3,  w_4,  w_5,  w_6,  w_7;
-	uint32_t	w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15;
-
-	/*
-	 * sparc optimization:
-	 *
-	 * if `block' is already aligned on a 4-byte boundary, use
-	 * LOAD_LITTLE_32() directly.  otherwise, bcopy() into a
-	 * buffer that *is* aligned on a 4-byte boundary and then do
-	 * the LOAD_LITTLE_32() on that buffer.  benchmarks have shown
-	 * that using the bcopy() is better than loading the bytes
-	 * individually and doing the endian-swap by hand.
-	 *
-	 * even though it's quite tempting to assign to do:
-	 *
-	 * blk = bcopy(ctx->buf_un.buf32, blk, sizeof (ctx->buf_un.buf32));
-	 *
-	 * and only have one set of LOAD_LITTLE_32()'s, the compiler
-	 * *does not* like that, so please resist the urge.
-	 */
-
-#if	defined(__sparc)
-	if ((uintptr_t)blk & 0x3) {		/* not 4-byte aligned? */
-		bcopy(blk, ctx->buf_un.buf32,  sizeof (ctx->buf_un.buf32));
-		w_15 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 15);
-		w_14 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 14);
-		w_13 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 13);
-		w_12 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 12);
-		w_11 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 11);
-		w_10 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 10);
-		w_9  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  9);
-		w_8  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  8);
-		w_7  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  7);
-		w_6  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  6);
-		w_5  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  5);
-		w_4  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  4);
-		w_3  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  3);
-		w_2  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  2);
-		w_1  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  1);
-		w_0  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  0);
-	} else
-#endif
-	{
-		/*LINTED*/
-		w_15 = LOAD_LITTLE_32(blk + 60);
-		/*LINTED*/
-		w_14 = LOAD_LITTLE_32(blk + 56);
-		/*LINTED*/
-		w_13 = LOAD_LITTLE_32(blk + 52);
-		/*LINTED*/
-		w_12 = LOAD_LITTLE_32(blk + 48);
-		/*LINTED*/
-		w_11 = LOAD_LITTLE_32(blk + 44);
-		/*LINTED*/
-		w_10 = LOAD_LITTLE_32(blk + 40);
-		/*LINTED*/
-		w_9  = LOAD_LITTLE_32(blk + 36);
-		/*LINTED*/
-		w_8  = LOAD_LITTLE_32(blk + 32);
-		/*LINTED*/
-		w_7  = LOAD_LITTLE_32(blk + 28);
-		/*LINTED*/
-		w_6  = LOAD_LITTLE_32(blk + 24);
-		/*LINTED*/
-		w_5  = LOAD_LITTLE_32(blk + 20);
-		/*LINTED*/
-		w_4  = LOAD_LITTLE_32(blk + 16);
-		/*LINTED*/
-		w_3  = LOAD_LITTLE_32(blk + 12);
-		/*LINTED*/
-		w_2  = LOAD_LITTLE_32(blk +  8);
-		/*LINTED*/
-		w_1  = LOAD_LITTLE_32(blk +  4);
-		/*LINTED*/
-		w_0  = LOAD_LITTLE_32(blk +  0);
-	}
-
-	/*
-	 * general optimization:
-	 *
-	 * even though this approach is described in the standard as
-	 * being slower algorithmically, it is 30-40% faster than the
-	 * "faster" version under SPARC, because this version has more
-	 * of the constraints specified at compile-time and uses fewer
-	 * variables (and therefore has better register utilization)
-	 * than its "speedier" brother.  (i've tried both, trust me)
-	 *
-	 * for either method given in the spec, there is an "assignment"
-	 * phase where the following takes place:
-	 *
-	 *	tmp = (main_computation);
-	 *	e = d; d = c; c = rotate_left(b, 30); b = a; a = tmp;
-	 *
-	 * we can make the algorithm go faster by not doing this work,
-	 * but just pretending that `d' is now `e', etc. this works
-	 * really well and obviates the need for a temporary variable.
-	 * however, we still explictly perform the rotate action,
-	 * since it is cheaper on SPARC to do it once than to have to
-	 * do it over and over again.
-	 */
-
-	/* round 1 */
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_0 + SHA1_CONST(0); /* 0 */
-	b = ROTATE_LEFT(b, 30);
-
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_1 + SHA1_CONST(0); /* 1 */
-	a = ROTATE_LEFT(a, 30);
-
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_2 + SHA1_CONST(0); /* 2 */
-	e = ROTATE_LEFT(e, 30);
-
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_3 + SHA1_CONST(0); /* 3 */
-	d = ROTATE_LEFT(d, 30);
-
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_4 + SHA1_CONST(0); /* 4 */
-	c = ROTATE_LEFT(c, 30);
-
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_5 + SHA1_CONST(0); /* 5 */
-	b = ROTATE_LEFT(b, 30);
-
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_6 + SHA1_CONST(0); /* 6 */
-	a = ROTATE_LEFT(a, 30);
-
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_7 + SHA1_CONST(0); /* 7 */
-	e = ROTATE_LEFT(e, 30);
-
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_8 + SHA1_CONST(0); /* 8 */
-	d = ROTATE_LEFT(d, 30);
-
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_9 + SHA1_CONST(0); /* 9 */
-	c = ROTATE_LEFT(c, 30);
-
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_10 + SHA1_CONST(0); /* 10 */
-	b = ROTATE_LEFT(b, 30);
-
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_11 + SHA1_CONST(0); /* 11 */
-	a = ROTATE_LEFT(a, 30);
-
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_12 + SHA1_CONST(0); /* 12 */
-	e = ROTATE_LEFT(e, 30);
-
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_13 + SHA1_CONST(0); /* 13 */
-	d = ROTATE_LEFT(d, 30);
-
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_14 + SHA1_CONST(0); /* 14 */
-	c = ROTATE_LEFT(c, 30);
-
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_15 + SHA1_CONST(0); /* 15 */
-	b = ROTATE_LEFT(b, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 16 */
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_0 + SHA1_CONST(0);
-	a = ROTATE_LEFT(a, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 17 */
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_1 + SHA1_CONST(0);
-	e = ROTATE_LEFT(e, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 18 */
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_2 + SHA1_CONST(0);
-	d = ROTATE_LEFT(d, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 19 */
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_3 + SHA1_CONST(0);
-	c = ROTATE_LEFT(c, 30);
-
-	/* round 2 */
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 20 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_4 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 21 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_5 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 22 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_6 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 23 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_7 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 24 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_8 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 25 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_9 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 26 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_10 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 27 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_11 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 28 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_12 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 29 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_13 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 30 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_14 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 31 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_15 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 32 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_0 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 33 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_1 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 34 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_2 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 35 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_3 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 36 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_4 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 37 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_5 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 38 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_6 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 39 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_7 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	/* round 3 */
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 40 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_8 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 41 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_9 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 42 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_10 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 43 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_11 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 44 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_12 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 45 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_13 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 46 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_14 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 47 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_15 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 48 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_0 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 49 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_1 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 50 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_2 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 51 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_3 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 52 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_4 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 53 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_5 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 54 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_6 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 55 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_7 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 56 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_8 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 57 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_9 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 58 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_10 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 59 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_11 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	/* round 4 */
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 60 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_12 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 61 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_13 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 62 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_14 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 63 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_15 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 64 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_0 + SHA1_CONST(3);
-	c = ROTATE_LEFT(c, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 65 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_1 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 66 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_2 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 67 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_3 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 68 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_4 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 69 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_5 + SHA1_CONST(3);
-	c = ROTATE_LEFT(c, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 70 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_6 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 71 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_7 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 72 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_8 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 73 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_9 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 74 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_10 + SHA1_CONST(3);
-	c = ROTATE_LEFT(c, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 75 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_11 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 76 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_12 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 77 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_13 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 78 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_14 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 79 */
-
-	ctx->state[0] += ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_15 +
-	    SHA1_CONST(3);
-	ctx->state[1] += b;
-	ctx->state[2] += ROTATE_LEFT(c, 30);
-	ctx->state[3] += d;
-	ctx->state[4] += e;
-
-	/* zeroize sensitive information */
-	w_0 = w_1 = w_2 = w_3 = w_4 = w_5 = w_6 = w_7 = w_8 = 0;
-	w_9 = w_10 = w_11 = w_12 = w_13 = w_14 = w_15 = 0;
-}
-
-/*
- * devpro compiler optimization:
- *
- * the compiler can generate better code if it knows that `input' and
- * `output' do not point to the same source.  there is no portable
- * way to tell the compiler this, but the sun compiler recognizes the
- * `_Restrict' keyword to indicate this condition.  use it if possible.
- */
-
-#ifdef	__RESTRICT
-#define	restrict	_Restrict
-#else
-#define	restrict	/* nothing */
-#endif
-
-/*
- * Encode()
- *
- * purpose: to convert a list of numbers from little endian to big endian
- *   input: uint8_t *	: place to store the converted big endian numbers
- *	    uint32_t *	: place to get numbers to convert from
- *          size_t	: the length of the input in bytes
- *  output: void
- */
-
-static void
-Encode(uint8_t *restrict output, uint32_t *restrict input, size_t len)
-{
-	size_t		i, j;
-
-	for (i = 0, j = 0; j < len; i++, j += 4) {
-
-#if	defined(__sparc)
-
-		/*LINTED*/
-		*(uint32_t *)(output + j) = input[i];
-
-#else	/* little endian -- will work on big endian, but slowly */
-
-		output[j]	= (input[i] >> 24) & 0xff;
-		output[j + 1]	= (input[i] >> 16) & 0xff;
-		output[j + 2]	= (input[i] >>  8) & 0xff;
-		output[j + 3]	= input[i] & 0xff;
-
-#endif
-	}
-}
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1.h	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1998, 2000 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#ifndef _SHA1_H
-#define	_SHA1_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/types.h>		/* for uint_* */
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#if defined(sun) && !defined(_SYS_INT_TYPES_H) && !defined(_UINT32_T)
-/* Backward compatibility */
-typedef uint_t uint32_t;
-typedef ushort_t uint16_t;
-typedef uchar_t uint8_t;
-typedef unsigned long uintptr_t;
-#define	_UINT32_T
-#endif
-
-#ifdef __linux__
-#include <stdint.h>
-#endif
-
-/* SHA-1 context. */
-typedef struct 	{
-	uint32_t state[5];	/* state (ABCDE) */
-	uint32_t count[2];	/* number of bits, modulo 2^64 (msb first) */
-	union 	{
-		uint8_t		buf8[64];	/* undigested input */
-		uint32_t	buf32[16];	/* realigned input */
-	} buf_un;
-} SHA1_CTX;
-
-void SHA1Init(SHA1_CTX *);
-void SHA1Update(SHA1_CTX *, const uint8_t *, uint32_t);
-void SHA1Final(uint8_t *, SHA1_CTX *);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _SHA1_H */
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/sha1_consts.h	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1998, by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#ifndef	_SHA1_CONSTS_H
-#define	_SHA1_CONSTS_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/*
- * as explained in sha1.c, loading 32-bit constants on a sparc is expensive
- * since it involves both a `sethi' and an `or'.  thus, we instead use `ld'
- * to load the constants from an array called `sha1_consts'.  however, on
- * intel (and perhaps other processors), it is cheaper to load the constant
- * directly.  thus, the c code in SHA1Transform() uses the macro SHA1_CONST()
- * which either expands to a constant or an array reference, depending on
- * the architecture the code is being compiled for.
- */
-
-#include <sys/types.h>		/* uint32_t */
-
-extern	const uint32_t	sha1_consts[];
-
-#if	defined(__sparc)
-#define	SHA1_CONST(x)		(sha1_consts[x])
-#else
-#define	SHA1_CONST(x)		(SHA1_CONST_ ## x)
-#endif
-
-/* constants, as provided in FIPS 180-1 */
-
-#define	SHA1_CONST_0		0x5a827999U
-#define	SHA1_CONST_1		0x6ed9eba1U
-#define	SHA1_CONST_2		0x8f1bbcdcU
-#define	SHA1_CONST_3		0xca62c1d6U
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _SHA1_CONSTS_H */
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -1,7 +1,7 @@
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -33,7 +33,7 @@
 
 CPPFLAGS +=	$(_D_XOPEN_EXTN)
 CFLAGS +=	$(CCVERBOSE)
-LDLIBS +=	-lxnet -lmd5 -lsocket
+LDLIBS +=	-lxnet -lmd -lsocket
 CLEAN_FILES +=	$(ROUTEDOBJS) $(RTQUERYOBJS)
 CLOBBERFILES +=	$(ROUTEDPROG) $(RTQUERYPROG)
 #
--- a/usr/src/cmd/ipf/tools/Makefile.tools	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/cmd/ipf/tools/Makefile.tools	Tue Mar 28 08:45:30 2006 -0800
@@ -1,9 +1,9 @@
 #
-# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
+# ident	"%Z%%M%	%I%	%E% SMI"
 #
 
 PROG=		ipf ipfs ipmon ipnat ippool ipfstat
@@ -44,7 +44,7 @@
 ipfstat		:=	LDLIBS += -lcurses
 
 ipf		:=	LDLIBS += -lsocket -lnsl
-ipftest		:=	LDLIBS += -lsocket -lnsl -lmd5
+ipftest		:=	LDLIBS += -lsocket -lnsl -lmd
 ipfstat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
 ipmon		:=	LDLIBS += -lsocket -lnsl
 ipnat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
--- a/usr/src/cmd/volmgt/vold/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/cmd/volmgt/vold/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -41,7 +40,7 @@
 OBJS=	nfs_server.o nfs_trace.o vold_err.o vold_main.o vold_proc.o \
 	vold_node.o vold_util.o vold_dev.o vold_config.o vold_vol.o \
 	vold_label.o vold_db.o vold_path.o vold_props.o vold_action.o \
-	vold_obj.o vold_md4.o vold_mnt.o medium.o partition.o \
+	vold_obj.o vold_mnt.o medium.o partition.o \
 	hsfs_partition.o pcfs_partition.o fdisk_partition.o \
 	solaris_partition.o udfs_partition.o ufs_partition.o \
 	blank_partition.o vtoc.o name_factory.o vold_sysevent.o
@@ -68,7 +67,7 @@
 
 CFLAGS += $(CCVERBOSE) -D_FILE_OFFSET_BITS=64
 
-$(PROG) :=	LDLIBS += -lnsl -ladm -lsmedia -lrpcsvc -lsysevent -lnvpair
+$(PROG) :=	LDLIBS += -lmd -lnsl -ladm -lsmedia -lrpcsvc -lsysevent -lnvpair
 $(SOFILES) :=	LDLIBS += -lc
 
 # to get the correct DSO flags used for compilation/linking
--- a/usr/src/cmd/volmgt/vold/md4.h	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright 1992 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	__MD4_H
-#define	__MD4_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-/*
- * MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
- */
-
-/*
- * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD4 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/* MD4 context. */
-typedef struct {
-	u_long state[4];	/* state (ABCD) */
-	u_long count[2];	/* number of bits, modulo 2^64 (lsb first) */
-	unsigned char buffer[64];	/* input buffer */
-} MD4_CTX;
-
-void MD4Init(MD4_CTX *);
-void MD4Update(MD4_CTX *, unsigned char *, unsigned int);
-void MD4Final(unsigned char [16], MD4_CTX *);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* __MD4_H */
--- a/usr/src/cmd/volmgt/vold/vold_md4.c	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-/*
- * Copyright 1994 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
- */
-
-/*
- * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD4 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
-
-#include	<string.h>
-#include	<sys/types.h>
-
-#include	"md4.h"
-
-/*
- * Constants for MD4Transform routine.
- */
-#define	S11 3
-#define	S12 7
-#define	S13 11
-#define	S14 19
-#define	S21 3
-#define	S22 5
-#define	S23 9
-#define	S24 13
-#define	S31 3
-#define	S32 9
-#define	S33 11
-#define	S34 15
-
-static void MD4Transform(u_long [4], unsigned char [64]);
-static void Encode(unsigned char *, u_long *, unsigned int);
-static void Decode(u_long *, unsigned char *, unsigned int);
-
-static unsigned char PADDING[64] = {
-	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/*
- * F, G and H are basic MD4 functions.
- */
-#define	F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define	G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
-#define	H(x, y, z) ((x) ^ (y) ^ (z))
-
-/*
- * ROTATE_LEFT rotates x left n bits.
- */
-#define	ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
-/* Rotation is separate from addition to prevent recomputation */
-
-#define	FF(a, b, c, d, x, s) { \
-		(a) += F((b), (c), (d)) + (x); \
-		(a) = ROTATE_LEFT((a), (s)); \
-	}
-#define	GG(a, b, c, d, x, s) { \
-		(a) += G((b), (c), (d)) + (x) + (u_long)0x5a827999; \
-		(a) = ROTATE_LEFT((a), (s)); \
-	}
-#define	HH(a, b, c, d, x, s) { \
-		(a) += H((b), (c), (d)) + (x) + (u_long)0x6ed9eba1; \
-		(a) = ROTATE_LEFT((a), (s)); \
-	}
-
-/*
- * MD4 initialization. Begins an MD4 operation, writing a new context.
- */
-void
-MD4Init(context)
-	MD4_CTX *context;			/* context */
-{
-	context->count[0] = context->count[1] = 0;
-
-	/*
-	 * Load magic initialization constants.
-	 */
-	context->state[0] = 0x67452301UL;
-	context->state[1] = 0xefcdab89UL;
-	context->state[2] = 0x98badcfeUL;
-	context->state[3] = 0x10325476UL;
-}
-
-
-/*
- * MD4 block update operation. Continues an MD4 message-digest
- * operation, processing another message block, and updating the
- * context.
- */
-void
-MD4Update(context, input, inputLen)
-	MD4_CTX *context;		/* context */
-	unsigned char *input;		/* input block */
-	unsigned int inputLen;		/* length of input block */
-{
-	unsigned int i, index, partLen;
-
-	/* Compute number of bytes mod 64 */
-	index = (unsigned int)((context->count[0] >> 3) & 0x3F);
-	/* Update number of bits */
-	if ((context->count[0] += ((u_long)inputLen << 3))
-	    < ((u_long)inputLen << 3))
-		context->count[1]++;
-	context->count[1] += ((u_long)inputLen >> 29);
-
-	partLen = 64 - index;
-
-	/*
-	 * Transform as many times as possible.
-	 */
-	if (inputLen >= partLen) {
-		(void) memcpy((char *)&context->buffer[index],
-		    (char *)input, partLen);
-		MD4Transform(context->state, context->buffer);
-
-		for (i = partLen; i + 63 < inputLen; i += 64) {
-			MD4Transform(context->state, &input[i]);
-		}
-
-		index = 0;
-	} else {
-		i = 0;
-	}
-
-	/* Buffer remaining input */
-	(void) memcpy((char *)&context->buffer[index],
-	    (char *)&input[i], inputLen-i);
-}
-
-/*
- * MD4 finalization. Ends an MD4 message-digest operation, writing the
- *	the message digest and zeroizing the context.
- */
-void
-MD4Final(digest, context)
-	unsigned char digest[16];		/* message digest */
-	MD4_CTX *context;			/* context */
-{
-	unsigned char bits[8];
-	unsigned int index, padLen;
-
-	/* Save number of bits */
-	Encode(bits, context->count, 8);
-
-	/*
-	 * Pad out to 56 mod 64.
-	 */
-	index = (unsigned int)((context->count[0] >> 3) & 0x3f);
-	padLen = (index < 56) ? (56 - index) : (120 - index);
-	MD4Update(context, PADDING, padLen);
-
-	/* Append length (before padding) */
-	MD4Update(context, bits, 8);
-	/* Store state in digest */
-	Encode(digest, context->state, 16);
-
-	/*
-	 * Zeroize sensitive information.
-	 */
-	(void) memset((char *)context, 0, sizeof (*context));
-}
-
-/*
- * MD4 basic transformation. Transforms state based on block.
- */
-static void
-MD4Transform(u_long state[4], unsigned char block[64])
-{
-	u_long a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
-
-	Decode(x, block, 64);
-
-	/* Round 1 */
-	FF(a, b, c, d, x[ 0], S11); /* 1 */
-	FF(d, a, b, c, x[ 1], S12); /* 2 */
-	FF(c, d, a, b, x[ 2], S13); /* 3 */
-	FF(b, c, d, a, x[ 3], S14); /* 4 */
-	FF(a, b, c, d, x[ 4], S11); /* 5 */
-	FF(d, a, b, c, x[ 5], S12); /* 6 */
-	FF(c, d, a, b, x[ 6], S13); /* 7 */
-	FF(b, c, d, a, x[ 7], S14); /* 8 */
-	FF(a, b, c, d, x[ 8], S11); /* 9 */
-	FF(d, a, b, c, x[ 9], S12); /* 10 */
-	FF(c, d, a, b, x[10], S13); /* 11 */
-	FF(b, c, d, a, x[11], S14); /* 12 */
-	FF(a, b, c, d, x[12], S11); /* 13 */
-	FF(d, a, b, c, x[13], S12); /* 14 */
-	FF(c, d, a, b, x[14], S13); /* 15 */
-	FF(b, c, d, a, x[15], S14); /* 16 */
-
-	/* Round 2 */
-	GG(a, b, c, d, x[ 0], S21); /* 17 */
-	GG(d, a, b, c, x[ 4], S22); /* 18 */
-	GG(c, d, a, b, x[ 8], S23); /* 19 */
-	GG(b, c, d, a, x[12], S24); /* 20 */
-	GG(a, b, c, d, x[ 1], S21); /* 21 */
-	GG(d, a, b, c, x[ 5], S22); /* 22 */
-	GG(c, d, a, b, x[ 9], S23); /* 23 */
-	GG(b, c, d, a, x[13], S24); /* 24 */
-	GG(a, b, c, d, x[ 2], S21); /* 25 */
-	GG(d, a, b, c, x[ 6], S22); /* 26 */
-	GG(c, d, a, b, x[10], S23); /* 27 */
-	GG(b, c, d, a, x[14], S24); /* 28 */
-	GG(a, b, c, d, x[ 3], S21); /* 29 */
-	GG(d, a, b, c, x[ 7], S22); /* 30 */
-	GG(c, d, a, b, x[11], S23); /* 31 */
-	GG(b, c, d, a, x[15], S24); /* 32 */
-
-
-	/* Round 3 */
-	HH(a, b, c, d, x[ 0], S31); /* 33 */
-	HH(d, a, b, c, x[ 8], S32); /* 34 */
-	HH(c, d, a, b, x[ 4], S33); /* 35 */
-	HH(b, c, d, a, x[12], S34); /* 36 */
-	HH(a, b, c, d, x[ 2], S31); /* 37 */
-	HH(d, a, b, c, x[10], S32); /* 38 */
-	HH(c, d, a, b, x[ 6], S33); /* 39 */
-	HH(b, c, d, a, x[14], S34); /* 40 */
-	HH(a, b, c, d, x[ 1], S31); /* 41 */
-	HH(d, a, b, c, x[ 9], S32); /* 42 */
-	HH(c, d, a, b, x[ 5], S33); /* 43 */
-	HH(b, c, d, a, x[13], S34); /* 44 */
-	HH(a, b, c, d, x[ 3], S31); /* 45 */
-	HH(d, a, b, c, x[11], S32); /* 46 */
-	HH(c, d, a, b, x[ 7], S33); /* 47 */
-	HH(b, c, d, a, x[15], S34); /* 48 */
-
-	state[0] += a;
-	state[1] += b;
-	state[2] += c;
-	state[3] += d;
-
-	/*
-	 * Zeroize sensitive information.
-	 */
-	(void) memset((char *)x, 0, sizeof (x));
-}
-
-/*
- * Encodes input (u_long) into output (unsigned char). Assumes len is
- * a multiple of 4.
- */
-static void
-Encode(output, input, len)
-	unsigned char *output;
-	u_long *input;
-	unsigned int len;
-{
-	unsigned int i, j;
-
-	for (i = 0, j = 0; j < len; i++, j += 4) {
-		output[j] = (unsigned char)(input[i] & 0xff);
-		output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
-		output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
-		output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
-	}
-}
-
-/*
- * Decodes input (unsigned char) into output (u_long). Assumes len is
- * a multiple of 4.
- */
-static void
-Decode(output, input, len)
-	u_long *output;
-	unsigned char *input;
-	unsigned int len;
-{
-	unsigned int i, j;
-
-	for (i = 0, j = 0; j < len; i++, j += 4)
-		output[i] = ((u_long)input[j]) |
-			(((u_long)input[j+1]) << 8) |
-			(((u_long)input[j+2]) << 16) |
-			(((u_long)input[j+3]) << 24);
-}
--- a/usr/src/cmd/xntpd/Makefile.cmd	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/cmd/xntpd/Makefile.cmd	Tue Mar 28 08:45:30 2006 -0800
@@ -1,11 +1,11 @@
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
-LIBS = -lsocket -lnsl -lrt -lmd5
+LIBS = -lsocket -lnsl -lrt -lmd
 
 LIBNTP_A= libntp/libntp.a
 LIBPARSE_A= libparse/libparse.a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/common/crypto/md4/md4.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,294 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+/*
+ * MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
+ */
+
+/*
+ * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD4 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+
+#include	<strings.h>
+#include	<sys/types.h>
+
+#include	"md4.h"
+
+/*
+ * Constants for MD4Transform routine.
+ */
+#define	S11 3
+#define	S12 7
+#define	S13 11
+#define	S14 19
+#define	S21 3
+#define	S22 5
+#define	S23 9
+#define	S24 13
+#define	S31 3
+#define	S32 9
+#define	S33 11
+#define	S34 15
+
+static void MD4Transform(ulong_t [4], unsigned char [64]);
+static void Encode(unsigned char *, ulong_t *, unsigned int);
+static void Decode(ulong_t *, unsigned char *, unsigned int);
+
+static unsigned char PADDING[64] = {
+	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*
+ * F, G and H are basic MD4 functions.
+ */
+#define	F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define	G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+#define	H(x, y, z) ((x) ^ (y) ^ (z))
+
+/*
+ * ROTATE_LEFT rotates x left n bits.
+ */
+#define	ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
+/* Rotation is separate from addition to prevent recomputation */
+
+#define	FF(a, b, c, d, x, s) { \
+		(a) += F((b), (c), (d)) + (x); \
+		(a) = ROTATE_LEFT((a), (s)); \
+	}
+#define	GG(a, b, c, d, x, s) { \
+		(a) += G((b), (c), (d)) + (x) + (ulong_t)0x5a827999; \
+		(a) = ROTATE_LEFT((a), (s)); \
+	}
+#define	HH(a, b, c, d, x, s) { \
+		(a) += H((b), (c), (d)) + (x) + (ulong_t)0x6ed9eba1; \
+		(a) = ROTATE_LEFT((a), (s)); \
+	}
+
+/*
+ * MD4 initialization. Begins an MD4 operation, writing a new context.
+ */
+void
+MD4Init(context)
+	MD4_CTX *context;			/* context */
+{
+	context->count[0] = context->count[1] = 0;
+
+	/*
+	 * Load magic initialization constants.
+	 */
+	context->state[0] = 0x67452301UL;
+	context->state[1] = 0xefcdab89UL;
+	context->state[2] = 0x98badcfeUL;
+	context->state[3] = 0x10325476UL;
+}
+
+
+/*
+ * MD4 block update operation. Continues an MD4 message-digest
+ * operation, processing another message block, and updating the
+ * context.
+ */
+void
+MD4Update(MD4_CTX *context, const void *_RESTRICT_KYWD inptr, size_t inputLen)
+{
+	unsigned int i, index, partLen;
+	uchar_t *input = (uchar_t *)inptr;
+
+	/* Compute number of bytes mod 64 */
+	index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+	/* Update number of bits */
+	if ((context->count[0] += ((ulong_t)inputLen << 3))
+	    < ((ulong_t)inputLen << 3))
+		context->count[1]++;
+	context->count[1] += ((ulong_t)inputLen >> 29);
+
+	partLen = 64 - index;
+
+	/*
+	 * Transform as many times as possible.
+	 */
+	if (inputLen >= partLen) {
+		bcopy(input, &context->buffer[index], partLen);
+		MD4Transform(context->state, (uchar_t *)context->buffer);
+
+		for (i = partLen; i + 63 < inputLen; i += 64) {
+			MD4Transform(context->state, (uchar_t *)&input[i]);
+		}
+
+		index = 0;
+	} else {
+		i = 0;
+	}
+
+	/* Buffer remaining input */
+	bcopy(&input[i], &context->buffer[index], inputLen - i);
+}
+
+/*
+ * MD4 finalization. Ends an MD4 message-digest operation, writing the
+ *	the message digest and zeroizing the context.
+ */
+void
+MD4Final(void *digest, MD4_CTX *context)
+{
+	unsigned char bits[8];
+	unsigned int index, padLen;
+
+	/* Save number of bits */
+	Encode(bits, context->count, 8);
+
+	/*
+	 * Pad out to 56 mod 64.
+	 */
+	index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+	padLen = (index < 56) ? (56 - index) : (120 - index);
+	MD4Update(context, PADDING, padLen);
+
+	/* Append length (before padding) */
+	MD4Update(context, bits, 8);
+	/* Store state in digest */
+	Encode(digest, context->state, 16);
+
+	/* zeroize sensitive information */
+	bzero(context, sizeof (*context));
+}
+
+/*
+ * MD4 basic transformation. Transforms state based on block.
+ */
+static void
+MD4Transform(ulong_t state[4], unsigned char block[64])
+{
+	ulong_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+
+
+	Decode(x, block, 64);
+
+	/* Round 1 */
+	FF(a, b, c, d, x[ 0], S11); /* 1 */
+	FF(d, a, b, c, x[ 1], S12); /* 2 */
+	FF(c, d, a, b, x[ 2], S13); /* 3 */
+	FF(b, c, d, a, x[ 3], S14); /* 4 */
+	FF(a, b, c, d, x[ 4], S11); /* 5 */
+	FF(d, a, b, c, x[ 5], S12); /* 6 */
+	FF(c, d, a, b, x[ 6], S13); /* 7 */
+	FF(b, c, d, a, x[ 7], S14); /* 8 */
+	FF(a, b, c, d, x[ 8], S11); /* 9 */
+	FF(d, a, b, c, x[ 9], S12); /* 10 */
+	FF(c, d, a, b, x[10], S13); /* 11 */
+	FF(b, c, d, a, x[11], S14); /* 12 */
+	FF(a, b, c, d, x[12], S11); /* 13 */
+	FF(d, a, b, c, x[13], S12); /* 14 */
+	FF(c, d, a, b, x[14], S13); /* 15 */
+	FF(b, c, d, a, x[15], S14); /* 16 */
+
+	/* Round 2 */
+	GG(a, b, c, d, x[ 0], S21); /* 17 */
+	GG(d, a, b, c, x[ 4], S22); /* 18 */
+	GG(c, d, a, b, x[ 8], S23); /* 19 */
+	GG(b, c, d, a, x[12], S24); /* 20 */
+	GG(a, b, c, d, x[ 1], S21); /* 21 */
+	GG(d, a, b, c, x[ 5], S22); /* 22 */
+	GG(c, d, a, b, x[ 9], S23); /* 23 */
+	GG(b, c, d, a, x[13], S24); /* 24 */
+	GG(a, b, c, d, x[ 2], S21); /* 25 */
+	GG(d, a, b, c, x[ 6], S22); /* 26 */
+	GG(c, d, a, b, x[10], S23); /* 27 */
+	GG(b, c, d, a, x[14], S24); /* 28 */
+	GG(a, b, c, d, x[ 3], S21); /* 29 */
+	GG(d, a, b, c, x[ 7], S22); /* 30 */
+	GG(c, d, a, b, x[11], S23); /* 31 */
+	GG(b, c, d, a, x[15], S24); /* 32 */
+
+
+	/* Round 3 */
+	HH(a, b, c, d, x[ 0], S31); /* 33 */
+	HH(d, a, b, c, x[ 8], S32); /* 34 */
+	HH(c, d, a, b, x[ 4], S33); /* 35 */
+	HH(b, c, d, a, x[12], S34); /* 36 */
+	HH(a, b, c, d, x[ 2], S31); /* 37 */
+	HH(d, a, b, c, x[10], S32); /* 38 */
+	HH(c, d, a, b, x[ 6], S33); /* 39 */
+	HH(b, c, d, a, x[14], S34); /* 40 */
+	HH(a, b, c, d, x[ 1], S31); /* 41 */
+	HH(d, a, b, c, x[ 9], S32); /* 42 */
+	HH(c, d, a, b, x[ 5], S33); /* 43 */
+	HH(b, c, d, a, x[13], S34); /* 44 */
+	HH(a, b, c, d, x[ 3], S31); /* 45 */
+	HH(d, a, b, c, x[11], S32); /* 46 */
+	HH(c, d, a, b, x[ 7], S33); /* 47 */
+	HH(b, c, d, a, x[15], S34); /* 48 */
+
+	state[0] += a;
+	state[1] += b;
+	state[2] += c;
+	state[3] += d;
+
+	/* zeroize sensitive information */
+	bzero(x, sizeof (*x));
+}
+
+/*
+ * Encodes input (ulong_t) into output (unsigned char). Assumes len is
+ * a multiple of 4.
+ */
+static void
+Encode(output, input, len)
+	unsigned char *output;
+	ulong_t *input;
+	unsigned int len;
+{
+	unsigned int i, j;
+
+	for (i = 0, j = 0; j < len; i++, j += 4) {
+		output[j] = (unsigned char)(input[i] & 0xff);
+		output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+		output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+		output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+	}
+}
+
+/*
+ * Decodes input (unsigned char) into output (ulong_t). Assumes len is
+ * a multiple of 4.
+ */
+static void
+Decode(output, input, len)
+	ulong_t *output;
+	unsigned char *input;
+	unsigned int len;
+{
+	unsigned int i, j;
+
+	for (i = 0, j = 0; j < len; i++, j += 4)
+		output[i] = ((ulong_t)input[j]) |
+			(((ulong_t)input[j+1]) << 8) |
+			(((ulong_t)input[j+2]) << 16) |
+			(((ulong_t)input[j+3]) << 24);
+}
--- a/usr/src/common/crypto/md5/md5.c	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/common/crypto/md5/md5.c	Tue Mar 28 08:45:30 2006 -0800
@@ -7,10 +7,6 @@
  * Cleaned-up and optimized version of MD5, based on the reference
  * implementation provided in RFC 1321.  See RSA Copyright information
  * below.
- *
- * NOTE:  All compiler data was gathered with SC4.2, and verified with SC5.x,
- *	  as used to build Solaris 2.7.  Hopefully the compiler behavior won't
- *	  change for the worse in subsequent Solaris builds.
  */
 
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
@@ -50,267 +46,11 @@
 #include <strings.h>
 #endif /* !_KERNEL || _BOOT */
 
-#if	defined(_KERNEL) && !defined(_BOOT)
-
-/*
- * In kernel module, the md5 module is created with two modlinkages:
- * - a modlmisc that allows consumers to directly call the entry points
- *   MD5Init, MD5Update, and MD5Final.
- * - a modlcrypto that allows the module to register with the Kernel
- *   Cryptographic Framework (KCF) as a software provider for the MD5
- *   mechanisms.
- */
-
+#ifdef _KERNEL
 #include <sys/systm.h>
-#include <sys/modctl.h>
-#include <sys/cmn_err.h>
-#include <sys/ddi.h>
-#include <sys/crypto/common.h>
-#include <sys/crypto/spi.h>
-#include <sys/sysmacros.h>
-#include <sys/strsun.h>
-#include <sys/note.h>
-
-extern struct mod_ops mod_miscops;
-extern struct mod_ops mod_cryptoops;
-
-/*
- * Module linkage information for the kernel.
- */
-
-static struct modlmisc modlmisc = {
-	&mod_miscops,
-	"MD5 Message-Digest Algorithm"
-};
-
-static struct modlcrypto modlcrypto = {
-	&mod_cryptoops,
-	"MD5 Kernel SW Provider 1.23"
-};
-
-static struct modlinkage modlinkage = {
-	MODREV_1,
-	(void *)&modlmisc,
-	(void *)&modlcrypto,
-	NULL
-};
-
-/*
- * CSPI information (entry points, provider info, etc.)
- */
-
-typedef enum md5_mech_type {
-	MD5_MECH_INFO_TYPE,		/* SUN_CKM_MD5 */
-	MD5_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_MD5_HMAC */
-	MD5_HMAC_GEN_MECH_INFO_TYPE	/* SUN_CKM_MD5_HMAC_GENERAL */
-} md5_mech_type_t;
-
-#define	MD5_DIGEST_LENGTH	16	/* MD5 digest length in bytes */
-#define	MD5_HMAC_BLOCK_SIZE	64	/* MD5 block size */
-#define	MD5_HMAC_MIN_KEY_LEN	8	/* MD5-HMAC min key length in bits */
-#define	MD5_HMAC_MAX_KEY_LEN	INT_MAX	/* MD5-HMAC max key length in bits */
-#define	MD5_HMAC_INTS_PER_BLOCK	(MD5_HMAC_BLOCK_SIZE/sizeof (uint32_t))
-
-/*
- * Context for MD5 mechanism.
- */
-typedef struct md5_ctx {
-	md5_mech_type_t		mc_mech_type;	/* type of context */
-	MD5_CTX			mc_md5_ctx;	/* MD5 context */
-} md5_ctx_t;
-
-/*
- * Context for MD5-HMAC and MD5-HMAC-GENERAL mechanisms.
- */
-typedef struct md5_hmac_ctx {
-	md5_mech_type_t		hc_mech_type;	/* type of context */
-	uint32_t		hc_digest_len;	/* digest len in bytes */
-	MD5_CTX			hc_icontext;	/* inner MD5 context */
-	MD5_CTX			hc_ocontext;	/* outer MD5 context */
-} md5_hmac_ctx_t;
-
-/*
- * Macros to access the MD5 or MD5-HMAC contexts from a context passed
- * by KCF to one of the entry points.
- */
-
-#define	PROV_MD5_CTX(ctx)	((md5_ctx_t *)(ctx)->cc_provider_private)
-#define	PROV_MD5_HMAC_CTX(ctx)	((md5_hmac_ctx_t *)(ctx)->cc_provider_private)
-/* to extract the digest length passed as mechanism parameter */
-
-#define	PROV_MD5_GET_DIGEST_LEN(m, len) {				\
-	if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))		\
-		(len) = (uint32_t)*((ulong_t *)mechanism->cm_param);	\
-	else {								\
-		ulong_t tmp_ulong;					\
-		bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));	\
-		(len) = (uint32_t)tmp_ulong;				\
-	}								\
-}
-
-#define	PROV_MD5_DIGEST_KEY(ctx, key, len, digest) {	\
-	MD5Init(ctx);					\
-	MD5Update(ctx, key, len);			\
-	MD5Final(digest, ctx);				\
-}
-
-/*
- * Mechanism info structure passed to KCF during registration.
- */
-static crypto_mech_info_t md5_mech_info_tab[] = {
-	/* MD5 */
-	{SUN_CKM_MD5, MD5_MECH_INFO_TYPE,
-	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
-	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* MD5-HMAC */
-	{SUN_CKM_MD5_HMAC, MD5_HMAC_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    MD5_HMAC_MIN_KEY_LEN, MD5_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* MD5-HMAC GENERAL */
-	{SUN_CKM_MD5_HMAC_GENERAL, MD5_HMAC_GEN_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    MD5_HMAC_MIN_KEY_LEN, MD5_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS}
-};
-
-static void md5_provider_status(crypto_provider_handle_t, uint_t *);
-
-static crypto_control_ops_t md5_control_ops = {
-	md5_provider_status
-};
+#endif /* _KERNEL */
 
-static int md5_digest_init(crypto_ctx_t *, crypto_mechanism_t *,
-    crypto_req_handle_t);
-static int md5_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int md5_digest_update(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int md5_digest_final(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int md5_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
-    crypto_req_handle_t);
-
-static crypto_digest_ops_t md5_digest_ops = {
-	md5_digest_init,
-	md5_digest,
-	md5_digest_update,
-	NULL,
-	md5_digest_final,
-	md5_digest_atomic
-};
-
-static int md5_mac_init(crypto_ctx_t *, crypto_mechanism_t *, crypto_key_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-static int md5_mac_update(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
-static int md5_mac_final(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
-static int md5_mac_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-static int md5_mac_verify_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-
-static crypto_mac_ops_t md5_mac_ops = {
-	md5_mac_init,
-	NULL,
-	md5_mac_update,
-	md5_mac_final,
-	md5_mac_atomic,
-	md5_mac_verify_atomic
-};
-
-static int md5_create_ctx_template(crypto_provider_handle_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
-    size_t *, crypto_req_handle_t);
-static int md5_free_context(crypto_ctx_t *);
-
-static crypto_ctx_ops_t md5_ctx_ops = {
-	md5_create_ctx_template,
-	md5_free_context
-};
-
-static crypto_ops_t md5_crypto_ops = {
-	&md5_control_ops,
-	&md5_digest_ops,
-	NULL,
-	&md5_mac_ops,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	&md5_ctx_ops
-};
-
-static crypto_provider_info_t md5_prov_info = {
-	CRYPTO_SPI_VERSION_1,
-	"MD5 Software Provider",
-	CRYPTO_SW_PROVIDER,
-	{&modlinkage},
-	NULL,
-	&md5_crypto_ops,
-	sizeof (md5_mech_info_tab)/sizeof (crypto_mech_info_t),
-	md5_mech_info_tab
-};
-
-static crypto_kcf_provider_handle_t md5_prov_handle = NULL;
-
-int
-_init(void)
-{
-	int ret;
-
-	if ((ret = mod_install(&modlinkage)) != 0)
-		return (ret);
-
-	/*
-	 * Register with KCF. If the registration fails, log an
-	 * error but do not uninstall the module, since the functionality
-	 * provided by misc/md5 should still be available.
-	 */
-	if ((ret = crypto_register_provider(&md5_prov_info,
-	    &md5_prov_handle)) != CRYPTO_SUCCESS)
-		cmn_err(CE_WARN, "md5 _init: "
-		    "crypto_register_provider() failed (0x%x)", ret);
-
-	return (0);
-}
-
-int
-_fini(void)
-{
-	int ret;
-
-	/*
-	 * Unregister from KCF if previous registration succeeded.
-	 */
-	if (md5_prov_handle != NULL) {
-		if ((ret = crypto_unregister_provider(md5_prov_handle)) !=
-		    CRYPTO_SUCCESS) {
-			cmn_err(CE_WARN, "md5 _fini: "
-			    "crypto_unregister_provider() failed (0x%x)", ret);
-			return (EBUSY);
-		}
-		md5_prov_handle = NULL;
-	}
-
-	return (mod_remove(&modlinkage));
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (mod_info(&modlinkage, modinfop));
-}
-#endif	/* _KERNEL && !_BOOT */
-
-static void Encode(uint8_t *, uint32_t *, size_t);
+static void Encode(uint8_t *, const uint32_t *, size_t);
 static void MD5Transform(uint32_t, uint32_t, uint32_t, uint32_t, MD5_CTX *,
     const uint8_t [64]);
 
@@ -662,6 +402,7 @@
 #ifdef sun4v
 	unsigned long long 	*md5_consts64;
 
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 	md5_consts64 = (unsigned long long *) md5_consts;
 #endif	/* sun4v */
 
@@ -738,38 +479,70 @@
 	{
 
 #ifdef sun4v
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_15 = LOAD_LITTLE_32_f(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_14 = LOAD_LITTLE_32_e(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_13 = LOAD_LITTLE_32_d(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_12 = LOAD_LITTLE_32_c(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_11 = LOAD_LITTLE_32_b(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_10 = LOAD_LITTLE_32_a(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_9  = LOAD_LITTLE_32_9(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_8  = LOAD_LITTLE_32_8(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_7  = LOAD_LITTLE_32_7(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_6  = LOAD_LITTLE_32_6(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_5  = LOAD_LITTLE_32_5(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_4  = LOAD_LITTLE_32_4(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_3  = LOAD_LITTLE_32_3(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_2  = LOAD_LITTLE_32_2(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_1  = LOAD_LITTLE_32_1(block);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_0  = LOAD_LITTLE_32_0(block);
 #else
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_15 = LOAD_LITTLE_32(block + 60);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_14 = LOAD_LITTLE_32(block + 56);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_13 = LOAD_LITTLE_32(block + 52);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_12 = LOAD_LITTLE_32(block + 48);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_11 = LOAD_LITTLE_32(block + 44);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_10 = LOAD_LITTLE_32(block + 40);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_9  = LOAD_LITTLE_32(block + 36);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_8  = LOAD_LITTLE_32(block + 32);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_7  = LOAD_LITTLE_32(block + 28);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_6  = LOAD_LITTLE_32(block + 24);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_5  = LOAD_LITTLE_32(block + 20);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_4  = LOAD_LITTLE_32(block + 16);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_3  = LOAD_LITTLE_32(block + 12);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_2  = LOAD_LITTLE_32(block +  8);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_1  = LOAD_LITTLE_32(block +  4);
+		/* LINTED E_BAD_PTR_CAST_ALIGN */
 		x_0  = LOAD_LITTLE_32(block +  0);
 #endif /* sun4v */
 	}
@@ -861,21 +634,6 @@
 }
 
 /*
- * devpro compiler optimization:
- *
- * the compiler can generate better code if it knows that `input' and
- * `output' do not point to the same source.  there is no portable
- * way to tell the compiler this, but the devpro compiler recognizes the
- * `_Restrict' keyword to indicate this condition.  use it if possible.
- */
-
-#if defined(__RESTRICT) && !defined(__GNUC__)
-#define	restrict	_Restrict
-#else
-#define	restrict	/* nothing */
-#endif
-
-/*
  * Encode()
  *
  * purpose: to convert a list of numbers from big endian to little endian
@@ -886,7 +644,8 @@
  */
 
 static void
-Encode(uint8_t *restrict output, uint32_t *restrict input, size_t input_len)
+Encode(uint8_t *_RESTRICT_KYWD output, const uint32_t *_RESTRICT_KYWD input,
+    size_t input_len)
 {
 	size_t		i, j;
 
@@ -899,6 +658,7 @@
 			bcopy(input + i, output + j, 4);
 		else *(uint32_t *)(output + j) = input[i];
 #else
+		/*LINTED E_BAD_PTR_CAST_ALIGN*/
 		*(uint32_t *)(output + j) = input[i];
 #endif /* _MD5_CHECK_ALIGNMENT */
 
@@ -911,1222 +671,3 @@
 #endif
 	}
 }
-
-#if	defined(_KERNEL) && !defined(_BOOT)
-
-/*
- * KCF software provider control entry points.
- */
-/* ARGSUSED */
-static void
-md5_provider_status(crypto_provider_handle_t provider, uint_t *status)
-{
-	*status = CRYPTO_PROVIDER_READY;
-}
-
-/*
- * KCF software provider digest entry points.
- */
-
-static int
-md5_digest_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
-    crypto_req_handle_t req)
-{
-	if (mechanism->cm_type != MD5_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/*
-	 * Allocate and initialize MD5 context.
-	 */
-	ctx->cc_provider_private = kmem_alloc(sizeof (md5_ctx_t),
-	    crypto_kmflag(req));
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	PROV_MD5_CTX(ctx)->mc_mech_type = MD5_MECH_INFO_TYPE;
-	MD5Init(&PROV_MD5_CTX(ctx)->mc_md5_ctx);
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper MD5 digest update function for uio data.
- */
-static int
-md5_digest_update_uio(MD5_CTX *md5_ctx, crypto_data_t *data)
-{
-	off_t offset = data->cd_offset;
-	size_t length = data->cd_length;
-	uint_t vec_idx;
-	size_t cur_len;
-
-	/* we support only kernel buffer */
-	if (data->cd_uio->uio_segflg != UIO_SYSSPACE)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Jump to the first iovec containing data to be
-	 * digested.
-	 */
-	for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
-	    offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
-	    offset -= data->cd_uio->uio_iov[vec_idx++].iov_len);
-	if (vec_idx == data->cd_uio->uio_iovcnt) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	/*
-	 * Now do the digesting on the iovecs.
-	 */
-	while (vec_idx < data->cd_uio->uio_iovcnt && length > 0) {
-		cur_len = MIN(data->cd_uio->uio_iov[vec_idx].iov_len -
-		    offset, length);
-
-		MD5Update(md5_ctx, data->cd_uio->uio_iov[vec_idx].iov_base +
-		    offset, cur_len);
-
-		length -= cur_len;
-		vec_idx++;
-		offset = 0;
-	}
-
-	if (vec_idx == data->cd_uio->uio_iovcnt && length > 0) {
-		/*
-		 * The end of the specified iovec's was reached but
-		 * the length requested could not be processed, i.e.
-		 * The caller requested to digest more data than it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper MD5 digest final function for uio data.
- * digest_len is the length of the desired digest. If digest_len
- * is smaller than the default MD5 digest length, the caller
- * must pass a scratch buffer, digest_scratch, which must
- * be at least MD5_DIGEST_LENGTH bytes.
- */
-static int
-md5_digest_final_uio(MD5_CTX *md5_ctx, crypto_data_t *digest,
-    ulong_t digest_len, uchar_t *digest_scratch)
-{
-	off_t offset = digest->cd_offset;
-	uint_t vec_idx;
-
-	/* we support only kernel buffer */
-	if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Jump to the first iovec containing ptr to the digest to
-	 * be returned.
-	 */
-	for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
-	    vec_idx < digest->cd_uio->uio_iovcnt;
-	    offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len);
-	if (vec_idx == digest->cd_uio->uio_iovcnt) {
-		/*
-		 * The caller specified an offset that is
-		 * larger than the total size of the buffers
-		 * it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	if (offset + digest_len <=
-	    digest->cd_uio->uio_iov[vec_idx].iov_len) {
-		/*
-		 * The computed MD5 digest will fit in the current
-		 * iovec.
-		 */
-		if (digest_len != MD5_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			MD5Final(digest_scratch, md5_ctx);
-			bcopy(digest_scratch, (uchar_t *)digest->
-			    cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    digest_len);
-		} else {
-			MD5Final((uchar_t *)digest->
-			    cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    md5_ctx);
-		}
-	} else {
-		/*
-		 * The computed digest will be crossing one or more iovec's.
-		 * This is bad performance-wise but we need to support it.
-		 * Allocate a small scratch buffer on the stack and
-		 * copy it piece meal to the specified digest iovec's.
-		 */
-		uchar_t digest_tmp[MD5_DIGEST_LENGTH];
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		MD5Final(digest_tmp, md5_ctx);
-
-		while (vec_idx < digest->cd_uio->uio_iovcnt && length > 0) {
-			cur_len = MIN(digest->cd_uio->uio_iov[vec_idx].iov_len -
-			    offset, length);
-			bcopy(digest_tmp + scratch_offset,
-			    digest->cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    cur_len);
-
-			length -= cur_len;
-			vec_idx++;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-
-		if (vec_idx == digest->cd_uio->uio_iovcnt && length > 0) {
-			/*
-			 * The end of the specified iovec's was reached but
-			 * the length requested could not be processed, i.e.
-			 * The caller requested to digest more data than it
-			 * provided.
-			 */
-			return (CRYPTO_DATA_LEN_RANGE);
-		}
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper MD5 digest update for mblk's.
- */
-static int
-md5_digest_update_mblk(MD5_CTX *md5_ctx, crypto_data_t *data)
-{
-	off_t offset = data->cd_offset;
-	size_t length = data->cd_length;
-	mblk_t *mp;
-	size_t cur_len;
-
-	/*
-	 * Jump to the first mblk_t containing data to be digested.
-	 */
-	for (mp = data->cd_mp; mp != NULL && offset >= MBLKL(mp);
-	    offset -= MBLKL(mp), mp = mp->b_cont);
-	if (mp == NULL) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	/*
-	 * Now do the digesting on the mblk chain.
-	 */
-	while (mp != NULL && length > 0) {
-		cur_len = MIN(MBLKL(mp) - offset, length);
-		MD5Update(md5_ctx, mp->b_rptr + offset, cur_len);
-		length -= cur_len;
-		offset = 0;
-		mp = mp->b_cont;
-	}
-
-	if (mp == NULL && length > 0) {
-		/*
-		 * The end of the mblk was reached but the length requested
-		 * could not be processed, i.e. The caller requested
-		 * to digest more data than it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper MD5 digest final for mblk's.
- * digest_len is the length of the desired digest. If digest_len
- * is smaller than the default MD5 digest length, the caller
- * must pass a scratch buffer, digest_scratch, which must
- * be at least MD5_DIGEST_LENGTH bytes.
- */
-static int
-md5_digest_final_mblk(MD5_CTX *md5_ctx, crypto_data_t *digest,
-    ulong_t digest_len, uchar_t *digest_scratch)
-{
-	off_t offset = digest->cd_offset;
-	mblk_t *mp;
-
-	/*
-	 * Jump to the first mblk_t that will be used to store the digest.
-	 */
-	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
-	    offset -= MBLKL(mp), mp = mp->b_cont);
-	if (mp == NULL) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	if (offset + digest_len <= MBLKL(mp)) {
-		/*
-		 * The computed MD5 digest will fit in the current mblk.
-		 * Do the MD5Final() in-place.
-		 */
-		if (digest_len != MD5_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			MD5Final(digest_scratch, md5_ctx);
-			bcopy(digest_scratch, mp->b_rptr + offset, digest_len);
-		} else {
-			MD5Final(mp->b_rptr + offset, md5_ctx);
-		}
-	} else {
-		/*
-		 * The computed digest will be crossing one or more mblk's.
-		 * This is bad performance-wise but we need to support it.
-		 * Allocate a small scratch buffer on the stack and
-		 * copy it piece meal to the specified digest iovec's.
-		 */
-		uchar_t digest_tmp[MD5_DIGEST_LENGTH];
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		MD5Final(digest_tmp, md5_ctx);
-
-		while (mp != NULL && length > 0) {
-			cur_len = MIN(MBLKL(mp) - offset, length);
-			bcopy(digest_tmp + scratch_offset,
-			    mp->b_rptr + offset, cur_len);
-
-			length -= cur_len;
-			mp = mp->b_cont;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-
-		if (mp == NULL && length > 0) {
-			/*
-			 * The end of the specified mblk was reached but
-			 * the length requested could not be processed, i.e.
-			 * The caller requested to digest more data than it
-			 * provided.
-			 */
-			return (CRYPTO_DATA_LEN_RANGE);
-		}
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/* ARGSUSED */
-static int
-md5_digest(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((digest->cd_length == 0) ||
-	    (digest->cd_length < MD5_DIGEST_LENGTH)) {
-		digest->cd_length = MD5_DIGEST_LENGTH;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do the MD5 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Update(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_update_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_update_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		/* the update failed, free context and bail */
-		kmem_free(ctx->cc_provider_private, sizeof (md5_ctx_t));
-		ctx->cc_provider_private = NULL;
-		digest->cd_length = 0;
-		return (ret);
-	}
-
-	/*
-	 * Do an MD5 final, must be done separately since the digest
-	 * type can be different than the input data type.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &PROV_MD5_CTX(ctx)->mc_md5_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_final_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    digest, MD5_DIGEST_LENGTH, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_final_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    digest, MD5_DIGEST_LENGTH, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/* all done, free context and return */
-
-	if (ret == CRYPTO_SUCCESS) {
-		digest->cd_length = MD5_DIGEST_LENGTH;
-	} else {
-		digest->cd_length = 0;
-	}
-
-	kmem_free(ctx->cc_provider_private, sizeof (md5_ctx_t));
-	ctx->cc_provider_private = NULL;
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-md5_digest_update(crypto_ctx_t *ctx, crypto_data_t *data,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * Do the MD5 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Update(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_update_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_update_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-md5_digest_final(crypto_ctx_t *ctx, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((digest->cd_length == 0) ||
-	    (digest->cd_length < MD5_DIGEST_LENGTH)) {
-		digest->cd_length = MD5_DIGEST_LENGTH;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do an MD5 final.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &PROV_MD5_CTX(ctx)->mc_md5_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_final_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    digest, MD5_DIGEST_LENGTH, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_final_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
-		    digest, MD5_DIGEST_LENGTH, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/* all done, free context and return */
-
-	if (ret == CRYPTO_SUCCESS) {
-		digest->cd_length = MD5_DIGEST_LENGTH;
-	} else {
-		digest->cd_length = 0;
-	}
-
-	kmem_free(ctx->cc_provider_private, sizeof (md5_ctx_t));
-	ctx->cc_provider_private = NULL;
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-md5_digest_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_data_t *data, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	MD5_CTX md5_ctx;
-
-	if (mechanism->cm_type != MD5_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/*
-	 * Do the MD5 init.
-	 */
-	MD5Init(&md5_ctx);
-
-	/*
-	 * Do the MD5 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Update(&md5_ctx, data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_update_uio(&md5_ctx, data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_update_mblk(&md5_ctx, data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		/* the update failed, bail */
-		digest->cd_length = 0;
-		return (ret);
-	}
-
-	/*
-	 * Do an MD5 final, must be done separately since the digest
-	 * type can be different than the input data type.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &md5_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_final_uio(&md5_ctx, digest,
-		    MD5_DIGEST_LENGTH, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_final_mblk(&md5_ctx, digest,
-		    MD5_DIGEST_LENGTH, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		digest->cd_length = MD5_DIGEST_LENGTH;
-	} else {
-		digest->cd_length = 0;
-	}
-
-	return (ret);
-}
-
-/*
- * KCF software provider mac entry points.
- *
- * MD5 HMAC is: MD5(key XOR opad, MD5(key XOR ipad, text))
- *
- * Init:
- * The initialization routine initializes what we denote
- * as the inner and outer contexts by doing
- * - for inner context: MD5(key XOR ipad)
- * - for outer context: MD5(key XOR opad)
- *
- * Update:
- * Each subsequent MD5 HMAC update will result in an
- * update of the inner context with the specified data.
- *
- * Final:
- * The MD5 HMAC final will do a MD5 final operation on the
- * inner context, and the resulting digest will be used
- * as the data for an update on the outer context. Last
- * but not least, an MD5 final on the outer context will
- * be performed to obtain the MD5 HMAC digest to return
- * to the user.
- */
-
-/*
- * Initialize a MD5-HMAC context.
- */
-static void
-md5_mac_init_ctx(md5_hmac_ctx_t *ctx, void *keyval, uint_t length_in_bytes)
-{
-	uint32_t ipad[MD5_HMAC_INTS_PER_BLOCK];
-	uint32_t opad[MD5_HMAC_INTS_PER_BLOCK];
-	uint_t i;
-
-	bzero(ipad, MD5_HMAC_BLOCK_SIZE);
-	bzero(opad, MD5_HMAC_BLOCK_SIZE);
-
-	bcopy(keyval, ipad, length_in_bytes);
-	bcopy(keyval, opad, length_in_bytes);
-
-	/* XOR key with ipad (0x36) and opad (0x5c) */
-	for (i = 0; i < MD5_HMAC_INTS_PER_BLOCK; i++) {
-		ipad[i] ^= 0x36363636;
-		opad[i] ^= 0x5c5c5c5c;
-	}
-
-	/* perform MD5 on ipad */
-	MD5Init(&ctx->hc_icontext);
-	MD5Update(&ctx->hc_icontext, ipad, MD5_HMAC_BLOCK_SIZE);
-
-	/* perform MD5 on opad */
-	MD5Init(&ctx->hc_ocontext);
-	MD5Update(&ctx->hc_ocontext, opad, MD5_HMAC_BLOCK_SIZE);
-}
-
-/*
- * Initializes a multi-part MAC operation.
- */
-static int
-md5_mac_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if (mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE &&
-	    mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	ctx->cc_provider_private = kmem_alloc(sizeof (md5_hmac_ctx_t),
-	    crypto_kmflag(req));
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, PROV_MD5_HMAC_CTX(ctx),
-		    sizeof (md5_hmac_ctx_t));
-	} else {
-		/* no context template, compute context */
-		if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
-			uchar_t digested_key[MD5_DIGEST_LENGTH];
-			md5_hmac_ctx_t *hmac_ctx = ctx->cc_provider_private;
-
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_MD5_DIGEST_KEY(&hmac_ctx->hc_icontext,
-			    key->ck_data, keylen_in_bytes, digested_key);
-			md5_mac_init_ctx(PROV_MD5_HMAC_CTX(ctx),
-			    digested_key, MD5_DIGEST_LENGTH);
-		} else {
-			md5_mac_init_ctx(PROV_MD5_HMAC_CTX(ctx),
-			    key->ck_data, keylen_in_bytes);
-		}
-	}
-
-	/*
-	 * Get the mechanism parameters, if applicable.
-	 */
-	PROV_MD5_HMAC_CTX(ctx)->hc_mech_type = mechanism->cm_type;
-	if (mechanism->cm_type == MD5_HMAC_GEN_MECH_INFO_TYPE) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t))
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-		PROV_MD5_GET_DIGEST_LEN(mechanism,
-		    PROV_MD5_HMAC_CTX(ctx)->hc_digest_len);
-		if (PROV_MD5_HMAC_CTX(ctx)->hc_digest_len >
-		    MD5_DIGEST_LENGTH)
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		bzero(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
-		kmem_free(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
-		ctx->cc_provider_private = NULL;
-	}
-
-	return (ret);
-}
-
-
-/* ARGSUSED */
-static int
-md5_mac_update(crypto_ctx_t *ctx, crypto_data_t *data, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * Do an MD5 update of the inner context using the specified
-	 * data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		MD5Update(&PROV_MD5_HMAC_CTX(ctx)->hc_icontext,
-		    data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_update_uio(
-		    &PROV_MD5_HMAC_CTX(ctx)->hc_icontext, data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_update_mblk(
-		    &PROV_MD5_HMAC_CTX(ctx)->hc_icontext, data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-md5_mac_final(crypto_ctx_t *ctx, crypto_data_t *mac, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[MD5_DIGEST_LENGTH];
-	uint32_t digest_len = MD5_DIGEST_LENGTH;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	if (PROV_MD5_HMAC_CTX(ctx)->hc_mech_type == MD5_HMAC_GEN_MECH_INFO_TYPE)
-	    digest_len = PROV_MD5_HMAC_CTX(ctx)->hc_digest_len;
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((mac->cd_length == 0) || (mac->cd_length < digest_len)) {
-		mac->cd_length = digest_len;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do an MD5 final on the inner context.
-	 */
-	MD5Final(digest, &PROV_MD5_HMAC_CTX(ctx)->hc_icontext);
-
-	/*
-	 * Do an MD5 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	MD5Update(&PROV_MD5_HMAC_CTX(ctx)->hc_ocontext, digest,
-	    MD5_DIGEST_LENGTH);
-
-	/*
-	 * Do an MD5 final on the outer context, storing the computing
-	 * digest in the users buffer.
-	 */
-	switch (mac->cd_format) {
-	case CRYPTO_DATA_RAW:
-		if (digest_len != MD5_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			MD5Final(digest,
-			    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext);
-			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, digest_len);
-		} else {
-			MD5Final((unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset,
-			    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext);
-		}
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_final_uio(
-		    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_final_mblk(
-		    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		mac->cd_length = digest_len;
-	} else {
-		mac->cd_length = 0;
-	}
-
-	bzero(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
-	kmem_free(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
-	ctx->cc_provider_private = NULL;
-
-	return (ret);
-}
-
-#define	MD5_MAC_UPDATE(data, ctx, ret) {				\
-	switch (data->cd_format) {					\
-	case CRYPTO_DATA_RAW:						\
-		MD5Update(&(ctx).hc_icontext,				\
-		    data->cd_raw.iov_base + data->cd_offset,		\
-		    data->cd_length);					\
-		break;							\
-	case CRYPTO_DATA_UIO:						\
-		ret = md5_digest_update_uio(&(ctx).hc_icontext,	data);	\
-		break;							\
-	case CRYPTO_DATA_MBLK:						\
-		ret = md5_digest_update_mblk(&(ctx).hc_icontext,	\
-		    data);						\
-		break;							\
-	default:							\
-		ret = CRYPTO_ARGUMENTS_BAD;				\
-	}								\
-}
-
-
-/* ARGSUSED */
-static int
-md5_mac_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
-    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[MD5_DIGEST_LENGTH];
-	md5_hmac_ctx_t md5_hmac_ctx;
-	uint32_t digest_len = MD5_DIGEST_LENGTH;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if (mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE &&
-	    mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, &md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
-	} else {
-		/* no context template, compute context */
-		if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_MD5_DIGEST_KEY(&md5_hmac_ctx.hc_icontext,
-			    key->ck_data, keylen_in_bytes, digest);
-			md5_mac_init_ctx(&md5_hmac_ctx, digest,
-			    MD5_DIGEST_LENGTH);
-		} else {
-			md5_mac_init_ctx(&md5_hmac_ctx, key->ck_data,
-			    keylen_in_bytes);
-		}
-	}
-
-	/*
-	 * Get the mechanism parameters, if applicable.
-	 */
-	if (mechanism->cm_type == MD5_HMAC_GEN_MECH_INFO_TYPE) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t)) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-		PROV_MD5_GET_DIGEST_LEN(mechanism, digest_len);
-		if (digest_len > MD5_DIGEST_LENGTH) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-	}
-
-	/* do an MD5 update of the inner context using the specified data */
-	MD5_MAC_UPDATE(data, md5_hmac_ctx, ret);
-	if (ret != CRYPTO_SUCCESS)
-		/* the update failed, free context and bail */
-		goto bail;
-
-	/* do an MD5 final on the inner context */
-	MD5Final(digest, &md5_hmac_ctx.hc_icontext);
-
-	/*
-	 * Do an MD5 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	MD5Update(&md5_hmac_ctx.hc_ocontext, digest, MD5_DIGEST_LENGTH);
-
-	/*
-	 * Do an MD5 final on the outer context, storing the computed
-	 * digest in the users buffer.
-	 */
-	switch (mac->cd_format) {
-	case CRYPTO_DATA_RAW:
-		if (digest_len != MD5_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			MD5Final(digest, &md5_hmac_ctx.hc_ocontext);
-			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, digest_len);
-		} else {
-			MD5Final((unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, &md5_hmac_ctx.hc_ocontext);
-		}
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = md5_digest_final_uio(&md5_hmac_ctx.hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = md5_digest_final_mblk(&md5_hmac_ctx.hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		mac->cd_length = digest_len;
-	} else {
-		mac->cd_length = 0;
-	}
-	/* Extra paranoia: zeroizing the local context on the stack */
-	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
-
-	return (ret);
-bail:
-	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
-	mac->cd_length = 0;
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-md5_mac_verify_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
-    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[MD5_DIGEST_LENGTH];
-	md5_hmac_ctx_t md5_hmac_ctx;
-	uint32_t digest_len = MD5_DIGEST_LENGTH;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if (mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE &&
-	    mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, &md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
-	} else {
-		/* no context template, compute context */
-		if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_MD5_DIGEST_KEY(&md5_hmac_ctx.hc_icontext,
-			    key->ck_data, keylen_in_bytes, digest);
-			md5_mac_init_ctx(&md5_hmac_ctx, digest,
-			    MD5_DIGEST_LENGTH);
-		} else {
-			md5_mac_init_ctx(&md5_hmac_ctx, key->ck_data,
-			    keylen_in_bytes);
-		}
-	}
-
-	/*
-	 * Get the mechanism parameters, if applicable.
-	 */
-	if (mechanism->cm_type == MD5_HMAC_GEN_MECH_INFO_TYPE) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t)) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-		PROV_MD5_GET_DIGEST_LEN(mechanism, digest_len);
-		if (digest_len > MD5_DIGEST_LENGTH) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-	}
-
-	if (mac->cd_length != digest_len) {
-		ret = CRYPTO_INVALID_MAC;
-		goto bail;
-	}
-
-	/* do an MD5 update of the inner context using the specified data */
-	MD5_MAC_UPDATE(data, md5_hmac_ctx, ret);
-	if (ret != CRYPTO_SUCCESS)
-		/* the update failed, free context and bail */
-		goto bail;
-
-	/* do an MD5 final on the inner context */
-	MD5Final(digest, &md5_hmac_ctx.hc_icontext);
-
-	/*
-	 * Do an MD5 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	MD5Update(&md5_hmac_ctx.hc_ocontext, digest, MD5_DIGEST_LENGTH);
-
-	/*
-	 * Do an MD5 final on the outer context, storing the computed
-	 * digest in the local digest buffer.
-	 */
-	MD5Final(digest, &md5_hmac_ctx.hc_ocontext);
-
-	/*
-	 * Compare the computed digest against the expected digest passed
-	 * as argument.
-	 */
-	switch (mac->cd_format) {
-
-	case CRYPTO_DATA_RAW:
-		if (bcmp(digest, (unsigned char *)mac->cd_raw.iov_base +
-		    mac->cd_offset, digest_len) != 0)
-			ret = CRYPTO_INVALID_MAC;
-		break;
-
-	case CRYPTO_DATA_UIO: {
-		off_t offset = mac->cd_offset;
-		uint_t vec_idx;
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		/* we support only kernel buffer */
-		if (mac->cd_uio->uio_segflg != UIO_SYSSPACE)
-			return (CRYPTO_ARGUMENTS_BAD);
-
-		/* jump to the first iovec containing the expected digest */
-		for (vec_idx = 0;
-		    offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
-		    vec_idx < mac->cd_uio->uio_iovcnt;
-		    offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len);
-		if (vec_idx == mac->cd_uio->uio_iovcnt) {
-			/*
-			 * The caller specified an offset that is
-			 * larger than the total size of the buffers
-			 * it provided.
-			 */
-			ret = CRYPTO_DATA_LEN_RANGE;
-			break;
-		}
-
-		/* do the comparison of computed digest vs specified one */
-		while (vec_idx < mac->cd_uio->uio_iovcnt && length > 0) {
-			cur_len = MIN(mac->cd_uio->uio_iov[vec_idx].iov_len -
-			    offset, length);
-
-			if (bcmp(digest + scratch_offset,
-			    mac->cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    cur_len) != 0) {
-				ret = CRYPTO_INVALID_MAC;
-				break;
-			}
-
-			length -= cur_len;
-			vec_idx++;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-		break;
-	}
-
-	case CRYPTO_DATA_MBLK: {
-		off_t offset = mac->cd_offset;
-		mblk_t *mp;
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		/* jump to the first mblk_t containing the expected digest */
-		for (mp = mac->cd_mp; mp != NULL && offset >= MBLKL(mp);
-		    offset -= MBLKL(mp), mp = mp->b_cont);
-		if (mp == NULL) {
-			/*
-			 * The caller specified an offset that is larger than
-			 * the total size of the buffers it provided.
-			 */
-			ret = CRYPTO_DATA_LEN_RANGE;
-			break;
-		}
-
-		while (mp != NULL && length > 0) {
-			cur_len = MIN(MBLKL(mp) - offset, length);
-			if (bcmp(digest + scratch_offset,
-			    mp->b_rptr + offset, cur_len) != 0) {
-				ret = CRYPTO_INVALID_MAC;
-				break;
-			}
-
-			length -= cur_len;
-			mp = mp->b_cont;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-		break;
-	}
-
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
-	return (ret);
-bail:
-	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
-	mac->cd_length = 0;
-	return (ret);
-}
-
-/*
- * KCF software provider context management entry points.
- */
-
-/* ARGSUSED */
-static int
-md5_create_ctx_template(crypto_provider_handle_t provider,
-    crypto_mechanism_t *mechanism, crypto_key_t *key,
-    crypto_spi_ctx_template_t *ctx_template, size_t *ctx_template_size,
-    crypto_req_handle_t req)
-{
-	md5_hmac_ctx_t *md5_hmac_ctx_tmpl;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if ((mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE) &&
-	    (mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE))
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Allocate and initialize MD5 context.
-	 */
-	md5_hmac_ctx_tmpl = kmem_alloc(sizeof (md5_hmac_ctx_t),
-	    crypto_kmflag(req));
-	if (md5_hmac_ctx_tmpl == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
-		uchar_t digested_key[MD5_DIGEST_LENGTH];
-
-		/*
-		 * Hash the passed-in key to get a smaller key.
-		 * The inner context is used since it hasn't been
-		 * initialized yet.
-		 */
-		PROV_MD5_DIGEST_KEY(&md5_hmac_ctx_tmpl->hc_icontext,
-		    key->ck_data, keylen_in_bytes, digested_key);
-		md5_mac_init_ctx(md5_hmac_ctx_tmpl, digested_key,
-		    MD5_DIGEST_LENGTH);
-	} else {
-		md5_mac_init_ctx(md5_hmac_ctx_tmpl, key->ck_data,
-		    keylen_in_bytes);
-	}
-
-	md5_hmac_ctx_tmpl->hc_mech_type = mechanism->cm_type;
-	*ctx_template = (crypto_spi_ctx_template_t)md5_hmac_ctx_tmpl;
-	*ctx_template_size = sizeof (md5_hmac_ctx_t);
-
-	return (CRYPTO_SUCCESS);
-}
-
-static int
-md5_free_context(crypto_ctx_t *ctx)
-{
-	uint_t ctx_len;
-	md5_mech_type_t mech_type;
-
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_SUCCESS);
-
-	/*
-	 * We have to free either MD5 or MD5-HMAC contexts, which
-	 * have different lengths.
-	 */
-
-	mech_type = PROV_MD5_CTX(ctx)->mc_mech_type;
-	if (mech_type == MD5_MECH_INFO_TYPE)
-		ctx_len = sizeof (md5_ctx_t);
-	else {
-		ASSERT(mech_type == MD5_HMAC_MECH_INFO_TYPE ||
-		    mech_type == MD5_HMAC_GEN_MECH_INFO_TYPE);
-		ctx_len = sizeof (md5_hmac_ctx_t);
-	}
-
-	bzero(ctx->cc_provider_private, ctx_len);
-	kmem_free(ctx->cc_provider_private, ctx_len);
-	ctx->cc_provider_private = NULL;
-
-	return (CRYPTO_SUCCESS);
-}
-
-#endif	/* _KERNEL && !_BOOT */
--- a/usr/src/common/crypto/md5/md5_byteswap.h	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/common/crypto/md5/md5_byteswap.h	Tue Mar 28 08:45:30 2006 -0800
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -120,6 +120,24 @@
 extern	uint32_t load_little_32(uint32_t *);
 #endif	/* !__GNUC__ */
 
+/* Placate lint */
+#if defined(__lint)
+uint32_t
+load_little_32(uint32_t *addr)
+{
+	return (*addr);
+}
+#endif	/* __lint */
+
+#else	/* !sun4u */
+
+/* big endian -- will work on little endian, but slowly */
+/* Since we do byte operations, we don't have to check for alignment. */
+#define	LOAD_LITTLE_32(addr)	\
+	((addr)[0] | ((addr)[1] << 8) | ((addr)[2] << 16) | ((addr)[3] << 24))
+
+#endif	/* sun4u */
+
 #if defined(sun4v)
 
 /*
@@ -241,23 +259,6 @@
 #endif	/* !__GNUC__ */
 #endif	/* sun4v */
 
-/* Placate lint */
-#if defined(__lint)
-uint32_t
-load_little_32(uint32_t *addr)
-{
-	return (*addr);
-}
-#endif	/* __lint */
-
-#else	/* !sun4u */
-
-/* big endian -- will work on little endian, but slowly */
-/* Since we do byte operations, we don't have to check for alignment. */
-#define	LOAD_LITTLE_32(addr)	\
-	((addr)[0] | ((addr)[1] << 8) | ((addr)[2] << 16) | ((addr)[3] << 24))
-
-#endif	/* sun4u */
 #endif	/* _LITTLE_ENDIAN */
 
 #ifdef	__cplusplus
--- a/usr/src/common/crypto/sha1/sha1.c	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/common/crypto/sha1/sha1.c	Tue Mar 28 08:45:30 2006 -0800
@@ -41,36 +41,33 @@
 #include <sys/sha1.h>
 #include <sys/sha1_consts.h>
 
-#ifdef _KERNEL
-
-#include <sys/modctl.h>
-#include <sys/cmn_err.h>
-#include <sys/note.h>
-#include <sys/crypto/common.h>
-#include <sys/crypto/spi.h>
-#include <sys/strsun.h>
-
-/*
- * The sha1 module is created with two modlinkages:
- * - a modlmisc that allows consumers to directly call the entry points
- *   SHA1Init, SHA1Update, and SHA1Final.
- * - a modlcrypto that allows the module to register with the Kernel
- *   Cryptographic Framework (KCF) as a software provider for the SHA1
- *   mechanisms.
- */
-
-#endif /* _KERNEL */
 #ifndef	_KERNEL
 #include <strings.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/systeminfo.h>
-#endif	/* !_KERNEL */
+#endif  /* !_KERNEL */
+
+static void Encode(uint8_t *, const uint32_t *, size_t);
 
-static void Encode(uint8_t *, uint32_t *, size_t);
+#if	defined(__sparc)
+
+#define	SHA1_TRANSFORM(ctx, in) \
+	SHA1Transform((ctx)->state[0], (ctx)->state[1], (ctx)->state[2], \
+		(ctx)->state[3], (ctx)->state[4], (ctx), (in))
+
 static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
     SHA1_CTX *, const uint8_t *);
 
+#else
+
+#define	SHA1_TRANSFORM(ctx, in) SHA1Transform((ctx), (in))
+
+static void SHA1Transform(SHA1_CTX *, const uint8_t *);
+
+#endif
+
+
 static uint8_t PADDING[64] = { 0x80, /* all zeros */ };
 
 /*
@@ -78,225 +75,40 @@
  */
 #define	F(b, c, d)	(((b) & (c)) | ((~b) & (d)))
 #define	G(b, c, d)	((b) ^ (c) ^ (d))
-#define	H(b, c, d)	(((b) & (c)) | ((b) & (d)) | ((c) & (d)))
+#define	H(b, c, d)	(((b) & (c)) | (((b)|(c)) & (d)))
 
 /*
  * ROTATE_LEFT rotates x left n bits.
  */
+
+#if	defined(__GNUC__) && defined(_LP64)
+static __inline__ uint64_t
+ROTATE_LEFT(uint64_t value, uint32_t n)
+{
+	uint32_t t32;
+
+	t32 = (uint32_t)value;
+	return ((t32 << n) | (t32 >> (32 - n)));
+}
+
+#else
+
 #define	ROTATE_LEFT(x, n)	\
 	(((x) << (n)) | ((x) >> ((sizeof (x) * NBBY)-(n))))
 
-#ifdef _KERNEL
-
-static struct modlmisc modlmisc = {
-	&mod_miscops,
-	"SHA1 Message-Digest Algorithm"
-};
-
-static struct modlcrypto modlcrypto = {
-	&mod_cryptoops,
-	"SHA1 Kernel SW Provider %I%"
-};
-
-static struct modlinkage modlinkage = {
-	MODREV_1, &modlmisc, &modlcrypto, NULL
-};
+#endif
 
-/*
- * CSPI information (entry points, provider info, etc.)
- */
-
-typedef enum sha1_mech_type {
-	SHA1_MECH_INFO_TYPE,		/* SUN_CKM_SHA1 */
-	SHA1_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA1_HMAC */
-	SHA1_HMAC_GEN_MECH_INFO_TYPE	/* SUN_CKM_SHA1_HMAC_GENERAL */
-} sha1_mech_type_t;
-
-#define	SHA1_DIGEST_LENGTH	20	/* SHA1 digest length in bytes */
-#define	SHA1_HMAC_BLOCK_SIZE	64	/* SHA1-HMAC block size */
-#define	SHA1_HMAC_MIN_KEY_LEN	8	/* SHA1-HMAC min key length in bits */
-#define	SHA1_HMAC_MAX_KEY_LEN	INT_MAX /* SHA1-HMAC max key length in bits */
-#define	SHA1_HMAC_INTS_PER_BLOCK	(SHA1_HMAC_BLOCK_SIZE/sizeof (uint32_t))
+#if	defined(__GNUC__) && (defined(__i386) || defined(__amd64))
 
-/*
- * Context for SHA1 mechanism.
- */
-typedef struct sha1_ctx {
-	sha1_mech_type_t	sc_mech_type;	/* type of context */
-	SHA1_CTX		sc_sha1_ctx;	/* SHA1 context */
-} sha1_ctx_t;
-
-/*
- * Context for SHA1-HMAC and SHA1-HMAC-GENERAL mechanisms.
- */
-typedef struct sha1_hmac_ctx {
-	sha1_mech_type_t	hc_mech_type;	/* type of context */
-	uint32_t		hc_digest_len;	/* digest len in bytes */
-	SHA1_CTX		hc_icontext;	/* inner SHA1 context */
-	SHA1_CTX		hc_ocontext;	/* outer SHA1 context */
-} sha1_hmac_ctx_t;
+#define	HAVE_BSWAP
 
-/*
- * Macros to access the SHA1 or SHA1-HMAC contexts from a context passed
- * by KCF to one of the entry points.
- */
-
-#define	PROV_SHA1_CTX(ctx)	((sha1_ctx_t *)(ctx)->cc_provider_private)
-#define	PROV_SHA1_HMAC_CTX(ctx)	((sha1_hmac_ctx_t *)(ctx)->cc_provider_private)
-
-/* to extract the digest length passed as mechanism parameter */
-#define	PROV_SHA1_GET_DIGEST_LEN(m, len) {				\
-	if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))		\
-		(len) = (uint32_t)*((ulong_t *)mechanism->cm_param);	\
-	else {								\
-		ulong_t tmp_ulong;					\
-		bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));	\
-		(len) = (uint32_t)tmp_ulong;				\
-	}								\
-}
-
-#define	PROV_SHA1_DIGEST_KEY(ctx, key, len, digest) {	\
-	SHA1Init(ctx);					\
-	SHA1Update(ctx, key, len);			\
-	SHA1Final(digest, ctx);				\
+extern __inline__ uint32_t bswap(uint32_t value)
+{
+	__asm__("bswap %0" : "+r" (value));
+	return (value);
 }
 
-/*
- * Mechanism info structure passed to KCF during registration.
- */
-static crypto_mech_info_t sha1_mech_info_tab[] = {
-	/* SHA1 */
-	{SUN_CKM_SHA1, SHA1_MECH_INFO_TYPE,
-	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
-	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA1-HMAC */
-	{SUN_CKM_SHA1_HMAC, SHA1_HMAC_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA1_HMAC_MIN_KEY_LEN, SHA1_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA1-HMAC GENERAL */
-	{SUN_CKM_SHA1_HMAC_GENERAL, SHA1_HMAC_GEN_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA1_HMAC_MIN_KEY_LEN, SHA1_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS}
-};
-
-static void sha1_provider_status(crypto_provider_handle_t, uint_t *);
-
-static crypto_control_ops_t sha1_control_ops = {
-	sha1_provider_status
-};
-
-static int sha1_digest_init(crypto_ctx_t *, crypto_mechanism_t *,
-    crypto_req_handle_t);
-static int sha1_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha1_digest_update(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha1_digest_final(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha1_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
-    crypto_req_handle_t);
-
-static crypto_digest_ops_t sha1_digest_ops = {
-	sha1_digest_init,
-	sha1_digest,
-	sha1_digest_update,
-	NULL,
-	sha1_digest_final,
-	sha1_digest_atomic
-};
-
-static int sha1_mac_init(crypto_ctx_t *, crypto_mechanism_t *, crypto_key_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-static int sha1_mac_update(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha1_mac_final(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
-static int sha1_mac_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-static int sha1_mac_verify_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-
-static crypto_mac_ops_t sha1_mac_ops = {
-	sha1_mac_init,
-	NULL,
-	sha1_mac_update,
-	sha1_mac_final,
-	sha1_mac_atomic,
-	sha1_mac_verify_atomic
-};
-
-static int sha1_create_ctx_template(crypto_provider_handle_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
-    size_t *, crypto_req_handle_t);
-static int sha1_free_context(crypto_ctx_t *);
-
-static crypto_ctx_ops_t sha1_ctx_ops = {
-	sha1_create_ctx_template,
-	sha1_free_context
-};
-
-static crypto_ops_t sha1_crypto_ops = {
-	&sha1_control_ops,
-	&sha1_digest_ops,
-	NULL,
-	&sha1_mac_ops,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	&sha1_ctx_ops
-};
-
-static crypto_provider_info_t sha1_prov_info = {
-	CRYPTO_SPI_VERSION_1,
-	"SHA1 Software Provider",
-	CRYPTO_SW_PROVIDER,
-	{&modlinkage},
-	NULL,
-	&sha1_crypto_ops,
-	sizeof (sha1_mech_info_tab)/sizeof (crypto_mech_info_t),
-	sha1_mech_info_tab
-};
-
-static crypto_kcf_provider_handle_t sha1_prov_handle = NULL;
-
-int
-_init()
-{
-	int ret;
-
-	if ((ret = mod_install(&modlinkage)) != 0)
-		return (ret);
-
-	/*
-	 * Register with KCF. If the registration fails, log an
-	 * error but do not uninstall the module, since the functionality
-	 * provided by misc/sha1 should still be available.
-	 */
-	if ((ret = crypto_register_provider(&sha1_prov_info,
-	    &sha1_prov_handle)) != CRYPTO_SUCCESS)
-		cmn_err(CE_WARN, "sha1 _init: "
-		    "crypto_register_provider() failed (0x%x)", ret);
-
-	return (0);
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (mod_info(&modlinkage, modinfop));
-}
-
-#endif /* _KERNEL */
+#endif
 
 /*
  * SHA1Init()
@@ -324,8 +136,6 @@
 }
 
 #ifdef VIS_SHA1
-
-
 #ifdef _KERNEL
 
 #include <sys/regset.h>
@@ -340,69 +150,6 @@
 
 uint32_t	vis_sha1_svfp_threshold = 128;
 
-#else /* !_KERNEL */
-
-static boolean_t checked_vis = B_FALSE;
-static int usevis = 0;
-
-static int
-havevis()
-{
-	char *buf = NULL;
-	char *isa_token;
-	char *lasts;
-	int ret = 0;
-	size_t bufsize = 255; /* UltraSPARC III needs 115 chars */
-	int v9_isa_token, vis_isa_token, isa_token_num;
-
-	if (checked_vis) {
-		return (usevis);
-	}
-
-	if ((buf = malloc(bufsize)) == NULL) {
-		return (0);
-	}
-
-	if ((ret = sysinfo(SI_ISALIST, buf, bufsize)) == -1) {
-		free(buf);
-		return (0);
-	} else if (ret > bufsize) {
-		/* We lost some because our buffer was too small  */
-		if ((buf = realloc(buf, bufsize = ret)) == NULL) {
-			return (0);
-		}
-		if ((ret = sysinfo(SI_ISALIST, buf, bufsize)) == -1) {
-			free(buf);
-			return (0);
-		}
-	}
-
-	/*
-	 * Check the relative posistions of sparcv9 & sparcv9+vis
-	 * because they are listed in (best) performance order.
-	 * For example: The Niagara chip reports it has VIS but the
-	 * SHA1 code runs faster without this optimisation.
-	 */
-	isa_token = strtok_r(buf, " ", &lasts);
-	v9_isa_token = vis_isa_token = -1;
-	isa_token_num = 0;
-	do {
-		if (strcmp(isa_token, "sparcv9") == 0) {
-			v9_isa_token = isa_token_num;
-		} else if (strcmp(isa_token, "sparcv9+vis") == 0) {
-			vis_isa_token = isa_token_num;
-		}
-		isa_token_num++;
-	} while (isa_token = strtok_r(NULL, " ", &lasts));
-
-	if (vis_isa_token != -1 && vis_isa_token < v9_isa_token)
-		usevis = 1;
-	free(buf);
-
-	checked_vis = B_TRUE;
-	return (usevis);
-}
-
 #endif /* _KERNEL */
 
 /*
@@ -415,7 +162,7 @@
 	0x8f1bbcdcca62c1d6ULL,
 	0x012389ab456789abULL};
 
-extern void SHA1TransformVIS(uint64_t *, uint64_t *, uint32_t *, uint64_t *);
+extern void SHA1TransformVIS(uint64_t *, uint32_t *, uint32_t *, uint64_t *);
 
 
 /*
@@ -424,18 +171,21 @@
  * purpose: continues an sha1 digest operation, using the message block
  *          to update the context.
  *   input: SHA1_CTX *	: the context to update
- *          uint8_t *	: the message block
- *          uint32_t    : the length of the message block in bytes
+ *          void *	: the message block
+ *          size_t    : the length of the message block in bytes
  *  output: void
  */
 
 void
-SHA1Update(SHA1_CTX *ctx, const uint8_t *input, uint32_t input_len)
+SHA1Update(SHA1_CTX *ctx, const void *inptr, size_t input_len)
 {
 	uint32_t i, buf_index, buf_len;
 	uint64_t X0[40], input64[8];
+	const uint8_t *input = inptr;
 #ifdef _KERNEL
 	int usevis = 0;
+#else
+	int usevis = 1;
 #endif /* _KERNEL */
 
 	/* check for noop */
@@ -457,18 +207,18 @@
 	i = 0;
 	if (input_len >= buf_len) {
 #ifdef _KERNEL
-		uint8_t fpua[sizeof (kfpu_t) + GSR_SIZE + VIS_ALIGN];
 		kfpu_t *fpu;
-
-		uint32_t len = (input_len + buf_index) & ~0x3f;
-		int svfp_ok;
+		if (fpu_exists) {
+			uint8_t fpua[sizeof (kfpu_t) + GSR_SIZE + VIS_ALIGN];
+			uint32_t len = (input_len + buf_index) & ~0x3f;
+			int svfp_ok;
 
-		fpu = (kfpu_t *)P2ROUNDUP((uintptr_t)fpua, 64);
-		svfp_ok = ((len >= vis_sha1_svfp_threshold) ? 1 : 0);
-		usevis = fpu_exists && sha1_savefp(fpu, svfp_ok);
-#else
-		if (!checked_vis)
-			usevis = havevis();
+			fpu = (kfpu_t *)P2ROUNDUP((uintptr_t)fpua, 64);
+			svfp_ok = ((len >= vis_sha1_svfp_threshold) ? 1 : 0);
+			usevis = fpu_exists && sha1_savefp(fpu, svfp_ok);
+		} else {
+			usevis = 0;
+		}
 #endif /* _KERNEL */
 
 		/*
@@ -485,12 +235,10 @@
 			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
 			if (usevis) {
 				SHA1TransformVIS(X0,
-				    (uint64_t *)ctx->buf_un.buf8,
+				    ctx->buf_un.buf32,
 				    &ctx->state[0], VIS);
 			} else {
-				SHA1Transform(ctx->state[0], ctx->state[1],
-				    ctx->state[2], ctx->state[3],
-				    ctx->state[4], ctx, ctx->buf_un.buf8);
+				SHA1_TRANSFORM(ctx, ctx->buf_un.buf8);
 			}
 			i = buf_len;
 		}
@@ -510,7 +258,7 @@
 		 *
 		 * void SHA1TransformVIS(
 		 *	 uint64_t *, // Pointer to MS for ith block
-		 *	 uint64_t *, // Pointer to ith block of message data
+		 *	 uint32_t *, // Pointer to ith block of message data
 		 *	 uint32_t *, // Pointer to SHA state i.e ctx->state
 		 *	 uint64_t *, // Pointer to various VIS constants
 		 * )
@@ -524,13 +272,13 @@
 		 * for alignments other than 4-bytes.
 		 */
 		if (usevis) {
-			if (((uint64_t)(uintptr_t)(&input[i]) & 0x3)) {
+			if (!IS_P2ALIGNED(&input[i], sizeof (uint32_t))) {
 				/*
 				 * Main processing loop - input misaligned
 				 */
 				for (; i + 63 < input_len; i += 64) {
 				    bcopy(&input[i], input64, 64);
-				    SHA1TransformVIS(X0, input64,
+				    SHA1TransformVIS(X0, (uint32_t *)input64,
 					&ctx->state[0], VIS);
 				}
 			} else {
@@ -539,7 +287,8 @@
 				 */
 				for (; i + 63 < input_len; i += 64) {
 					SHA1TransformVIS(X0,
-					    (uint64_t *)&input[i],
+					    /* LINTED E_BAD_PTR_CAST_ALIGN */
+					    (uint32_t *)&input[i],
 					    &ctx->state[0], VIS);
 				}
 
@@ -549,9 +298,7 @@
 #endif /* _KERNEL */
 		} else {
 			for (; i + 63 < input_len; i += 64) {
-			    SHA1Transform(ctx->state[0], ctx->state[1],
-				ctx->state[2], ctx->state[3], ctx->state[4],
-				ctx, &input[i]);
+			    SHA1_TRANSFORM(ctx, &input[i]);
 			}
 		}
 
@@ -576,9 +323,10 @@
 #else /* VIS_SHA1 */
 
 void
-SHA1Update(SHA1_CTX *ctx, const uint8_t *input, uint32_t input_len)
+SHA1Update(SHA1_CTX *ctx, const void *inptr, size_t input_len)
 {
 	uint32_t i, buf_index, buf_len;
+	const uint8_t *input = inptr;
 
 	/* check for noop */
 	if (input_len == 0)
@@ -611,19 +359,12 @@
 
 		if (buf_index) {
 			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
-
-
-			SHA1Transform(ctx->state[0], ctx->state[1],
-			    ctx->state[2], ctx->state[3], ctx->state[4], ctx,
-			    ctx->buf_un.buf8);
-
+			SHA1_TRANSFORM(ctx, ctx->buf_un.buf8);
 			i = buf_len;
 		}
 
 		for (; i + 63 < input_len; i += 64)
-			SHA1Transform(ctx->state[0], ctx->state[1],
-			    ctx->state[2], ctx->state[3], ctx->state[4],
-			    ctx, &input[i]);
+			SHA1_TRANSFORM(ctx, &input[i]);
 
 		/*
 		 * general optimization:
@@ -656,7 +397,7 @@
  */
 
 void
-SHA1Final(uint8_t *digest, SHA1_CTX *ctx)
+SHA1Final(void *digest, SHA1_CTX *ctx)
 {
 	uint8_t		bitcount_be[sizeof (ctx->count)];
 	uint32_t	index = (ctx->count[1] >> 3) & 0x3f;
@@ -677,6 +418,12 @@
 	bzero(ctx, sizeof (*ctx));
 }
 
+#if	defined(__amd64)
+typedef uint64_t sha1word;
+#else
+typedef uint32_t sha1word;
+#endif
+
 /*
  * sparc optimization:
  *
@@ -690,11 +437,33 @@
 
 #define	LOAD_BIG_32(addr)	(*(uint32_t *)(addr))
 
-#else	/* little endian -- will work on big endian, but slowly */
+#else	/* !defined(_BIG_ENDIAN) */
+
+#if	defined(HAVE_BSWAP)
 
+#define	LOAD_BIG_32(addr) bswap(*((uint32_t *)(addr)))
+
+#else	/* !defined(HAVE_BSWAP) */
+
+/* little endian -- will work on big endian, but slowly */
 #define	LOAD_BIG_32(addr)	\
 	(((addr)[0] << 24) | ((addr)[1] << 16) | ((addr)[2] << 8) | (addr)[3])
-#endif
+
+#endif	/* !defined(HAVE_BSWAP) */
+
+#endif	/* !defined(_BIG_ENDIAN) */
+
+/*
+ * SHA1Transform()
+ */
+#if	defined(W_ARRAY)
+#define	W(n) w[n]
+#else	/* !defined(W_ARRAY) */
+#define	W(n) w_ ## n
+#endif	/* !defined(W_ARRAY) */
+
+
+#if	defined(__sparc)
 
 /*
  * sparc register window optimization:
@@ -703,10 +472,6 @@
  * explicitly since it increases the number of registers available to
  * the compiler.  under this scheme, these variables can be held in
  * %i0 - %i4, which leaves more local and out registers available.
- */
-
-/*
- * SHA1Transform()
  *
  * purpose: sha1 transformation -- updates the digest based on `block'
  *   input: uint32_t	: bytes  1 -  4 of the digest
@@ -757,11 +522,9 @@
 	 * depending on what platform this code is compiled for.
 	 */
 
-#if	defined(__sparc)
 	static const uint32_t sha1_consts[] = {
 		SHA1_CONST_0,	SHA1_CONST_1,	SHA1_CONST_2,	SHA1_CONST_3,
 	};
-#endif
 
 	/*
 	 * general optimization:
@@ -791,7 +554,6 @@
 	 * *does not* like that, so please resist the urge.
 	 */
 
-#if	defined(__sparc)
 	if ((uintptr_t)blk & 0x3) {		/* not 4-byte aligned? */
 		bcopy(blk, ctx->buf_un.buf32,  sizeof (ctx->buf_un.buf32));
 		w_15 = LOAD_BIG_32(ctx->buf_un.buf32 + 15);
@@ -844,24 +606,43 @@
 		/*LINTED*/
 		w_0  = LOAD_BIG_32(blk +  0);
 	}
-#else
-	w_15 = LOAD_BIG_32(blk + 60);
-	w_14 = LOAD_BIG_32(blk + 56);
-	w_13 = LOAD_BIG_32(blk + 52);
-	w_12 = LOAD_BIG_32(blk + 48);
-	w_11 = LOAD_BIG_32(blk + 44);
-	w_10 = LOAD_BIG_32(blk + 40);
-	w_9  = LOAD_BIG_32(blk + 36);
-	w_8  = LOAD_BIG_32(blk + 32);
-	w_7  = LOAD_BIG_32(blk + 28);
-	w_6  = LOAD_BIG_32(blk + 24);
-	w_5  = LOAD_BIG_32(blk + 20);
-	w_4  = LOAD_BIG_32(blk + 16);
-	w_3  = LOAD_BIG_32(blk + 12);
-	w_2  = LOAD_BIG_32(blk +  8);
-	w_1  = LOAD_BIG_32(blk +  4);
-	w_0  = LOAD_BIG_32(blk +  0);
-#endif
+#else	/* !defined(__sparc) */
+
+void
+SHA1Transform(SHA1_CTX *ctx, const uint8_t blk[64])
+{
+	sha1word a = ctx->state[0];
+	sha1word b = ctx->state[1];
+	sha1word c = ctx->state[2];
+	sha1word d = ctx->state[3];
+	sha1word e = ctx->state[4];
+
+#if	defined(W_ARRAY)
+	sha1word	w[16];
+#else	/* !defined(W_ARRAY) */
+	sha1word	w_0, w_1, w_2,  w_3,  w_4,  w_5,  w_6,  w_7;
+	sha1word	w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15;
+#endif	/* !defined(W_ARRAY) */
+
+	W(0)  = LOAD_BIG_32(blk +  0);
+	W(1)  = LOAD_BIG_32(blk +  4);
+	W(2)  = LOAD_BIG_32(blk +  8);
+	W(3)  = LOAD_BIG_32(blk + 12);
+	W(4)  = LOAD_BIG_32(blk + 16);
+	W(5)  = LOAD_BIG_32(blk + 20);
+	W(6)  = LOAD_BIG_32(blk + 24);
+	W(7)  = LOAD_BIG_32(blk + 28);
+	W(8)  = LOAD_BIG_32(blk + 32);
+	W(9)  = LOAD_BIG_32(blk + 36);
+	W(10) = LOAD_BIG_32(blk + 40);
+	W(11) = LOAD_BIG_32(blk + 44);
+	W(12) = LOAD_BIG_32(blk + 48);
+	W(13) = LOAD_BIG_32(blk + 52);
+	W(14) = LOAD_BIG_32(blk + 56);
+	W(15) = LOAD_BIG_32(blk + 60);
+
+#endif	/* !defined(__sparc) */
+
 	/*
 	 * general optimization:
 	 *
@@ -887,312 +668,312 @@
 	 */
 
 	/* round 1 */
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_0 + SHA1_CONST(0); /* 0 */
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + W(0) + SHA1_CONST(0); /* 0 */
 	b = ROTATE_LEFT(b, 30);
 
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_1 + SHA1_CONST(0); /* 1 */
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + W(1) + SHA1_CONST(0); /* 1 */
 	a = ROTATE_LEFT(a, 30);
 
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_2 + SHA1_CONST(0); /* 2 */
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + W(2) + SHA1_CONST(0); /* 2 */
 	e = ROTATE_LEFT(e, 30);
 
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_3 + SHA1_CONST(0); /* 3 */
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + W(3) + SHA1_CONST(0); /* 3 */
 	d = ROTATE_LEFT(d, 30);
 
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_4 + SHA1_CONST(0); /* 4 */
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + W(4) + SHA1_CONST(0); /* 4 */
 	c = ROTATE_LEFT(c, 30);
 
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_5 + SHA1_CONST(0); /* 5 */
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + W(5) + SHA1_CONST(0); /* 5 */
 	b = ROTATE_LEFT(b, 30);
 
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_6 + SHA1_CONST(0); /* 6 */
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + W(6) + SHA1_CONST(0); /* 6 */
 	a = ROTATE_LEFT(a, 30);
 
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_7 + SHA1_CONST(0); /* 7 */
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + W(7) + SHA1_CONST(0); /* 7 */
 	e = ROTATE_LEFT(e, 30);
 
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_8 + SHA1_CONST(0); /* 8 */
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + W(8) + SHA1_CONST(0); /* 8 */
 	d = ROTATE_LEFT(d, 30);
 
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_9 + SHA1_CONST(0); /* 9 */
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + W(9) + SHA1_CONST(0); /* 9 */
 	c = ROTATE_LEFT(c, 30);
 
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_10 + SHA1_CONST(0); /* 10 */
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + W(10) + SHA1_CONST(0); /* 10 */
 	b = ROTATE_LEFT(b, 30);
 
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_11 + SHA1_CONST(0); /* 11 */
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + W(11) + SHA1_CONST(0); /* 11 */
 	a = ROTATE_LEFT(a, 30);
 
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_12 + SHA1_CONST(0); /* 12 */
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + W(12) + SHA1_CONST(0); /* 12 */
 	e = ROTATE_LEFT(e, 30);
 
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_13 + SHA1_CONST(0); /* 13 */
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + W(13) + SHA1_CONST(0); /* 13 */
 	d = ROTATE_LEFT(d, 30);
 
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_14 + SHA1_CONST(0); /* 14 */
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + W(14) + SHA1_CONST(0); /* 14 */
 	c = ROTATE_LEFT(c, 30);
 
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_15 + SHA1_CONST(0); /* 15 */
+	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + W(15) + SHA1_CONST(0); /* 15 */
 	b = ROTATE_LEFT(b, 30);
 
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 16 */
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_0 + SHA1_CONST(0);
+	W(0) = ROTATE_LEFT((W(13) ^ W(8) ^ W(2) ^ W(0)), 1);		/* 16 */
+	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + W(0) + SHA1_CONST(0);
 	a = ROTATE_LEFT(a, 30);
 
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 17 */
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_1 + SHA1_CONST(0);
+	W(1) = ROTATE_LEFT((W(14) ^ W(9) ^ W(3) ^ W(1)), 1);		/* 17 */
+	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + W(1) + SHA1_CONST(0);
 	e = ROTATE_LEFT(e, 30);
 
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 18 */
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_2 + SHA1_CONST(0);
+	W(2) = ROTATE_LEFT((W(15) ^ W(10) ^ W(4) ^ W(2)), 1);	/* 18 */
+	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + W(2) + SHA1_CONST(0);
 	d = ROTATE_LEFT(d, 30);
 
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 19 */
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_3 + SHA1_CONST(0);
+	W(3) = ROTATE_LEFT((W(0) ^ W(11) ^ W(5) ^ W(3)), 1);		/* 19 */
+	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + W(3) + SHA1_CONST(0);
 	c = ROTATE_LEFT(c, 30);
 
 	/* round 2 */
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 20 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_4 + SHA1_CONST(1);
+	W(4) = ROTATE_LEFT((W(1) ^ W(12) ^ W(6) ^ W(4)), 1);		/* 20 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(4) + SHA1_CONST(1);
 	b = ROTATE_LEFT(b, 30);
 
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 21 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_5 + SHA1_CONST(1);
+	W(5) = ROTATE_LEFT((W(2) ^ W(13) ^ W(7) ^ W(5)), 1);		/* 21 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(5) + SHA1_CONST(1);
 	a = ROTATE_LEFT(a, 30);
 
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 22 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_6 + SHA1_CONST(1);
+	W(6) = ROTATE_LEFT((W(3) ^ W(14) ^ W(8) ^ W(6)), 1);		/* 22 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(6) + SHA1_CONST(1);
 	e = ROTATE_LEFT(e, 30);
 
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 23 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_7 + SHA1_CONST(1);
+	W(7) = ROTATE_LEFT((W(4) ^ W(15) ^ W(9) ^ W(7)), 1);		/* 23 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(7) + SHA1_CONST(1);
 	d = ROTATE_LEFT(d, 30);
 
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 24 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_8 + SHA1_CONST(1);
+	W(8) = ROTATE_LEFT((W(5) ^ W(0) ^ W(10) ^ W(8)), 1);		/* 24 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(8) + SHA1_CONST(1);
 	c = ROTATE_LEFT(c, 30);
 
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 25 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_9 + SHA1_CONST(1);
+	W(9) = ROTATE_LEFT((W(6) ^ W(1) ^ W(11) ^ W(9)), 1);		/* 25 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(9) + SHA1_CONST(1);
 	b = ROTATE_LEFT(b, 30);
 
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 26 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_10 + SHA1_CONST(1);
+	W(10) = ROTATE_LEFT((W(7) ^ W(2) ^ W(12) ^ W(10)), 1);	/* 26 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(10) + SHA1_CONST(1);
 	a = ROTATE_LEFT(a, 30);
 
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 27 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_11 + SHA1_CONST(1);
+	W(11) = ROTATE_LEFT((W(8) ^ W(3) ^ W(13) ^ W(11)), 1);	/* 27 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(11) + SHA1_CONST(1);
 	e = ROTATE_LEFT(e, 30);
 
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 28 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_12 + SHA1_CONST(1);
+	W(12) = ROTATE_LEFT((W(9) ^ W(4) ^ W(14) ^ W(12)), 1);	/* 28 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(12) + SHA1_CONST(1);
 	d = ROTATE_LEFT(d, 30);
 
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 29 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_13 + SHA1_CONST(1);
+	W(13) = ROTATE_LEFT((W(10) ^ W(5) ^ W(15) ^ W(13)), 1);	/* 29 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(13) + SHA1_CONST(1);
 	c = ROTATE_LEFT(c, 30);
 
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 30 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_14 + SHA1_CONST(1);
+	W(14) = ROTATE_LEFT((W(11) ^ W(6) ^ W(0) ^ W(14)), 1);	/* 30 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(14) + SHA1_CONST(1);
 	b = ROTATE_LEFT(b, 30);
 
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 31 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_15 + SHA1_CONST(1);
+	W(15) = ROTATE_LEFT((W(12) ^ W(7) ^ W(1) ^ W(15)), 1);	/* 31 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(15) + SHA1_CONST(1);
 	a = ROTATE_LEFT(a, 30);
 
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 32 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_0 + SHA1_CONST(1);
+	W(0) = ROTATE_LEFT((W(13) ^ W(8) ^ W(2) ^ W(0)), 1);		/* 32 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(0) + SHA1_CONST(1);
 	e = ROTATE_LEFT(e, 30);
 
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 33 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_1 + SHA1_CONST(1);
+	W(1) = ROTATE_LEFT((W(14) ^ W(9) ^ W(3) ^ W(1)), 1);		/* 33 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(1) + SHA1_CONST(1);
 	d = ROTATE_LEFT(d, 30);
 
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 34 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_2 + SHA1_CONST(1);
+	W(2) = ROTATE_LEFT((W(15) ^ W(10) ^ W(4) ^ W(2)), 1);	/* 34 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(2) + SHA1_CONST(1);
 	c = ROTATE_LEFT(c, 30);
 
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 35 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_3 + SHA1_CONST(1);
+	W(3) = ROTATE_LEFT((W(0) ^ W(11) ^ W(5) ^ W(3)), 1);		/* 35 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(3) + SHA1_CONST(1);
 	b = ROTATE_LEFT(b, 30);
 
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 36 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_4 + SHA1_CONST(1);
+	W(4) = ROTATE_LEFT((W(1) ^ W(12) ^ W(6) ^ W(4)), 1);		/* 36 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(4) + SHA1_CONST(1);
 	a = ROTATE_LEFT(a, 30);
 
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 37 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_5 + SHA1_CONST(1);
+	W(5) = ROTATE_LEFT((W(2) ^ W(13) ^ W(7) ^ W(5)), 1);		/* 37 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(5) + SHA1_CONST(1);
 	e = ROTATE_LEFT(e, 30);
 
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 38 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_6 + SHA1_CONST(1);
+	W(6) = ROTATE_LEFT((W(3) ^ W(14) ^ W(8) ^ W(6)), 1);		/* 38 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(6) + SHA1_CONST(1);
 	d = ROTATE_LEFT(d, 30);
 
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 39 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_7 + SHA1_CONST(1);
+	W(7) = ROTATE_LEFT((W(4) ^ W(15) ^ W(9) ^ W(7)), 1);		/* 39 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(7) + SHA1_CONST(1);
 	c = ROTATE_LEFT(c, 30);
 
 	/* round 3 */
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 40 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_8 + SHA1_CONST(2);
+	W(8) = ROTATE_LEFT((W(5) ^ W(0) ^ W(10) ^ W(8)), 1);		/* 40 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + W(8) + SHA1_CONST(2);
 	b = ROTATE_LEFT(b, 30);
 
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 41 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_9 + SHA1_CONST(2);
+	W(9) = ROTATE_LEFT((W(6) ^ W(1) ^ W(11) ^ W(9)), 1);		/* 41 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + W(9) + SHA1_CONST(2);
 	a = ROTATE_LEFT(a, 30);
 
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 42 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_10 + SHA1_CONST(2);
+	W(10) = ROTATE_LEFT((W(7) ^ W(2) ^ W(12) ^ W(10)), 1);	/* 42 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + W(10) + SHA1_CONST(2);
 	e = ROTATE_LEFT(e, 30);
 
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 43 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_11 + SHA1_CONST(2);
+	W(11) = ROTATE_LEFT((W(8) ^ W(3) ^ W(13) ^ W(11)), 1);	/* 43 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + W(11) + SHA1_CONST(2);
 	d = ROTATE_LEFT(d, 30);
 
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 44 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_12 + SHA1_CONST(2);
+	W(12) = ROTATE_LEFT((W(9) ^ W(4) ^ W(14) ^ W(12)), 1);	/* 44 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + W(12) + SHA1_CONST(2);
 	c = ROTATE_LEFT(c, 30);
 
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 45 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_13 + SHA1_CONST(2);
+	W(13) = ROTATE_LEFT((W(10) ^ W(5) ^ W(15) ^ W(13)), 1);	/* 45 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + W(13) + SHA1_CONST(2);
 	b = ROTATE_LEFT(b, 30);
 
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 46 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_14 + SHA1_CONST(2);
+	W(14) = ROTATE_LEFT((W(11) ^ W(6) ^ W(0) ^ W(14)), 1);	/* 46 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + W(14) + SHA1_CONST(2);
 	a = ROTATE_LEFT(a, 30);
 
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 47 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_15 + SHA1_CONST(2);
+	W(15) = ROTATE_LEFT((W(12) ^ W(7) ^ W(1) ^ W(15)), 1);	/* 47 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + W(15) + SHA1_CONST(2);
 	e = ROTATE_LEFT(e, 30);
 
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 48 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_0 + SHA1_CONST(2);
+	W(0) = ROTATE_LEFT((W(13) ^ W(8) ^ W(2) ^ W(0)), 1);		/* 48 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + W(0) + SHA1_CONST(2);
 	d = ROTATE_LEFT(d, 30);
 
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 49 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_1 + SHA1_CONST(2);
+	W(1) = ROTATE_LEFT((W(14) ^ W(9) ^ W(3) ^ W(1)), 1);		/* 49 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + W(1) + SHA1_CONST(2);
 	c = ROTATE_LEFT(c, 30);
 
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 50 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_2 + SHA1_CONST(2);
+	W(2) = ROTATE_LEFT((W(15) ^ W(10) ^ W(4) ^ W(2)), 1);	/* 50 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + W(2) + SHA1_CONST(2);
 	b = ROTATE_LEFT(b, 30);
 
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 51 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_3 + SHA1_CONST(2);
+	W(3) = ROTATE_LEFT((W(0) ^ W(11) ^ W(5) ^ W(3)), 1);		/* 51 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + W(3) + SHA1_CONST(2);
 	a = ROTATE_LEFT(a, 30);
 
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 52 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_4 + SHA1_CONST(2);
+	W(4) = ROTATE_LEFT((W(1) ^ W(12) ^ W(6) ^ W(4)), 1);		/* 52 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + W(4) + SHA1_CONST(2);
 	e = ROTATE_LEFT(e, 30);
 
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 53 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_5 + SHA1_CONST(2);
+	W(5) = ROTATE_LEFT((W(2) ^ W(13) ^ W(7) ^ W(5)), 1);		/* 53 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + W(5) + SHA1_CONST(2);
 	d = ROTATE_LEFT(d, 30);
 
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 54 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_6 + SHA1_CONST(2);
+	W(6) = ROTATE_LEFT((W(3) ^ W(14) ^ W(8) ^ W(6)), 1);		/* 54 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + W(6) + SHA1_CONST(2);
 	c = ROTATE_LEFT(c, 30);
 
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 55 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_7 + SHA1_CONST(2);
+	W(7) = ROTATE_LEFT((W(4) ^ W(15) ^ W(9) ^ W(7)), 1);		/* 55 */
+	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + W(7) + SHA1_CONST(2);
 	b = ROTATE_LEFT(b, 30);
 
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 56 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_8 + SHA1_CONST(2);
+	W(8) = ROTATE_LEFT((W(5) ^ W(0) ^ W(10) ^ W(8)), 1);		/* 56 */
+	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + W(8) + SHA1_CONST(2);
 	a = ROTATE_LEFT(a, 30);
 
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 57 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_9 + SHA1_CONST(2);
+	W(9) = ROTATE_LEFT((W(6) ^ W(1) ^ W(11) ^ W(9)), 1);		/* 57 */
+	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + W(9) + SHA1_CONST(2);
 	e = ROTATE_LEFT(e, 30);
 
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 58 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_10 + SHA1_CONST(2);
+	W(10) = ROTATE_LEFT((W(7) ^ W(2) ^ W(12) ^ W(10)), 1);	/* 58 */
+	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + W(10) + SHA1_CONST(2);
 	d = ROTATE_LEFT(d, 30);
 
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 59 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_11 + SHA1_CONST(2);
+	W(11) = ROTATE_LEFT((W(8) ^ W(3) ^ W(13) ^ W(11)), 1);	/* 59 */
+	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + W(11) + SHA1_CONST(2);
 	c = ROTATE_LEFT(c, 30);
 
 	/* round 4 */
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 60 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_12 + SHA1_CONST(3);
+	W(12) = ROTATE_LEFT((W(9) ^ W(4) ^ W(14) ^ W(12)), 1);	/* 60 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(12) + SHA1_CONST(3);
 	b = ROTATE_LEFT(b, 30);
 
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 61 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_13 + SHA1_CONST(3);
+	W(13) = ROTATE_LEFT((W(10) ^ W(5) ^ W(15) ^ W(13)), 1);	/* 61 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(13) + SHA1_CONST(3);
 	a = ROTATE_LEFT(a, 30);
 
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 62 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_14 + SHA1_CONST(3);
+	W(14) = ROTATE_LEFT((W(11) ^ W(6) ^ W(0) ^ W(14)), 1);	/* 62 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(14) + SHA1_CONST(3);
 	e = ROTATE_LEFT(e, 30);
 
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 63 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_15 + SHA1_CONST(3);
+	W(15) = ROTATE_LEFT((W(12) ^ W(7) ^ W(1) ^ W(15)), 1);	/* 63 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(15) + SHA1_CONST(3);
 	d = ROTATE_LEFT(d, 30);
 
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 64 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_0 + SHA1_CONST(3);
+	W(0) = ROTATE_LEFT((W(13) ^ W(8) ^ W(2) ^ W(0)), 1);		/* 64 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(0) + SHA1_CONST(3);
 	c = ROTATE_LEFT(c, 30);
 
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 65 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_1 + SHA1_CONST(3);
+	W(1) = ROTATE_LEFT((W(14) ^ W(9) ^ W(3) ^ W(1)), 1);		/* 65 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(1) + SHA1_CONST(3);
 	b = ROTATE_LEFT(b, 30);
 
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 66 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_2 + SHA1_CONST(3);
+	W(2) = ROTATE_LEFT((W(15) ^ W(10) ^ W(4) ^ W(2)), 1);	/* 66 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(2) + SHA1_CONST(3);
 	a = ROTATE_LEFT(a, 30);
 
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 67 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_3 + SHA1_CONST(3);
+	W(3) = ROTATE_LEFT((W(0) ^ W(11) ^ W(5) ^ W(3)), 1);		/* 67 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(3) + SHA1_CONST(3);
 	e = ROTATE_LEFT(e, 30);
 
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 68 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_4 + SHA1_CONST(3);
+	W(4) = ROTATE_LEFT((W(1) ^ W(12) ^ W(6) ^ W(4)), 1);		/* 68 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(4) + SHA1_CONST(3);
 	d = ROTATE_LEFT(d, 30);
 
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 69 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_5 + SHA1_CONST(3);
+	W(5) = ROTATE_LEFT((W(2) ^ W(13) ^ W(7) ^ W(5)), 1);		/* 69 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(5) + SHA1_CONST(3);
 	c = ROTATE_LEFT(c, 30);
 
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 70 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_6 + SHA1_CONST(3);
+	W(6) = ROTATE_LEFT((W(3) ^ W(14) ^ W(8) ^ W(6)), 1);		/* 70 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(6) + SHA1_CONST(3);
 	b = ROTATE_LEFT(b, 30);
 
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 71 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_7 + SHA1_CONST(3);
+	W(7) = ROTATE_LEFT((W(4) ^ W(15) ^ W(9) ^ W(7)), 1);		/* 71 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(7) + SHA1_CONST(3);
 	a = ROTATE_LEFT(a, 30);
 
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 72 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_8 + SHA1_CONST(3);
+	W(8) = ROTATE_LEFT((W(5) ^ W(0) ^ W(10) ^ W(8)), 1);		/* 72 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(8) + SHA1_CONST(3);
 	e = ROTATE_LEFT(e, 30);
 
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 73 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_9 + SHA1_CONST(3);
+	W(9) = ROTATE_LEFT((W(6) ^ W(1) ^ W(11) ^ W(9)), 1);		/* 73 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(9) + SHA1_CONST(3);
 	d = ROTATE_LEFT(d, 30);
 
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 74 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_10 + SHA1_CONST(3);
+	W(10) = ROTATE_LEFT((W(7) ^ W(2) ^ W(12) ^ W(10)), 1);	/* 74 */
+	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(10) + SHA1_CONST(3);
 	c = ROTATE_LEFT(c, 30);
 
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 75 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_11 + SHA1_CONST(3);
+	W(11) = ROTATE_LEFT((W(8) ^ W(3) ^ W(13) ^ W(11)), 1);	/* 75 */
+	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + W(11) + SHA1_CONST(3);
 	b = ROTATE_LEFT(b, 30);
 
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 76 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_12 + SHA1_CONST(3);
+	W(12) = ROTATE_LEFT((W(9) ^ W(4) ^ W(14) ^ W(12)), 1);	/* 76 */
+	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + W(12) + SHA1_CONST(3);
 	a = ROTATE_LEFT(a, 30);
 
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 77 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_13 + SHA1_CONST(3);
+	W(13) = ROTATE_LEFT((W(10) ^ W(5) ^ W(15) ^ W(13)), 1);	/* 77 */
+	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + W(13) + SHA1_CONST(3);
 	e = ROTATE_LEFT(e, 30);
 
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 78 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_14 + SHA1_CONST(3);
+	W(14) = ROTATE_LEFT((W(11) ^ W(6) ^ W(0) ^ W(14)), 1);	/* 78 */
+	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + W(14) + SHA1_CONST(3);
 	d = ROTATE_LEFT(d, 30);
 
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 79 */
+	W(15) = ROTATE_LEFT((W(12) ^ W(7) ^ W(1) ^ W(15)), 1);	/* 79 */
 
-	ctx->state[0] += ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_15 +
+	ctx->state[0] += ROTATE_LEFT(b, 5) + G(c, d, e) + a + W(15) +
 	    SHA1_CONST(3);
 	ctx->state[1] += b;
 	ctx->state[2] += ROTATE_LEFT(c, 30);
@@ -1200,26 +981,11 @@
 	ctx->state[4] += e;
 
 	/* zeroize sensitive information */
-	w_0 = w_1 = w_2 = w_3 = w_4 = w_5 = w_6 = w_7 = w_8 = 0;
-	w_9 = w_10 = w_11 = w_12 = w_13 = w_14 = w_15 = 0;
+	W(0) = W(1) = W(2) = W(3) = W(4) = W(5) = W(6) = W(7) = W(8) = 0;
+	W(9) = W(10) = W(11) = W(12) = W(13) = W(14) = W(15) = 0;
 }
 
 /*
- * devpro compiler optimization:
- *
- * the compiler can generate better code if it knows that `input' and
- * `output' do not point to the same source.  there is no portable
- * way to tell the compiler this, but the sun compiler recognizes the
- * `_Restrict' keyword to indicate this condition.  use it if possible.
- */
-
-#ifdef	__RESTRICT
-#define	restrict	_Restrict
-#else
-#define	restrict	/* nothing */
-#endif
-
-/*
  * Encode()
  *
  * purpose: to convert a list of numbers from little endian to big endian
@@ -1230,7 +996,8 @@
  */
 
 static void
-Encode(uint8_t *restrict output, uint32_t *restrict input, size_t len)
+Encode(uint8_t *_RESTRICT_KYWD output, const uint32_t *_RESTRICT_KYWD input,
+    size_t len)
 {
 	size_t		i, j;
 
@@ -1252,1224 +1019,3 @@
 	}
 #endif
 }
-
-
-#ifdef _KERNEL
-
-/*
- * KCF software provider control entry points.
- */
-/* ARGSUSED */
-static void
-sha1_provider_status(crypto_provider_handle_t provider, uint_t *status)
-{
-	*status = CRYPTO_PROVIDER_READY;
-}
-
-/*
- * KCF software provider digest entry points.
- */
-
-static int
-sha1_digest_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
-    crypto_req_handle_t req)
-{
-	if (mechanism->cm_type != SHA1_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/*
-	 * Allocate and initialize SHA1 context.
-	 */
-	ctx->cc_provider_private = kmem_alloc(sizeof (sha1_ctx_t),
-	    crypto_kmflag(req));
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	PROV_SHA1_CTX(ctx)->sc_mech_type = SHA1_MECH_INFO_TYPE;
-	SHA1Init(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx);
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA1 digest update function for uio data.
- */
-static int
-sha1_digest_update_uio(SHA1_CTX *sha1_ctx, crypto_data_t *data)
-{
-	off_t offset = data->cd_offset;
-	size_t length = data->cd_length;
-	uint_t vec_idx;
-	size_t cur_len;
-
-	/* we support only kernel buffer */
-	if (data->cd_uio->uio_segflg != UIO_SYSSPACE)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Jump to the first iovec containing data to be
-	 * digested.
-	 */
-	for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
-	    offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
-	    offset -= data->cd_uio->uio_iov[vec_idx++].iov_len);
-	if (vec_idx == data->cd_uio->uio_iovcnt) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	/*
-	 * Now do the digesting on the iovecs.
-	 */
-	while (vec_idx < data->cd_uio->uio_iovcnt && length > 0) {
-		cur_len = MIN(data->cd_uio->uio_iov[vec_idx].iov_len -
-		    offset, length);
-
-		SHA1Update(sha1_ctx,
-		    (uint8_t *)data->cd_uio->uio_iov[vec_idx].iov_base + offset,
-		    cur_len);
-
-		length -= cur_len;
-		vec_idx++;
-		offset = 0;
-	}
-
-	if (vec_idx == data->cd_uio->uio_iovcnt && length > 0) {
-		/*
-		 * The end of the specified iovec's was reached but
-		 * the length requested could not be processed, i.e.
-		 * The caller requested to digest more data than it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA1 digest final function for uio data.
- * digest_len is the length of the desired digest. If digest_len
- * is smaller than the default SHA1 digest length, the caller
- * must pass a scratch buffer, digest_scratch, which must
- * be at least SHA1_DIGEST_LENGTH bytes.
- */
-static int
-sha1_digest_final_uio(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
-    ulong_t digest_len, uchar_t *digest_scratch)
-{
-	off_t offset = digest->cd_offset;
-	uint_t vec_idx;
-
-	/* we support only kernel buffer */
-	if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Jump to the first iovec containing ptr to the digest to
-	 * be returned.
-	 */
-	for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
-	    vec_idx < digest->cd_uio->uio_iovcnt;
-	    offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len);
-	if (vec_idx == digest->cd_uio->uio_iovcnt) {
-		/*
-		 * The caller specified an offset that is
-		 * larger than the total size of the buffers
-		 * it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	if (offset + digest_len <=
-	    digest->cd_uio->uio_iov[vec_idx].iov_len) {
-		/*
-		 * The computed SHA1 digest will fit in the current
-		 * iovec.
-		 */
-		if (digest_len != SHA1_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA1Final(digest_scratch, sha1_ctx);
-			bcopy(digest_scratch, (uchar_t *)digest->
-			    cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    digest_len);
-		} else {
-			SHA1Final((uchar_t *)digest->
-			    cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    sha1_ctx);
-		}
-	} else {
-		/*
-		 * The computed digest will be crossing one or more iovec's.
-		 * This is bad performance-wise but we need to support it.
-		 * Allocate a small scratch buffer on the stack and
-		 * copy it piece meal to the specified digest iovec's.
-		 */
-		uchar_t digest_tmp[SHA1_DIGEST_LENGTH];
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		SHA1Final(digest_tmp, sha1_ctx);
-
-		while (vec_idx < digest->cd_uio->uio_iovcnt && length > 0) {
-			cur_len = MIN(digest->cd_uio->uio_iov[vec_idx].iov_len -
-			    offset, length);
-			bcopy(digest_tmp + scratch_offset,
-			    digest->cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    cur_len);
-
-			length -= cur_len;
-			vec_idx++;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-
-		if (vec_idx == digest->cd_uio->uio_iovcnt && length > 0) {
-			/*
-			 * The end of the specified iovec's was reached but
-			 * the length requested could not be processed, i.e.
-			 * The caller requested to digest more data than it
-			 * provided.
-			 */
-			return (CRYPTO_DATA_LEN_RANGE);
-		}
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA1 digest update for mblk's.
- */
-static int
-sha1_digest_update_mblk(SHA1_CTX *sha1_ctx, crypto_data_t *data)
-{
-	off_t offset = data->cd_offset;
-	size_t length = data->cd_length;
-	mblk_t *mp;
-	size_t cur_len;
-
-	/*
-	 * Jump to the first mblk_t containing data to be digested.
-	 */
-	for (mp = data->cd_mp; mp != NULL && offset >= MBLKL(mp);
-	    offset -= MBLKL(mp), mp = mp->b_cont);
-	if (mp == NULL) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	/*
-	 * Now do the digesting on the mblk chain.
-	 */
-	while (mp != NULL && length > 0) {
-		cur_len = MIN(MBLKL(mp) - offset, length);
-		SHA1Update(sha1_ctx, mp->b_rptr + offset, cur_len);
-		length -= cur_len;
-		offset = 0;
-		mp = mp->b_cont;
-	}
-
-	if (mp == NULL && length > 0) {
-		/*
-		 * The end of the mblk was reached but the length requested
-		 * could not be processed, i.e. The caller requested
-		 * to digest more data than it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA1 digest final for mblk's.
- * digest_len is the length of the desired digest. If digest_len
- * is smaller than the default SHA1 digest length, the caller
- * must pass a scratch buffer, digest_scratch, which must
- * be at least SHA1_DIGEST_LENGTH bytes.
- */
-static int
-sha1_digest_final_mblk(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
-    ulong_t digest_len, uchar_t *digest_scratch)
-{
-	off_t offset = digest->cd_offset;
-	mblk_t *mp;
-
-	/*
-	 * Jump to the first mblk_t that will be used to store the digest.
-	 */
-	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
-	    offset -= MBLKL(mp), mp = mp->b_cont);
-	if (mp == NULL) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	if (offset + digest_len <= MBLKL(mp)) {
-		/*
-		 * The computed SHA1 digest will fit in the current mblk.
-		 * Do the SHA1Final() in-place.
-		 */
-		if (digest_len != SHA1_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA1Final(digest_scratch, sha1_ctx);
-			bcopy(digest_scratch, mp->b_rptr + offset, digest_len);
-		} else {
-			SHA1Final(mp->b_rptr + offset, sha1_ctx);
-		}
-	} else {
-		/*
-		 * The computed digest will be crossing one or more mblk's.
-		 * This is bad performance-wise but we need to support it.
-		 * Allocate a small scratch buffer on the stack and
-		 * copy it piece meal to the specified digest iovec's.
-		 */
-		uchar_t digest_tmp[SHA1_DIGEST_LENGTH];
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		SHA1Final(digest_tmp, sha1_ctx);
-
-		while (mp != NULL && length > 0) {
-			cur_len = MIN(MBLKL(mp) - offset, length);
-			bcopy(digest_tmp + scratch_offset,
-			    mp->b_rptr + offset, cur_len);
-
-			length -= cur_len;
-			mp = mp->b_cont;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-
-		if (mp == NULL && length > 0) {
-			/*
-			 * The end of the specified mblk was reached but
-			 * the length requested could not be processed, i.e.
-			 * The caller requested to digest more data than it
-			 * provided.
-			 */
-			return (CRYPTO_DATA_LEN_RANGE);
-		}
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/* ARGSUSED */
-static int
-sha1_digest(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((digest->cd_length == 0) ||
-	    (digest->cd_length < SHA1_DIGEST_LENGTH)) {
-		digest->cd_length = SHA1_DIGEST_LENGTH;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do the SHA1 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Update(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_update_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_update_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		/* the update failed, free context and bail */
-		kmem_free(ctx->cc_provider_private, sizeof (sha1_ctx_t));
-		ctx->cc_provider_private = NULL;
-		digest->cd_length = 0;
-		return (ret);
-	}
-
-	/*
-	 * Do a SHA1 final, must be done separately since the digest
-	 * type can be different than the input data type.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &PROV_SHA1_CTX(ctx)->sc_sha1_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_final_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    digest, SHA1_DIGEST_LENGTH, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_final_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    digest, SHA1_DIGEST_LENGTH, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/* all done, free context and return */
-
-	if (ret == CRYPTO_SUCCESS) {
-		digest->cd_length = SHA1_DIGEST_LENGTH;
-	} else {
-		digest->cd_length = 0;
-	}
-
-	kmem_free(ctx->cc_provider_private, sizeof (sha1_ctx_t));
-	ctx->cc_provider_private = NULL;
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha1_digest_update(crypto_ctx_t *ctx, crypto_data_t *data,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * Do the SHA1 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Update(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_update_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_update_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha1_digest_final(crypto_ctx_t *ctx, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((digest->cd_length == 0) ||
-	    (digest->cd_length < SHA1_DIGEST_LENGTH)) {
-		digest->cd_length = SHA1_DIGEST_LENGTH;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do a SHA1 final.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &PROV_SHA1_CTX(ctx)->sc_sha1_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_final_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    digest, SHA1_DIGEST_LENGTH, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_final_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
-		    digest, SHA1_DIGEST_LENGTH, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/* all done, free context and return */
-
-	if (ret == CRYPTO_SUCCESS) {
-		digest->cd_length = SHA1_DIGEST_LENGTH;
-	} else {
-		digest->cd_length = 0;
-	}
-
-	kmem_free(ctx->cc_provider_private, sizeof (sha1_ctx_t));
-	ctx->cc_provider_private = NULL;
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha1_digest_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_data_t *data, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	SHA1_CTX sha1_ctx;
-
-	if (mechanism->cm_type != SHA1_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/*
-	 * Do the SHA1 init.
-	 */
-	SHA1Init(&sha1_ctx);
-
-	/*
-	 * Do the SHA1 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Update(&sha1_ctx,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_update_uio(&sha1_ctx, data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_update_mblk(&sha1_ctx, data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		/* the update failed, bail */
-		digest->cd_length = 0;
-		return (ret);
-	}
-
-	/*
-	 * Do a SHA1 final, must be done separately since the digest
-	 * type can be different than the input data type.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &sha1_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_final_uio(&sha1_ctx, digest,
-		    SHA1_DIGEST_LENGTH, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_final_mblk(&sha1_ctx, digest,
-		    SHA1_DIGEST_LENGTH, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		digest->cd_length = SHA1_DIGEST_LENGTH;
-	} else {
-		digest->cd_length = 0;
-	}
-
-	return (ret);
-}
-
-/*
- * KCF software provider mac entry points.
- *
- * SHA1 HMAC is: SHA1(key XOR opad, SHA1(key XOR ipad, text))
- *
- * Init:
- * The initialization routine initializes what we denote
- * as the inner and outer contexts by doing
- * - for inner context: SHA1(key XOR ipad)
- * - for outer context: SHA1(key XOR opad)
- *
- * Update:
- * Each subsequent SHA1 HMAC update will result in an
- * update of the inner context with the specified data.
- *
- * Final:
- * The SHA1 HMAC final will do a SHA1 final operation on the
- * inner context, and the resulting digest will be used
- * as the data for an update on the outer context. Last
- * but not least, a SHA1 final on the outer context will
- * be performed to obtain the SHA1 HMAC digest to return
- * to the user.
- */
-
-/*
- * Initialize a SHA1-HMAC context.
- */
-static void
-sha1_mac_init_ctx(sha1_hmac_ctx_t *ctx, void *keyval, uint_t length_in_bytes)
-{
-	uint32_t ipad[SHA1_HMAC_INTS_PER_BLOCK];
-	uint32_t opad[SHA1_HMAC_INTS_PER_BLOCK];
-	uint_t i;
-
-	bzero(ipad, SHA1_HMAC_BLOCK_SIZE);
-	bzero(opad, SHA1_HMAC_BLOCK_SIZE);
-
-	bcopy(keyval, ipad, length_in_bytes);
-	bcopy(keyval, opad, length_in_bytes);
-
-	/* XOR key with ipad (0x36) and opad (0x5c) */
-	for (i = 0; i < SHA1_HMAC_INTS_PER_BLOCK; i++) {
-		ipad[i] ^= 0x36363636;
-		opad[i] ^= 0x5c5c5c5c;
-	}
-
-	/* perform SHA1 on ipad */
-	SHA1Init(&ctx->hc_icontext);
-	SHA1Update(&ctx->hc_icontext, (uint8_t *)ipad, SHA1_HMAC_BLOCK_SIZE);
-
-	/* perform SHA1 on opad */
-	SHA1Init(&ctx->hc_ocontext);
-	SHA1Update(&ctx->hc_ocontext, (uint8_t *)opad, SHA1_HMAC_BLOCK_SIZE);
-}
-
-/*
- */
-static int
-sha1_mac_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if (mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE &&
-	    mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	ctx->cc_provider_private = kmem_alloc(sizeof (sha1_hmac_ctx_t),
-	    crypto_kmflag(req));
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, PROV_SHA1_HMAC_CTX(ctx),
-		    sizeof (sha1_hmac_ctx_t));
-	} else {
-		/* no context template, compute context */
-		if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
-			uchar_t digested_key[SHA1_DIGEST_LENGTH];
-			sha1_hmac_ctx_t *hmac_ctx = ctx->cc_provider_private;
-
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_SHA1_DIGEST_KEY(&hmac_ctx->hc_icontext,
-			    key->ck_data, keylen_in_bytes, digested_key);
-			sha1_mac_init_ctx(PROV_SHA1_HMAC_CTX(ctx),
-			    digested_key, SHA1_DIGEST_LENGTH);
-		} else {
-			sha1_mac_init_ctx(PROV_SHA1_HMAC_CTX(ctx),
-			    key->ck_data, keylen_in_bytes);
-		}
-	}
-
-	/*
-	 * Get the mechanism parameters, if applicable.
-	 */
-	PROV_SHA1_HMAC_CTX(ctx)->hc_mech_type = mechanism->cm_type;
-	if (mechanism->cm_type == SHA1_HMAC_GEN_MECH_INFO_TYPE) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t))
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-		PROV_SHA1_GET_DIGEST_LEN(mechanism,
-		    PROV_SHA1_HMAC_CTX(ctx)->hc_digest_len);
-		if (PROV_SHA1_HMAC_CTX(ctx)->hc_digest_len >
-		    SHA1_DIGEST_LENGTH)
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		bzero(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
-		kmem_free(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
-		ctx->cc_provider_private = NULL;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha1_mac_update(crypto_ctx_t *ctx, crypto_data_t *data, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * Do a SHA1 update of the inner context using the specified
-	 * data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA1Update(&PROV_SHA1_HMAC_CTX(ctx)->hc_icontext,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_update_uio(
-		    &PROV_SHA1_HMAC_CTX(ctx)->hc_icontext, data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_update_mblk(
-		    &PROV_SHA1_HMAC_CTX(ctx)->hc_icontext, data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha1_mac_final(crypto_ctx_t *ctx, crypto_data_t *mac, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[SHA1_DIGEST_LENGTH];
-	uint32_t digest_len = SHA1_DIGEST_LENGTH;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	if (PROV_SHA1_HMAC_CTX(ctx)->hc_mech_type ==
-	    SHA1_HMAC_GEN_MECH_INFO_TYPE)
-		digest_len = PROV_SHA1_HMAC_CTX(ctx)->hc_digest_len;
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((mac->cd_length == 0) || (mac->cd_length < digest_len)) {
-		mac->cd_length = digest_len;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do a SHA1 final on the inner context.
-	 */
-	SHA1Final(digest, &PROV_SHA1_HMAC_CTX(ctx)->hc_icontext);
-
-	/*
-	 * Do a SHA1 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	SHA1Update(&PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext, digest,
-	    SHA1_DIGEST_LENGTH);
-
-	/*
-	 * Do a SHA1 final on the outer context, storing the computing
-	 * digest in the users buffer.
-	 */
-	switch (mac->cd_format) {
-	case CRYPTO_DATA_RAW:
-		if (digest_len != SHA1_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA1Final(digest,
-			    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext);
-			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, digest_len);
-		} else {
-			SHA1Final((unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset,
-			    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext);
-		}
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_final_uio(
-		    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_final_mblk(
-		    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		mac->cd_length = digest_len;
-	} else {
-		mac->cd_length = 0;
-	}
-
-	bzero(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
-	kmem_free(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
-	ctx->cc_provider_private = NULL;
-
-	return (ret);
-}
-
-#define	SHA1_MAC_UPDATE(data, ctx, ret) {				\
-	switch (data->cd_format) {					\
-	case CRYPTO_DATA_RAW:						\
-		SHA1Update(&(ctx).hc_icontext,				\
-		    (uint8_t *)data->cd_raw.iov_base +			\
-		    data->cd_offset, data->cd_length);			\
-		break;							\
-	case CRYPTO_DATA_UIO:						\
-		ret = sha1_digest_update_uio(&(ctx).hc_icontext, data); \
-		break;							\
-	case CRYPTO_DATA_MBLK:						\
-		ret = sha1_digest_update_mblk(&(ctx).hc_icontext,	\
-		    data);						\
-		break;							\
-	default:							\
-		ret = CRYPTO_ARGUMENTS_BAD;				\
-	}								\
-}
-
-/* ARGSUSED */
-static int
-sha1_mac_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
-    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[SHA1_DIGEST_LENGTH];
-	sha1_hmac_ctx_t sha1_hmac_ctx;
-	uint32_t digest_len = SHA1_DIGEST_LENGTH;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if (mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE &&
-	    mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, &sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
-	} else {
-		/* no context template, initialize context */
-		if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_SHA1_DIGEST_KEY(&sha1_hmac_ctx.hc_icontext,
-			    key->ck_data, keylen_in_bytes, digest);
-			sha1_mac_init_ctx(&sha1_hmac_ctx, digest,
-			    SHA1_DIGEST_LENGTH);
-		} else {
-			sha1_mac_init_ctx(&sha1_hmac_ctx, key->ck_data,
-			    keylen_in_bytes);
-		}
-	}
-
-	/* get the mechanism parameters, if applicable */
-	if (mechanism->cm_type == SHA1_HMAC_GEN_MECH_INFO_TYPE) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t)) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-		PROV_SHA1_GET_DIGEST_LEN(mechanism, digest_len);
-		if (digest_len > SHA1_DIGEST_LENGTH) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-	}
-
-	/* do a SHA1 update of the inner context using the specified data */
-	SHA1_MAC_UPDATE(data, sha1_hmac_ctx, ret);
-	if (ret != CRYPTO_SUCCESS)
-		/* the update failed, free context and bail */
-		goto bail;
-
-	/*
-	 * Do a SHA1 final on the inner context.
-	 */
-	SHA1Final(digest, &sha1_hmac_ctx.hc_icontext);
-
-	/*
-	 * Do an SHA1 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	SHA1Update(&sha1_hmac_ctx.hc_ocontext, digest, SHA1_DIGEST_LENGTH);
-
-	/*
-	 * Do a SHA1 final on the outer context, storing the computed
-	 * digest in the users buffer.
-	 */
-	switch (mac->cd_format) {
-	case CRYPTO_DATA_RAW:
-		if (digest_len != SHA1_DIGEST_LENGTH) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA1Final(digest, &sha1_hmac_ctx.hc_ocontext);
-			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, digest_len);
-		} else {
-			SHA1Final((unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, &sha1_hmac_ctx.hc_ocontext);
-		}
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha1_digest_final_uio(&sha1_hmac_ctx.hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha1_digest_final_mblk(&sha1_hmac_ctx.hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		mac->cd_length = digest_len;
-	} else {
-		mac->cd_length = 0;
-	}
-	/* Extra paranoia: zeroize the context on the stack */
-	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
-
-	return (ret);
-bail:
-	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
-	mac->cd_length = 0;
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha1_mac_verify_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
-    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[SHA1_DIGEST_LENGTH];
-	sha1_hmac_ctx_t sha1_hmac_ctx;
-	uint32_t digest_len = SHA1_DIGEST_LENGTH;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if (mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE &&
-	    mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)
-		return (CRYPTO_MECHANISM_INVALID);
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, &sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
-	} else {
-		/* no context template, initialize context */
-		if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_SHA1_DIGEST_KEY(&sha1_hmac_ctx.hc_icontext,
-			    key->ck_data, keylen_in_bytes, digest);
-			sha1_mac_init_ctx(&sha1_hmac_ctx, digest,
-			    SHA1_DIGEST_LENGTH);
-		} else {
-			sha1_mac_init_ctx(&sha1_hmac_ctx, key->ck_data,
-			    keylen_in_bytes);
-		}
-	}
-
-	/* get the mechanism parameters, if applicable */
-	if (mechanism->cm_type == SHA1_HMAC_GEN_MECH_INFO_TYPE) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t)) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-		PROV_SHA1_GET_DIGEST_LEN(mechanism, digest_len);
-		if (digest_len > SHA1_DIGEST_LENGTH) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-	}
-
-	if (mac->cd_length != digest_len) {
-		ret = CRYPTO_INVALID_MAC;
-		goto bail;
-	}
-
-	/* do a SHA1 update of the inner context using the specified data */
-	SHA1_MAC_UPDATE(data, sha1_hmac_ctx, ret);
-	if (ret != CRYPTO_SUCCESS)
-		/* the update failed, free context and bail */
-		goto bail;
-
-	/* do a SHA1 final on the inner context */
-	SHA1Final(digest, &sha1_hmac_ctx.hc_icontext);
-
-	/*
-	 * Do an SHA1 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	SHA1Update(&sha1_hmac_ctx.hc_ocontext, digest, SHA1_DIGEST_LENGTH);
-
-	/*
-	 * Do a SHA1 final on the outer context, storing the computed
-	 * digest in the users buffer.
-	 */
-	SHA1Final(digest, &sha1_hmac_ctx.hc_ocontext);
-
-	/*
-	 * Compare the computed digest against the expected digest passed
-	 * as argument.
-	 */
-
-	switch (mac->cd_format) {
-
-	case CRYPTO_DATA_RAW:
-		if (bcmp(digest, (unsigned char *)mac->cd_raw.iov_base +
-		    mac->cd_offset, digest_len) != 0)
-			ret = CRYPTO_INVALID_MAC;
-		break;
-
-	case CRYPTO_DATA_UIO: {
-		off_t offset = mac->cd_offset;
-		uint_t vec_idx;
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		/* we support only kernel buffer */
-		if (mac->cd_uio->uio_segflg != UIO_SYSSPACE)
-			return (CRYPTO_ARGUMENTS_BAD);
-
-		/* jump to the first iovec containing the expected digest */
-		for (vec_idx = 0;
-		    offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
-		    vec_idx < mac->cd_uio->uio_iovcnt;
-		    offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len);
-		if (vec_idx == mac->cd_uio->uio_iovcnt) {
-			/*
-			 * The caller specified an offset that is
-			 * larger than the total size of the buffers
-			 * it provided.
-			 */
-			ret = CRYPTO_DATA_LEN_RANGE;
-			break;
-		}
-
-		/* do the comparison of computed digest vs specified one */
-		while (vec_idx < mac->cd_uio->uio_iovcnt && length > 0) {
-			cur_len = MIN(mac->cd_uio->uio_iov[vec_idx].iov_len -
-			    offset, length);
-
-			if (bcmp(digest + scratch_offset,
-			    mac->cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    cur_len) != 0) {
-				ret = CRYPTO_INVALID_MAC;
-				break;
-			}
-
-			length -= cur_len;
-			vec_idx++;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-		break;
-	}
-
-	case CRYPTO_DATA_MBLK: {
-		off_t offset = mac->cd_offset;
-		mblk_t *mp;
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		/* jump to the first mblk_t containing the expected digest */
-		for (mp = mac->cd_mp; mp != NULL && offset >= MBLKL(mp);
-		    offset -= MBLKL(mp), mp = mp->b_cont);
-		if (mp == NULL) {
-			/*
-			 * The caller specified an offset that is larger than
-			 * the total size of the buffers it provided.
-			 */
-			ret = CRYPTO_DATA_LEN_RANGE;
-			break;
-		}
-
-		while (mp != NULL && length > 0) {
-			cur_len = MIN(MBLKL(mp) - offset, length);
-			if (bcmp(digest + scratch_offset,
-			    mp->b_rptr + offset, cur_len) != 0) {
-				ret = CRYPTO_INVALID_MAC;
-				break;
-			}
-
-			length -= cur_len;
-			mp = mp->b_cont;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-		break;
-	}
-
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
-	return (ret);
-bail:
-	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
-	mac->cd_length = 0;
-	return (ret);
-}
-
-/*
- * KCF software provider context management entry points.
- */
-
-/* ARGSUSED */
-static int
-sha1_create_ctx_template(crypto_provider_handle_t provider,
-    crypto_mechanism_t *mechanism, crypto_key_t *key,
-    crypto_spi_ctx_template_t *ctx_template, size_t *ctx_template_size,
-    crypto_req_handle_t req)
-{
-	sha1_hmac_ctx_t *sha1_hmac_ctx_tmpl;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	if ((mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE) &&
-	    (mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)) {
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Allocate and initialize SHA1 context.
-	 */
-	sha1_hmac_ctx_tmpl = kmem_alloc(sizeof (sha1_hmac_ctx_t),
-	    crypto_kmflag(req));
-	if (sha1_hmac_ctx_tmpl == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
-		uchar_t digested_key[SHA1_DIGEST_LENGTH];
-
-		/*
-		 * Hash the passed-in key to get a smaller key.
-		 * The inner context is used since it hasn't been
-		 * initialized yet.
-		 */
-		PROV_SHA1_DIGEST_KEY(&sha1_hmac_ctx_tmpl->hc_icontext,
-		    key->ck_data, keylen_in_bytes, digested_key);
-		sha1_mac_init_ctx(sha1_hmac_ctx_tmpl, digested_key,
-		    SHA1_DIGEST_LENGTH);
-	} else {
-		sha1_mac_init_ctx(sha1_hmac_ctx_tmpl, key->ck_data,
-		    keylen_in_bytes);
-	}
-
-	sha1_hmac_ctx_tmpl->hc_mech_type = mechanism->cm_type;
-	*ctx_template = (crypto_spi_ctx_template_t)sha1_hmac_ctx_tmpl;
-	*ctx_template_size = sizeof (sha1_hmac_ctx_t);
-
-
-	return (CRYPTO_SUCCESS);
-}
-
-static int
-sha1_free_context(crypto_ctx_t *ctx)
-{
-	uint_t ctx_len;
-	sha1_mech_type_t mech_type;
-
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_SUCCESS);
-
-	/*
-	 * We have to free either SHA1 or SHA1-HMAC contexts, which
-	 * have different lengths.
-	 */
-
-	mech_type = PROV_SHA1_CTX(ctx)->sc_mech_type;
-	if (mech_type == SHA1_MECH_INFO_TYPE)
-		ctx_len = sizeof (sha1_ctx_t);
-	else {
-		ASSERT(mech_type == SHA1_HMAC_MECH_INFO_TYPE ||
-		    mech_type == SHA1_HMAC_GEN_MECH_INFO_TYPE);
-		ctx_len = sizeof (sha1_hmac_ctx_t);
-	}
-
-	bzero(ctx->cc_provider_private, ctx_len);
-	kmem_free(ctx->cc_provider_private, ctx_len);
-	ctx->cc_provider_private = NULL;
-
-	return (CRYPTO_SUCCESS);
-}
-
-#endif /* _KERNEL */
--- a/usr/src/common/crypto/sha2/sha2.c	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/common/crypto/sha2/sha2.c	Tue Mar 28 08:45:30 2006 -0800
@@ -39,34 +39,30 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/sysmacros.h>
+#define	_SHA2_IMPL
 #include <sys/sha2.h>
 #include <sys/sha2_consts.h>
 
-#ifdef _KERNEL
-
-#include <sys/modctl.h>
-#include <sys/cmn_err.h>
-#include <sys/crypto/common.h>
-#include <sys/crypto/spi.h>
-#include <sys/strsun.h>
-
-/*
- * The sha2 module is created with two modlinkages:
- * - a modlmisc that allows consumers to directly call the entry points
- *   SHA2Init, SHA2Update, and SHA2Final.
- * - a modlcrypto that allows the module to register with the Kernel
- *   Cryptographic Framework (KCF) as a software provider for the SHA2
- *   mechanisms.
- */
-
-#else
+#ifndef _KERNEL
 
 #include <strings.h>
 #include <stdlib.h>
 #include <errno.h>
 
+#pragma weak SHA256Update = SHA2Update
+#pragma weak SHA384Update = SHA2Update
+#pragma weak SHA512Update = SHA2Update
+
+#pragma weak SHA256Final = SHA2Final
+#pragma weak SHA384Final = SHA2Final
+#pragma weak SHA512Final = SHA2Final
+
 #endif	/* !_KERNEL */
 
+#ifdef _KERNEL
+#include <sys/cmn_err.h>
+#endif /* _KERNEL */
+
 static void Encode(uint8_t *, uint32_t *, size_t);
 static void Encode64(uint8_t *, uint64_t *, size_t);
 static void SHA256Transform(SHA2_CTX *, const uint8_t *);
@@ -108,264 +104,6 @@
 	T2 = BIGSIGMA0(a) + Maj(a, b, c);				\
 	h = T1 + T2
 
-#ifdef _KERNEL
-
-static struct modlmisc modlmisc = {
-	&mod_miscops,
-	"SHA2 Message-Digest Algorithm"
-};
-
-static struct modlcrypto modlcrypto = {
-	&mod_cryptoops,
-	"SHA2 Kernel SW Provider %I%"
-};
-
-static struct modlinkage modlinkage = {
-	MODREV_1, &modlmisc, &modlcrypto, NULL
-};
-
-/*
- * CSPI information (entry points, provider info, etc.)
- */
-
-#endif /* _KERNEL */
-
-/*
- * List of support mechanisms in this module.
- *
- * It is important to note that in the module, division or modulus calculations
- * are used on the enumerated type to determine which mechanism is being used;
- * therefore, changing the order or additional mechanisms should be done
- * carefully
- */
-typedef enum sha2_mech_type {
-	SHA256_MECH_INFO_TYPE,		/* SUN_CKM_SHA256 */
-	SHA256_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA256_HMAC */
-	SHA256_HMAC_GEN_MECH_INFO_TYPE,	/* SUN_CKM_SHA256_HMAC_GENERAL */
-	SHA384_MECH_INFO_TYPE,		/* SUN_CKM_SHA384 */
-	SHA384_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA384_HMAC */
-	SHA384_HMAC_GEN_MECH_INFO_TYPE,	/* SUN_CKM_SHA384_HMAC_GENERAL */
-	SHA512_MECH_INFO_TYPE,		/* SUN_CKM_SHA512 */
-	SHA512_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA512_HMAC */
-	SHA512_HMAC_GEN_MECH_INFO_TYPE	/* SUN_CKM_SHA512_HMAC_GENERAL */
-} sha2_mech_type_t;
-
-#ifdef _KERNEL
-
-
-/*
- * Context for SHA2 mechanism.
- */
-typedef struct sha2_ctx {
-	sha2_mech_type_t	sc_mech_type;	/* type of context */
-	SHA2_CTX		sc_sha2_ctx;	/* SHA2 context */
-} sha2_ctx_t;
-
-/*
- * Context for SHA2 HMAC and HMAC GENERAL mechanisms.
- */
-typedef struct sha2_hmac_ctx {
-	sha2_mech_type_t	hc_mech_type;	/* type of context */
-	uint32_t		hc_digest_len;	/* digest len in bytes */
-	SHA2_CTX		hc_icontext;	/* inner SHA2 context */
-	SHA2_CTX		hc_ocontext;	/* outer SHA2 context */
-} sha2_hmac_ctx_t;
-
-/*
- * Macros to access the SHA2 or SHA2-HMAC contexts from a context passed
- * by KCF to one of the entry points.
- */
-
-#define	PROV_SHA2_CTX(ctx)	((sha2_ctx_t *)(ctx)->cc_provider_private)
-#define	PROV_SHA2_HMAC_CTX(ctx)	((sha2_hmac_ctx_t *)(ctx)->cc_provider_private)
-
-/* to extract the digest length passed as mechanism parameter */
-#define	PROV_SHA2_GET_DIGEST_LEN(m, len) {				\
-	if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))		\
-		(len) = (uint32_t)*((ulong_t *)(m)->cm_param);	\
-	else {								\
-		ulong_t tmp_ulong;					\
-		bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));	\
-		(len) = (uint32_t)tmp_ulong;				\
-	}								\
-}
-
-#define	PROV_SHA2_DIGEST_KEY(mech, ctx, key, len, digest) {	\
-	SHA2Init(mech, ctx);				\
-	SHA2Update(ctx, key, len);			\
-	SHA2Final(digest, ctx);				\
-}
-
-/*
- * Mechanism info structure passed to KCF during registration.
- */
-static crypto_mech_info_t sha2_mech_info_tab[] = {
-	/* SHA256 */
-	{SUN_CKM_SHA256, SHA256_MECH_INFO_TYPE,
-	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
-	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA256-HMAC */
-	{SUN_CKM_SHA256_HMAC, SHA256_HMAC_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA256-HMAC GENERAL */
-	{SUN_CKM_SHA256_HMAC_GENERAL, SHA256_HMAC_GEN_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA384 */
-	{SUN_CKM_SHA384, SHA384_MECH_INFO_TYPE,
-	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
-	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA384-HMAC */
-	{SUN_CKM_SHA384_HMAC, SHA384_HMAC_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA384-HMAC GENERAL */
-	{SUN_CKM_SHA384_HMAC_GENERAL, SHA384_HMAC_GEN_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA512 */
-	{SUN_CKM_SHA512, SHA512_MECH_INFO_TYPE,
-	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
-	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA512-HMAC */
-	{SUN_CKM_SHA512_HMAC, SHA512_HMAC_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
-	/* SHA512-HMAC GENERAL */
-	{SUN_CKM_SHA512_HMAC_GENERAL, SHA512_HMAC_GEN_MECH_INFO_TYPE,
-	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
-	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
-	    CRYPTO_KEYSIZE_UNIT_IN_BITS}
-};
-
-void SHA2Init(uint64_t, SHA2_CTX *);
-void SHA2Update(SHA2_CTX *, const uint8_t *, uint32_t);
-void SHA2Final(uint8_t *, SHA2_CTX *);
-
-static void sha2_provider_status(crypto_provider_handle_t, uint_t *);
-
-static crypto_control_ops_t sha2_control_ops = {
-	sha2_provider_status
-};
-
-static int sha2_digest_init(crypto_ctx_t *, crypto_mechanism_t *,
-    crypto_req_handle_t);
-static int sha2_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha2_digest_update(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha2_digest_final(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha2_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
-    crypto_req_handle_t);
-
-static crypto_digest_ops_t sha2_digest_ops = {
-	sha2_digest_init,
-	sha2_digest,
-	sha2_digest_update,
-	NULL,
-	sha2_digest_final,
-	sha2_digest_atomic
-};
-
-static int sha2_mac_init(crypto_ctx_t *, crypto_mechanism_t *, crypto_key_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-static int sha2_mac_update(crypto_ctx_t *, crypto_data_t *,
-    crypto_req_handle_t);
-static int sha2_mac_final(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
-static int sha2_mac_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-static int sha2_mac_verify_atomic(crypto_provider_handle_t, crypto_session_id_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
-    crypto_spi_ctx_template_t, crypto_req_handle_t);
-
-static crypto_mac_ops_t sha2_mac_ops = {
-	sha2_mac_init,
-	NULL,
-	sha2_mac_update,
-	sha2_mac_final,
-	sha2_mac_atomic,
-	sha2_mac_verify_atomic
-};
-
-static int sha2_create_ctx_template(crypto_provider_handle_t,
-    crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
-    size_t *, crypto_req_handle_t);
-static int sha2_free_context(crypto_ctx_t *);
-
-static crypto_ctx_ops_t sha2_ctx_ops = {
-	sha2_create_ctx_template,
-	sha2_free_context
-};
-
-static crypto_ops_t sha2_crypto_ops = {
-	&sha2_control_ops,
-	&sha2_digest_ops,
-	NULL,
-	&sha2_mac_ops,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	&sha2_ctx_ops
-};
-
-static crypto_provider_info_t sha2_prov_info = {
-	CRYPTO_SPI_VERSION_1,
-	"SHA2 Software Provider",
-	CRYPTO_SW_PROVIDER,
-	{&modlinkage},
-	NULL,
-	&sha2_crypto_ops,
-	sizeof (sha2_mech_info_tab)/sizeof (crypto_mech_info_t),
-	sha2_mech_info_tab
-};
-
-static crypto_kcf_provider_handle_t sha2_prov_handle = NULL;
-
-int
-_init()
-{
-	int ret;
-
-	if ((ret = mod_install(&modlinkage)) != 0)
-		return (ret);
-
-	/*
-	 * Register with KCF. If the registration fails, log an
-	 * error but do not uninstall the module, since the functionality
-	 * provided by misc/sha2 should still be available.
-	 */
-	if ((ret = crypto_register_provider(&sha2_prov_info,
-	    &sha2_prov_handle)) != CRYPTO_SUCCESS)
-		cmn_err(CE_WARN, "sha2 _init: "
-		    "crypto_register_provider() failed (0x%x)", ret);
-
-	return (0);
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (mod_info(&modlinkage, modinfop));
-}
-
-#endif /* _KERNEL */
-
-
 /*
  * sparc optimization:
  *
@@ -452,93 +190,55 @@
 		blk = (uint8_t *)ctx->buf_un.buf32;
 	}
 
-#if	defined(__sparc)
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w0 =  LOAD_BIG_32(blk + 4 * 0);
 	SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w1 =  LOAD_BIG_32(blk + 4 * 1);
 	SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w2 =  LOAD_BIG_32(blk + 4 * 2);
 	SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w3 =  LOAD_BIG_32(blk + 4 * 3);
 	SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w4 =  LOAD_BIG_32(blk + 4 * 4);
 	SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w5 =  LOAD_BIG_32(blk + 4 * 5);
 	SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w6 =  LOAD_BIG_32(blk + 4 * 6);
 	SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w7 =  LOAD_BIG_32(blk + 4 * 7);
 	SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w8 =  LOAD_BIG_32(blk + 4 * 8);
 	SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w9 =  LOAD_BIG_32(blk + 4 * 9);
 	SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w10 =  LOAD_BIG_32(blk + 4 * 10);
 	SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w11 =  LOAD_BIG_32(blk + 4 * 11);
 	SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w12 =  LOAD_BIG_32(blk + 4 * 12);
 	SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w13 =  LOAD_BIG_32(blk + 4 * 13);
 	SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w14 =  LOAD_BIG_32(blk + 4 * 14);
 	SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w15 =  LOAD_BIG_32(blk + 4 * 15);
 	SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);
 
-#else
-
-	w0 =  LOAD_BIG_32(blk + 4 * 0);
-	SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);
-	w1 =  LOAD_BIG_32(blk + 4 * 1);
-	SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);
-	w2 =  LOAD_BIG_32(blk + 4 * 2);
-	SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);
-	w3 =  LOAD_BIG_32(blk + 4 * 3);
-	SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);
-	w4 =  LOAD_BIG_32(blk + 4 * 4);
-	SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);
-	w5 =  LOAD_BIG_32(blk + 4 * 5);
-	SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);
-	w6 =  LOAD_BIG_32(blk + 4 * 6);
-	SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);
-	w7 =  LOAD_BIG_32(blk + 4 * 7);
-	SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);
-	w8 =  LOAD_BIG_32(blk + 4 * 8);
-	SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);
-	w9 =  LOAD_BIG_32(blk + 4 * 9);
-	SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);
-	w10 =  LOAD_BIG_32(blk + 4 * 10);
-	SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);
-	w11 =  LOAD_BIG_32(blk + 4 * 11);
-	SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);
-	w12 =  LOAD_BIG_32(blk + 4 * 12);
-	SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);
-	w13 =  LOAD_BIG_32(blk + 4 * 13);
-	SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);
-	w14 =  LOAD_BIG_32(blk + 4 * 14);
-	SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);
-	w15 =  LOAD_BIG_32(blk + 4 * 15);
-	SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);
-
-#endif
-
 	w0 = SIGMA1_256(w14) + w9 + SIGMA0_256(w1) + w0;
 	SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);
 	w1 = SIGMA1_256(w15) + w10 + SIGMA0_256(w2) + w1;
@@ -706,93 +406,55 @@
 		blk = (uint8_t *)ctx->buf_un.buf64;
 	}
 
-#if	defined(__sparc)
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w0 =  LOAD_BIG_64(blk + 8 * 0);
 	SHA512ROUND(a, b, c, d, e, f, g, h, 0, w0);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w1 =  LOAD_BIG_64(blk + 8 * 1);
 	SHA512ROUND(h, a, b, c, d, e, f, g, 1, w1);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w2 =  LOAD_BIG_64(blk + 8 * 2);
 	SHA512ROUND(g, h, a, b, c, d, e, f, 2, w2);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w3 =  LOAD_BIG_64(blk + 8 * 3);
 	SHA512ROUND(f, g, h, a, b, c, d, e, 3, w3);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w4 =  LOAD_BIG_64(blk + 8 * 4);
 	SHA512ROUND(e, f, g, h, a, b, c, d, 4, w4);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w5 =  LOAD_BIG_64(blk + 8 * 5);
 	SHA512ROUND(d, e, f, g, h, a, b, c, 5, w5);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w6 =  LOAD_BIG_64(blk + 8 * 6);
 	SHA512ROUND(c, d, e, f, g, h, a, b, 6, w6);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w7 =  LOAD_BIG_64(blk + 8 * 7);
 	SHA512ROUND(b, c, d, e, f, g, h, a, 7, w7);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w8 =  LOAD_BIG_64(blk + 8 * 8);
 	SHA512ROUND(a, b, c, d, e, f, g, h, 8, w8);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w9 =  LOAD_BIG_64(blk + 8 * 9);
 	SHA512ROUND(h, a, b, c, d, e, f, g, 9, w9);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w10 =  LOAD_BIG_64(blk + 8 * 10);
 	SHA512ROUND(g, h, a, b, c, d, e, f, 10, w10);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w11 =  LOAD_BIG_64(blk + 8 * 11);
 	SHA512ROUND(f, g, h, a, b, c, d, e, 11, w11);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w12 =  LOAD_BIG_64(blk + 8 * 12);
 	SHA512ROUND(e, f, g, h, a, b, c, d, 12, w12);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w13 =  LOAD_BIG_64(blk + 8 * 13);
 	SHA512ROUND(d, e, f, g, h, a, b, c, 13, w13);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w14 =  LOAD_BIG_64(blk + 8 * 14);
 	SHA512ROUND(c, d, e, f, g, h, a, b, 14, w14);
-	/*LINTED*/
+	/* LINTED E_BAD_PTR_CAST_ALIGN */
 	w15 =  LOAD_BIG_64(blk + 8 * 15);
 	SHA512ROUND(b, c, d, e, f, g, h, a, 15, w15);
 
-#else
-
-	w0 =  LOAD_BIG_64(blk + 8 * 0);
-	SHA512ROUND(a, b, c, d, e, f, g, h, 0, w0);
-	w1 =  LOAD_BIG_64(blk + 8 * 1);
-	SHA512ROUND(h, a, b, c, d, e, f, g, 1, w1);
-	w2 =  LOAD_BIG_64(blk + 8 * 2);
-	SHA512ROUND(g, h, a, b, c, d, e, f, 2, w2);
-	w3 =  LOAD_BIG_64(blk + 8 * 3);
-	SHA512ROUND(f, g, h, a, b, c, d, e, 3, w3);
-	w4 =  LOAD_BIG_64(blk + 8 * 4);
-	SHA512ROUND(e, f, g, h, a, b, c, d, 4, w4);
-	w5 =  LOAD_BIG_64(blk + 8 * 5);
-	SHA512ROUND(d, e, f, g, h, a, b, c, 5, w5);
-	w6 =  LOAD_BIG_64(blk + 8 * 6);
-	SHA512ROUND(c, d, e, f, g, h, a, b, 6, w6);
-	w7 =  LOAD_BIG_64(blk + 8 * 7);
-	SHA512ROUND(b, c, d, e, f, g, h, a, 7, w7);
-	w8 =  LOAD_BIG_64(blk + 8 * 8);
-	SHA512ROUND(a, b, c, d, e, f, g, h, 8, w8);
-	w9 =  LOAD_BIG_64(blk + 8 * 9);
-	SHA512ROUND(h, a, b, c, d, e, f, g, 9, w9);
-	w10 =  LOAD_BIG_64(blk + 8 * 10);
-	SHA512ROUND(g, h, a, b, c, d, e, f, 10, w10);
-	w11 =  LOAD_BIG_64(blk + 8 * 11);
-	SHA512ROUND(f, g, h, a, b, c, d, e, 11, w11);
-	w12 =  LOAD_BIG_64(blk + 8 * 12);
-	SHA512ROUND(e, f, g, h, a, b, c, d, 12, w12);
-	w13 =  LOAD_BIG_64(blk + 8 * 13);
-	SHA512ROUND(d, e, f, g, h, a, b, c, 13, w13);
-	w14 =  LOAD_BIG_64(blk + 8 * 14);
-	SHA512ROUND(c, d, e, f, g, h, a, b, 14, w14);
-	w15 =  LOAD_BIG_64(blk + 8 * 15);
-	SHA512ROUND(b, c, d, e, f, g, h, a, 15, w15);
-
-#endif
-
 	w0 = SIGMA1(w14) + w9 + SIGMA0(w1) + w0;
 	SHA512ROUND(a, b, c, d, e, f, g, h, 16, w0);
 	w1 = SIGMA1(w15) + w10 + SIGMA0(w2) + w1;
@@ -938,21 +600,6 @@
 
 
 /*
- * devpro compiler optimization:
- *
- * the compiler can generate better code if it knows that `input' and
- * `output' do not point to the same source.  there is no portable
- * way to tell the compiler this, but the sun compiler recognizes the
- * `_Restrict' keyword to indicate this condition.  use it if possible.
- */
-
-#ifdef	__RESTRICT
-#define	restrict	_Restrict
-#else
-#define	restrict	/* nothing */
-#endif
-
-/*
  * Encode()
  *
  * purpose: to convert a list of numbers from little endian to big endian
@@ -963,7 +610,8 @@
  */
 
 static void
-Encode(uint8_t *restrict output, uint32_t *restrict input, size_t len)
+Encode(uint8_t *_RESTRICT_KYWD output, uint32_t *_RESTRICT_KYWD input,
+    size_t len)
 {
 	size_t		i, j;
 
@@ -987,7 +635,8 @@
 }
 
 static void
-Encode64(uint8_t *restrict output, uint64_t *restrict input, size_t len)
+Encode64(uint8_t *_RESTRICT_KYWD output, uint64_t *_RESTRICT_KYWD input,
+    size_t len)
 {
 	size_t		i, j;
 
@@ -1016,1358 +665,6 @@
 }
 
 
-#ifdef _KERNEL
-
-/*
- * KCF software provider control entry points.
- */
-/* ARGSUSED */
-static void
-sha2_provider_status(crypto_provider_handle_t provider, uint_t *status)
-{
-	*status = CRYPTO_PROVIDER_READY;
-}
-
-/*
- * KCF software provider digest entry points.
- */
-
-static int
-sha2_digest_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
-    crypto_req_handle_t req)
-{
-
-	/*
-	 * Allocate and initialize SHA2 context.
-	 */
-	ctx->cc_provider_private = kmem_alloc(sizeof (sha2_ctx_t),
-	    crypto_kmflag(req));
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	PROV_SHA2_CTX(ctx)->sc_mech_type = mechanism->cm_type;
-	SHA2Init(mechanism->cm_type, &PROV_SHA2_CTX(ctx)->sc_sha2_ctx);
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA2 digest update function for uio data.
- */
-static int
-sha2_digest_update_uio(SHA2_CTX *sha2_ctx, crypto_data_t *data)
-{
-	off_t offset = data->cd_offset;
-	size_t length = data->cd_length;
-	uint_t vec_idx;
-	size_t cur_len;
-
-	/* we support only kernel buffer */
-	if (data->cd_uio->uio_segflg != UIO_SYSSPACE)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Jump to the first iovec containing data to be
-	 * digested.
-	 */
-	for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
-	    offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
-	    offset -= data->cd_uio->uio_iov[vec_idx++].iov_len);
-	if (vec_idx == data->cd_uio->uio_iovcnt) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	/*
-	 * Now do the digesting on the iovecs.
-	 */
-	while (vec_idx < data->cd_uio->uio_iovcnt && length > 0) {
-		cur_len = MIN(data->cd_uio->uio_iov[vec_idx].iov_len -
-		    offset, length);
-
-		SHA2Update(sha2_ctx, (uint8_t *)data->cd_uio->
-		    uio_iov[vec_idx].iov_base + offset, cur_len);
-		length -= cur_len;
-		vec_idx++;
-		offset = 0;
-	}
-
-	if (vec_idx == data->cd_uio->uio_iovcnt && length > 0) {
-		/*
-		 * The end of the specified iovec's was reached but
-		 * the length requested could not be processed, i.e.
-		 * The caller requested to digest more data than it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA2 digest final function for uio data.
- * digest_len is the length of the desired digest. If digest_len
- * is smaller than the default SHA2 digest length, the caller
- * must pass a scratch buffer, digest_scratch, which must
- * be at least the algorithm's digest length bytes.
- */
-static int
-sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
-    ulong_t digest_len, uchar_t *digest_scratch)
-{
-	off_t offset = digest->cd_offset;
-	uint_t vec_idx;
-
-	/* we support only kernel buffer */
-	if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Jump to the first iovec containing ptr to the digest to
-	 * be returned.
-	 */
-	for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
-	    vec_idx < digest->cd_uio->uio_iovcnt;
-	    offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len);
-	if (vec_idx == digest->cd_uio->uio_iovcnt) {
-		/*
-		 * The caller specified an offset that is
-		 * larger than the total size of the buffers
-		 * it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	if (offset + digest_len <=
-	    digest->cd_uio->uio_iov[vec_idx].iov_len) {
-		/*
-		 * The computed SHA2 digest will fit in the current
-		 * iovec.
-		 */
-		if (((sha2_ctx->algotype <= SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
-		    (digest_len != SHA256_DIGEST_LENGTH)) ||
-		    ((sha2_ctx->algotype > SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
-			(digest_len != SHA512_DIGEST_LENGTH))) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA2Final(digest_scratch, sha2_ctx);
-
-			bcopy(digest_scratch, (uchar_t *)digest->
-			    cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    digest_len);
-		} else {
-			SHA2Final((uchar_t *)digest->
-			    cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    sha2_ctx);
-
-		}
-	} else {
-		/*
-		 * The computed digest will be crossing one or more iovec's.
-		 * This is bad performance-wise but we need to support it.
-		 * Allocate a small scratch buffer on the stack and
-		 * copy it piece meal to the specified digest iovec's.
-		 */
-		uchar_t digest_tmp[SHA512_DIGEST_LENGTH];
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		SHA2Final(digest_tmp, sha2_ctx);
-
-		while (vec_idx < digest->cd_uio->uio_iovcnt && length > 0) {
-			cur_len =
-			    MIN(digest->cd_uio->uio_iov[vec_idx].iov_len -
-				    offset, length);
-			bcopy(digest_tmp + scratch_offset,
-			    digest->cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    cur_len);
-
-			length -= cur_len;
-			vec_idx++;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-
-		if (vec_idx == digest->cd_uio->uio_iovcnt && length > 0) {
-			/*
-			 * The end of the specified iovec's was reached but
-			 * the length requested could not be processed, i.e.
-			 * The caller requested to digest more data than it
-			 * provided.
-			 */
-			return (CRYPTO_DATA_LEN_RANGE);
-		}
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA2 digest update for mblk's.
- */
-static int
-sha2_digest_update_mblk(SHA2_CTX *sha2_ctx, crypto_data_t *data)
-{
-	off_t offset = data->cd_offset;
-	size_t length = data->cd_length;
-	mblk_t *mp;
-	size_t cur_len;
-
-	/*
-	 * Jump to the first mblk_t containing data to be digested.
-	 */
-	for (mp = data->cd_mp; mp != NULL && offset >= MBLKL(mp);
-	    offset -= MBLKL(mp), mp = mp->b_cont);
-	if (mp == NULL) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	/*
-	 * Now do the digesting on the mblk chain.
-	 */
-	while (mp != NULL && length > 0) {
-		cur_len = MIN(MBLKL(mp) - offset, length);
-		SHA2Update(sha2_ctx, mp->b_rptr + offset, cur_len);
-		length -= cur_len;
-		offset = 0;
-		mp = mp->b_cont;
-	}
-
-	if (mp == NULL && length > 0) {
-		/*
-		 * The end of the mblk was reached but the length requested
-		 * could not be processed, i.e. The caller requested
-		 * to digest more data than it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/*
- * Helper SHA2 digest final for mblk's.
- * digest_len is the length of the desired digest. If digest_len
- * is smaller than the default SHA2 digest length, the caller
- * must pass a scratch buffer, digest_scratch, which must
- * be at least the algorithm's digest length bytes.
- */
-static int
-sha2_digest_final_mblk(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
-    ulong_t digest_len, uchar_t *digest_scratch)
-{
-	off_t offset = digest->cd_offset;
-	mblk_t *mp;
-
-	/*
-	 * Jump to the first mblk_t that will be used to store the digest.
-	 */
-	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
-	    offset -= MBLKL(mp), mp = mp->b_cont);
-	if (mp == NULL) {
-		/*
-		 * The caller specified an offset that is larger than the
-		 * total size of the buffers it provided.
-		 */
-		return (CRYPTO_DATA_LEN_RANGE);
-	}
-
-	if (offset + digest_len <= MBLKL(mp)) {
-		/*
-		 * The computed SHA2 digest will fit in the current mblk.
-		 * Do the SHA2Final() in-place.
-		 */
-		if (((sha2_ctx->algotype <= SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
-		    (digest_len != SHA256_DIGEST_LENGTH)) ||
-		    ((sha2_ctx->algotype > SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
-			(digest_len != SHA512_DIGEST_LENGTH))) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA2Final(digest_scratch, sha2_ctx);
-			bcopy(digest_scratch, mp->b_rptr + offset, digest_len);
-		} else {
-			SHA2Final(mp->b_rptr + offset, sha2_ctx);
-		}
-	} else {
-		/*
-		 * The computed digest will be crossing one or more mblk's.
-		 * This is bad performance-wise but we need to support it.
-		 * Allocate a small scratch buffer on the stack and
-		 * copy it piece meal to the specified digest iovec's.
-		 */
-		uchar_t digest_tmp[SHA512_DIGEST_LENGTH];
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		SHA2Final(digest_tmp, sha2_ctx);
-
-		while (mp != NULL && length > 0) {
-			cur_len = MIN(MBLKL(mp) - offset, length);
-			bcopy(digest_tmp + scratch_offset,
-			    mp->b_rptr + offset, cur_len);
-
-			length -= cur_len;
-			mp = mp->b_cont;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-
-		if (mp == NULL && length > 0) {
-			/*
-			 * The end of the specified mblk was reached but
-			 * the length requested could not be processed, i.e.
-			 * The caller requested to digest more data than it
-			 * provided.
-			 */
-			return (CRYPTO_DATA_LEN_RANGE);
-		}
-	}
-
-	return (CRYPTO_SUCCESS);
-}
-
-/* ARGSUSED */
-static int
-sha2_digest(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uint_t sha_digest_len;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	switch (PROV_SHA2_CTX(ctx)->sc_mech_type) {
-	case SHA256_MECH_INFO_TYPE:
-		sha_digest_len = SHA256_DIGEST_LENGTH;
-		break;
-	case SHA384_MECH_INFO_TYPE:
-		sha_digest_len = SHA384_DIGEST_LENGTH;
-		break;
-	case SHA512_MECH_INFO_TYPE:
-		sha_digest_len = SHA512_DIGEST_LENGTH;
-		break;
-	default:
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((digest->cd_length == 0) ||
-	    (digest->cd_length < sha_digest_len)) {
-		digest->cd_length = sha_digest_len;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do the SHA2 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Update(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_update_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_update_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		/* the update failed, free context and bail */
-		kmem_free(ctx->cc_provider_private, sizeof (sha2_ctx_t));
-		ctx->cc_provider_private = NULL;
-		digest->cd_length = 0;
-		return (ret);
-	}
-
-	/*
-	 * Do a SHA2 final, must be done separately since the digest
-	 * type can be different than the input data type.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &PROV_SHA2_CTX(ctx)->sc_sha2_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_final_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    digest, sha_digest_len, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_final_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    digest, sha_digest_len, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/* all done, free context and return */
-
-	if (ret == CRYPTO_SUCCESS)
-		digest->cd_length = sha_digest_len;
-	else
-		digest->cd_length = 0;
-
-	kmem_free(ctx->cc_provider_private, sizeof (sha2_ctx_t));
-	ctx->cc_provider_private = NULL;
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha2_digest_update(crypto_ctx_t *ctx, crypto_data_t *data,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * Do the SHA2 update on the specified input data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Update(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_update_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_update_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha2_digest_final(crypto_ctx_t *ctx, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uint_t sha_digest_len;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	switch (PROV_SHA2_CTX(ctx)->sc_mech_type) {
-	case SHA256_MECH_INFO_TYPE:
-		sha_digest_len = SHA256_DIGEST_LENGTH;
-		break;
-	case SHA384_MECH_INFO_TYPE:
-		sha_digest_len = SHA384_DIGEST_LENGTH;
-		break;
-	case SHA512_MECH_INFO_TYPE:
-		sha_digest_len = SHA512_DIGEST_LENGTH;
-		break;
-	default:
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((digest->cd_length == 0) ||
-	    (digest->cd_length < sha_digest_len)) {
-		digest->cd_length = sha_digest_len;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do a SHA2 final.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &PROV_SHA2_CTX(ctx)->sc_sha2_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_final_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    digest, sha_digest_len, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_final_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
-		    digest, sha_digest_len, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/* all done, free context and return */
-
-	if (ret == CRYPTO_SUCCESS)
-		digest->cd_length = sha_digest_len;
-	else
-		digest->cd_length = 0;
-
-	kmem_free(ctx->cc_provider_private, sizeof (sha2_ctx_t));
-	ctx->cc_provider_private = NULL;
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha2_digest_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_data_t *data, crypto_data_t *digest,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	SHA2_CTX sha2_ctx;
-	uint32_t sha_digest_len;
-
-	/*
-	 * Do the SHA inits.
-	 */
-
-	SHA2Init(mechanism->cm_type, &sha2_ctx);
-
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Update(&sha2_ctx, (uint8_t *)data->
-		    cd_raw.iov_base + data->cd_offset, data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_update_uio(&sha2_ctx, data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_update_mblk(&sha2_ctx, data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	/*
-	 * Do the SHA updates on the specified input data.
-	 */
-
-	if (ret != CRYPTO_SUCCESS) {
-		/* the update failed, bail */
-		digest->cd_length = 0;
-		return (ret);
-	}
-
-	if (mechanism->cm_type <= SHA256_HMAC_GEN_MECH_INFO_TYPE)
-		sha_digest_len = SHA256_DIGEST_LENGTH;
-	else
-		sha_digest_len = SHA512_DIGEST_LENGTH;
-
-	/*
-	 * Do a SHA2 final, must be done separately since the digest
-	 * type can be different than the input data type.
-	 */
-	switch (digest->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Final((unsigned char *)digest->cd_raw.iov_base +
-		    digest->cd_offset, &sha2_ctx);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_final_uio(&sha2_ctx, digest,
-		    sha_digest_len, NULL);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_final_mblk(&sha2_ctx, digest,
-		    sha_digest_len, NULL);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS)
-		digest->cd_length = sha_digest_len;
-	else
-		digest->cd_length = 0;
-
-	return (ret);
-}
-
-/*
- * KCF software provider mac entry points.
- *
- * SHA2 HMAC is: SHA2(key XOR opad, SHA2(key XOR ipad, text))
- *
- * Init:
- * The initialization routine initializes what we denote
- * as the inner and outer contexts by doing
- * - for inner context: SHA2(key XOR ipad)
- * - for outer context: SHA2(key XOR opad)
- *
- * Update:
- * Each subsequent SHA2 HMAC update will result in an
- * update of the inner context with the specified data.
- *
- * Final:
- * The SHA2 HMAC final will do a SHA2 final operation on the
- * inner context, and the resulting digest will be used
- * as the data for an update on the outer context. Last
- * but not least, a SHA2 final on the outer context will
- * be performed to obtain the SHA2 HMAC digest to return
- * to the user.
- */
-
-/*
- * Initialize a SHA2-HMAC context.
- */
-static void
-sha2_mac_init_ctx(sha2_hmac_ctx_t *ctx, void *keyval, uint_t length_in_bytes)
-{
-	uint64_t ipad[SHA512_HMAC_BLOCK_SIZE / sizeof (uint64_t)];
-	uint64_t opad[SHA512_HMAC_BLOCK_SIZE / sizeof (uint64_t)];
-	int i, block_size, blocks_per_int64;
-
-	/* Determine the block size */
-	if (ctx->hc_mech_type <= SHA256_HMAC_GEN_MECH_INFO_TYPE) {
-		block_size = SHA256_HMAC_BLOCK_SIZE;
-		blocks_per_int64 = SHA256_HMAC_BLOCK_SIZE / sizeof (uint64_t);
-	} else {
-		block_size = SHA512_HMAC_BLOCK_SIZE;
-		blocks_per_int64 = SHA512_HMAC_BLOCK_SIZE / sizeof (uint64_t);
-	}
-
-	(void) bzero(ipad, block_size);
-	(void) bzero(opad, block_size);
-	(void) bcopy(keyval, ipad, length_in_bytes);
-	(void) bcopy(keyval, opad, length_in_bytes);
-
-	/* XOR key with ipad (0x36) and opad (0x5c) */
-	for (i = 0; i < blocks_per_int64; i ++) {
-		ipad[i] ^= 0x3636363636363636;
-		opad[i] ^= 0x5c5c5c5c5c5c5c5c;
-	}
-
-	/* perform SHA2 on ipad */
-	SHA2Init(ctx->hc_mech_type, &ctx->hc_icontext);
-	SHA2Update(&ctx->hc_icontext, (uint8_t *)ipad, block_size);
-
-	/* perform SHA2 on opad */
-	SHA2Init(ctx->hc_mech_type, &ctx->hc_ocontext);
-	SHA2Update(&ctx->hc_ocontext, (uint8_t *)opad, block_size);
-
-}
-
-/*
- */
-static int
-sha2_mac_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-	uint_t sha_digest_len, sha_hmac_block_size;
-
-	/*
-	 * Set the digest length and block size to values approriate to the
-	 * mechanism
-	 */
-	switch (mechanism->cm_type) {
-	case SHA256_HMAC_MECH_INFO_TYPE:
-	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = SHA256_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
-		break;
-	case SHA384_HMAC_MECH_INFO_TYPE:
-	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
-	case SHA512_HMAC_MECH_INFO_TYPE:
-	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = SHA512_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
-		break;
-	default:
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	ctx->cc_provider_private = kmem_alloc(sizeof (sha2_hmac_ctx_t),
-	    crypto_kmflag(req));
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, PROV_SHA2_HMAC_CTX(ctx),
-		    sizeof (sha2_hmac_ctx_t));
-	} else {
-		/* no context template, compute context */
-		if (keylen_in_bytes > sha_hmac_block_size) {
-			uchar_t digested_key[SHA512_DIGEST_LENGTH];
-			sha2_hmac_ctx_t *hmac_ctx = ctx->cc_provider_private;
-
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
-			    &hmac_ctx->hc_icontext,
-			    key->ck_data, keylen_in_bytes, digested_key);
-			sha2_mac_init_ctx(PROV_SHA2_HMAC_CTX(ctx),
-			    digested_key, sha_digest_len);
-		} else {
-			sha2_mac_init_ctx(PROV_SHA2_HMAC_CTX(ctx),
-			    key->ck_data, keylen_in_bytes);
-		}
-	}
-
-	/*
-	 * Get the mechanism parameters, if applicable.
-	 */
-	PROV_SHA2_HMAC_CTX(ctx)->hc_mech_type = mechanism->cm_type;
-	if (mechanism->cm_type % 3 == 2) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t))
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-		PROV_SHA2_GET_DIGEST_LEN(mechanism,
-		    PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len);
-		if (PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len > sha_digest_len)
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-	}
-
-	if (ret != CRYPTO_SUCCESS) {
-		bzero(ctx->cc_provider_private, sizeof (sha2_hmac_ctx_t));
-		kmem_free(ctx->cc_provider_private, sizeof (sha2_hmac_ctx_t));
-		ctx->cc_provider_private = NULL;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha2_mac_update(crypto_ctx_t *ctx, crypto_data_t *data,
-    crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/*
-	 * Do a SHA2 update of the inner context using the specified
-	 * data.
-	 */
-	switch (data->cd_format) {
-	case CRYPTO_DATA_RAW:
-		SHA2Update(&PROV_SHA2_HMAC_CTX(ctx)->hc_icontext,
-		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
-		    data->cd_length);
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_update_uio(
-		    &PROV_SHA2_HMAC_CTX(ctx)->hc_icontext, data);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_update_mblk(
-		    &PROV_SHA2_HMAC_CTX(ctx)->hc_icontext, data);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha2_mac_final(crypto_ctx_t *ctx, crypto_data_t *mac, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[SHA512_DIGEST_LENGTH];
-	uint32_t digest_len, sha_digest_len;
-
-	ASSERT(ctx->cc_provider_private != NULL);
-
-	/* Set the digest lengths to values approriate to the mechanism */
-	switch (PROV_SHA2_HMAC_CTX(ctx)->hc_mech_type) {
-	case SHA256_HMAC_MECH_INFO_TYPE:
-		sha_digest_len = digest_len = SHA256_DIGEST_LENGTH;
-		break;
-	case SHA384_HMAC_MECH_INFO_TYPE:
-	case SHA512_HMAC_MECH_INFO_TYPE:
-		sha_digest_len = digest_len = SHA512_DIGEST_LENGTH;
-		break;
-	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = SHA256_DIGEST_LENGTH;
-		digest_len = PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len;
-		break;
-	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
-	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = SHA512_DIGEST_LENGTH;
-		digest_len = PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len;
-		break;
-	}
-
-	/*
-	 * We need to just return the length needed to store the output.
-	 * We should not destroy the context for the following cases.
-	 */
-	if ((mac->cd_length == 0) || (mac->cd_length < digest_len)) {
-		mac->cd_length = digest_len;
-		return (CRYPTO_BUFFER_TOO_SMALL);
-	}
-
-	/*
-	 * Do a SHA2 final on the inner context.
-	 */
-	SHA2Final(digest, &PROV_SHA2_HMAC_CTX(ctx)->hc_icontext);
-
-	/*
-	 * Do a SHA2 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	SHA2Update(&PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, digest,
-	    sha_digest_len);
-
-	/*
-	 * Do a SHA2 final on the outer context, storing the computing
-	 * digest in the users buffer.
-	 */
-	switch (mac->cd_format) {
-	case CRYPTO_DATA_RAW:
-		if (digest_len != sha_digest_len) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA2Final(digest,
-			    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext);
-			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, digest_len);
-		} else {
-			SHA2Final((unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset,
-			    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext);
-		}
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_final_uio(
-		    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_final_mblk(
-		    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS)
-		mac->cd_length = digest_len;
-	else
-		mac->cd_length = 0;
-
-	bzero(&PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, sizeof (sha2_hmac_ctx_t));
-	kmem_free(ctx->cc_provider_private, sizeof (sha2_hmac_ctx_t));
-	ctx->cc_provider_private = NULL;
-
-	return (ret);
-}
-
-#define	SHA2_MAC_UPDATE(data, ctx, ret) {				\
-	switch (data->cd_format) {					\
-	case CRYPTO_DATA_RAW:						\
-		SHA2Update(&(ctx).hc_icontext,				\
-		    (uint8_t *)data->cd_raw.iov_base +			\
-		    data->cd_offset, data->cd_length);			\
-		break;							\
-	case CRYPTO_DATA_UIO:						\
-		ret = sha2_digest_update_uio(&(ctx).hc_icontext, data);	\
-		break;							\
-	case CRYPTO_DATA_MBLK:						\
-		ret = sha2_digest_update_mblk(&(ctx).hc_icontext,	\
-		    data);						\
-		break;							\
-	default:							\
-		ret = CRYPTO_ARGUMENTS_BAD;				\
-	}								\
-}
-
-/* ARGSUSED */
-static int
-sha2_mac_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
-    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[SHA512_DIGEST_LENGTH];
-	sha2_hmac_ctx_t sha2_hmac_ctx;
-	uint32_t sha_digest_len, digest_len, sha_hmac_block_size;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	/*
-	 * Set the digest length and block size to values approriate to the
-	 * mechanism
-	 */
-	switch (mechanism->cm_type) {
-	case SHA256_HMAC_MECH_INFO_TYPE:
-	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = digest_len = SHA256_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
-		break;
-	case SHA384_HMAC_MECH_INFO_TYPE:
-	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
-	case SHA512_HMAC_MECH_INFO_TYPE:
-	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = digest_len = SHA512_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
-		break;
-	default:
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, &sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
-	} else {
-		sha2_hmac_ctx.hc_mech_type = mechanism->cm_type;
-		/* no context template, initialize context */
-		if (keylen_in_bytes > sha_hmac_block_size) {
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
-			    &sha2_hmac_ctx.hc_icontext,
-			    key->ck_data, keylen_in_bytes, digest);
-			sha2_mac_init_ctx(&sha2_hmac_ctx, digest,
-			    sha_digest_len);
-		} else {
-			sha2_mac_init_ctx(&sha2_hmac_ctx, key->ck_data,
-			    keylen_in_bytes);
-		}
-	}
-
-	/* get the mechanism parameters, if applicable */
-	if ((mechanism->cm_type % 3) == 2) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t)) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-		PROV_SHA2_GET_DIGEST_LEN(mechanism, digest_len);
-		if (digest_len > sha_digest_len) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-	}
-
-	/* do a SHA2 update of the inner context using the specified data */
-	SHA2_MAC_UPDATE(data, sha2_hmac_ctx, ret);
-	if (ret != CRYPTO_SUCCESS)
-		/* the update failed, free context and bail */
-		goto bail;
-
-	/*
-	 * Do a SHA2 final on the inner context.
-	 */
-	SHA2Final(digest, &sha2_hmac_ctx.hc_icontext);
-
-	/*
-	 * Do an SHA2 update on the outer context, feeding the inner
-	 * digest as data.
-	 *
-	 * Make sure that SHA384 is handled special because
-	 * it cannot feed a 60-byte inner hash to the outer
-	 */
-	if (mechanism->cm_type == SHA384_HMAC_MECH_INFO_TYPE ||
-	    mechanism->cm_type == SHA384_HMAC_GEN_MECH_INFO_TYPE)
-		SHA2Update(&sha2_hmac_ctx.hc_ocontext, digest,
-		    SHA384_DIGEST_LENGTH);
-	else
-		SHA2Update(&sha2_hmac_ctx.hc_ocontext, digest, sha_digest_len);
-
-	/*
-	 * Do a SHA2 final on the outer context, storing the computed
-	 * digest in the users buffer.
-	 */
-	switch (mac->cd_format) {
-	case CRYPTO_DATA_RAW:
-		if (digest_len != sha_digest_len) {
-			/*
-			 * The caller requested a short digest. Digest
-			 * into a scratch buffer and return to
-			 * the user only what was requested.
-			 */
-			SHA2Final(digest, &sha2_hmac_ctx.hc_ocontext);
-			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, digest_len);
-		} else {
-			SHA2Final((unsigned char *)mac->cd_raw.iov_base +
-			    mac->cd_offset, &sha2_hmac_ctx.hc_ocontext);
-		}
-		break;
-	case CRYPTO_DATA_UIO:
-		ret = sha2_digest_final_uio(&sha2_hmac_ctx.hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	case CRYPTO_DATA_MBLK:
-		ret = sha2_digest_final_mblk(&sha2_hmac_ctx.hc_ocontext, mac,
-		    digest_len, digest);
-		break;
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	if (ret == CRYPTO_SUCCESS) {
-		mac->cd_length = digest_len;
-		return (CRYPTO_SUCCESS);
-	}
-bail:
-	bzero(&sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
-	mac->cd_length = 0;
-	return (ret);
-}
-
-/* ARGSUSED */
-static int
-sha2_mac_verify_atomic(crypto_provider_handle_t provider,
-    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
-    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
-    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
-{
-	int ret = CRYPTO_SUCCESS;
-	uchar_t digest[SHA512_DIGEST_LENGTH];
-	sha2_hmac_ctx_t sha2_hmac_ctx;
-	uint32_t sha_digest_len, digest_len, sha_hmac_block_size;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-
-	/*
-	 * Set the digest length and block size to values approriate to the
-	 * mechanism
-	 */
-	switch (mechanism->cm_type) {
-	case SHA256_HMAC_MECH_INFO_TYPE:
-	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = digest_len = SHA256_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
-		break;
-	case SHA384_HMAC_MECH_INFO_TYPE:
-	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
-	case SHA512_HMAC_MECH_INFO_TYPE:
-	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = digest_len = SHA512_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
-		break;
-	default:
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	if (ctx_template != NULL) {
-		/* reuse context template */
-		bcopy(ctx_template, &sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
-	} else {
-		/* no context template, initialize context */
-		if (keylen_in_bytes > sha_hmac_block_size) {
-			/*
-			 * Hash the passed-in key to get a smaller key.
-			 * The inner context is used since it hasn't been
-			 * initialized yet.
-			 */
-			PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
-			    &sha2_hmac_ctx.hc_icontext,
-			    key->ck_data, keylen_in_bytes, digest);
-			sha2_mac_init_ctx(&sha2_hmac_ctx, digest,
-			    sha_digest_len);
-		} else {
-			sha2_mac_init_ctx(&sha2_hmac_ctx, key->ck_data,
-			    keylen_in_bytes);
-		}
-	}
-
-	/* get the mechanism parameters, if applicable */
-	if (mechanism->cm_type % 3 == 2) {
-		if (mechanism->cm_param == NULL ||
-		    mechanism->cm_param_len != sizeof (ulong_t)) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-		PROV_SHA2_GET_DIGEST_LEN(mechanism, digest_len);
-		if (digest_len > sha_digest_len) {
-			ret = CRYPTO_MECHANISM_PARAM_INVALID;
-			goto bail;
-		}
-	}
-
-	if (mac->cd_length != digest_len) {
-		ret = CRYPTO_INVALID_MAC;
-		goto bail;
-	}
-
-	/* do a SHA2 update of the inner context using the specified data */
-	SHA2_MAC_UPDATE(data, sha2_hmac_ctx, ret);
-	if (ret != CRYPTO_SUCCESS)
-		/* the update failed, free context and bail */
-		goto bail;
-
-	/* do a SHA2 final on the inner context */
-	SHA2Final(digest, &sha2_hmac_ctx.hc_icontext);
-
-	/*
-	 * Do an SHA2 update on the outer context, feeding the inner
-	 * digest as data.
-	 */
-	SHA2Update(&sha2_hmac_ctx.hc_ocontext, digest, sha_digest_len);
-
-	/*
-	 * Do a SHA2 final on the outer context, storing the computed
-	 * digest in the users buffer.
-	 */
-	SHA2Final(digest, &sha2_hmac_ctx.hc_ocontext);
-
-	/*
-	 * Compare the computed digest against the expected digest passed
-	 * as argument.
-	 */
-
-	switch (mac->cd_format) {
-
-	case CRYPTO_DATA_RAW:
-		if (bcmp(digest, (unsigned char *)mac->cd_raw.iov_base +
-		    mac->cd_offset, digest_len) != 0)
-			ret = CRYPTO_INVALID_MAC;
-		break;
-
-	case CRYPTO_DATA_UIO: {
-		off_t offset = mac->cd_offset;
-		uint_t vec_idx;
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		/* we support only kernel buffer */
-		if (mac->cd_uio->uio_segflg != UIO_SYSSPACE)
-			return (CRYPTO_ARGUMENTS_BAD);
-
-		/* jump to the first iovec containing the expected digest */
-		for (vec_idx = 0;
-		    offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
-		    vec_idx < mac->cd_uio->uio_iovcnt;
-		    offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len);
-		if (vec_idx == mac->cd_uio->uio_iovcnt) {
-			/*
-			 * The caller specified an offset that is
-			 * larger than the total size of the buffers
-			 * it provided.
-			 */
-			ret = CRYPTO_DATA_LEN_RANGE;
-			break;
-		}
-
-		/* do the comparison of computed digest vs specified one */
-		while (vec_idx < mac->cd_uio->uio_iovcnt && length > 0) {
-			cur_len = MIN(mac->cd_uio->uio_iov[vec_idx].iov_len -
-			    offset, length);
-
-			if (bcmp(digest + scratch_offset,
-			    mac->cd_uio->uio_iov[vec_idx].iov_base + offset,
-			    cur_len) != 0) {
-				ret = CRYPTO_INVALID_MAC;
-				break;
-			}
-
-			length -= cur_len;
-			vec_idx++;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-		break;
-	}
-
-	case CRYPTO_DATA_MBLK: {
-		off_t offset = mac->cd_offset;
-		mblk_t *mp;
-		off_t scratch_offset = 0;
-		size_t length = digest_len;
-		size_t cur_len;
-
-		/* jump to the first mblk_t containing the expected digest */
-		for (mp = mac->cd_mp; mp != NULL && offset >= MBLKL(mp);
-		    offset -= MBLKL(mp), mp = mp->b_cont);
-		if (mp == NULL) {
-			/*
-			 * The caller specified an offset that is larger than
-			 * the total size of the buffers it provided.
-			 */
-			ret = CRYPTO_DATA_LEN_RANGE;
-			break;
-		}
-
-		while (mp != NULL && length > 0) {
-			cur_len = MIN(MBLKL(mp) - offset, length);
-			if (bcmp(digest + scratch_offset,
-			    mp->b_rptr + offset, cur_len) != 0) {
-				ret = CRYPTO_INVALID_MAC;
-				break;
-			}
-
-			length -= cur_len;
-			mp = mp->b_cont;
-			scratch_offset += cur_len;
-			offset = 0;
-		}
-		break;
-	}
-
-	default:
-		ret = CRYPTO_ARGUMENTS_BAD;
-	}
-
-	return (ret);
-bail:
-	bzero(&sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
-	mac->cd_length = 0;
-	return (ret);
-}
-
-/*
- * KCF software provider context management entry points.
- */
-
-/* ARGSUSED */
-static int
-sha2_create_ctx_template(crypto_provider_handle_t provider,
-    crypto_mechanism_t *mechanism, crypto_key_t *key,
-    crypto_spi_ctx_template_t *ctx_template, size_t *ctx_template_size,
-    crypto_req_handle_t req)
-{
-	sha2_hmac_ctx_t *sha2_hmac_ctx_tmpl;
-	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
-	uint32_t sha_digest_len, sha_hmac_block_size;
-
-	/*
-	 * Set the digest length and block size to values approriate to the
-	 * mechanism
-	 */
-	switch (mechanism->cm_type) {
-	case SHA256_HMAC_MECH_INFO_TYPE:
-	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = SHA256_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
-		break;
-	case SHA384_HMAC_MECH_INFO_TYPE:
-	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
-	case SHA512_HMAC_MECH_INFO_TYPE:
-	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
-		sha_digest_len = SHA512_DIGEST_LENGTH;
-		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
-		break;
-	default:
-		return (CRYPTO_MECHANISM_INVALID);
-	}
-
-	/* Add support for key by attributes (RFE 4706552) */
-	if (key->ck_format != CRYPTO_KEY_RAW)
-		return (CRYPTO_ARGUMENTS_BAD);
-
-	/*
-	 * Allocate and initialize SHA2 context.
-	 */
-	sha2_hmac_ctx_tmpl = kmem_alloc(sizeof (sha2_hmac_ctx_t),
-	    crypto_kmflag(req));
-	if (sha2_hmac_ctx_tmpl == NULL)
-		return (CRYPTO_HOST_MEMORY);
-
-	sha2_hmac_ctx_tmpl->hc_mech_type = mechanism->cm_type;
-
-	if (keylen_in_bytes > sha_hmac_block_size) {
-		uchar_t digested_key[SHA512_DIGEST_LENGTH];
-
-		/*
-		 * Hash the passed-in key to get a smaller key.
-		 * The inner context is used since it hasn't been
-		 * initialized yet.
-		 */
-		PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
-		    &sha2_hmac_ctx_tmpl->hc_icontext,
-		    key->ck_data, keylen_in_bytes, digested_key);
-		sha2_mac_init_ctx(sha2_hmac_ctx_tmpl, digested_key,
-		    sha_digest_len);
-	} else {
-		sha2_mac_init_ctx(sha2_hmac_ctx_tmpl, key->ck_data,
-		    keylen_in_bytes);
-	}
-
-	*ctx_template = (crypto_spi_ctx_template_t)sha2_hmac_ctx_tmpl;
-	*ctx_template_size = sizeof (sha2_hmac_ctx_t);
-
-	return (CRYPTO_SUCCESS);
-}
-
-static int
-sha2_free_context(crypto_ctx_t *ctx)
-{
-	uint_t ctx_len;
-
-	if (ctx->cc_provider_private == NULL)
-		return (CRYPTO_SUCCESS);
-
-	/*
-	 * We have to free either SHA2 or SHA2-HMAC contexts, which
-	 * have different lengths.
-	 *
-	 * Note: Below is dependent on the mechanism ordering.
-	 */
-
-	if (PROV_SHA2_CTX(ctx)->sc_mech_type % 3 == 0)
-		ctx_len = sizeof (sha2_ctx_t);
-	else
-		ctx_len = sizeof (sha2_hmac_ctx_t);
-
-	bzero(ctx->cc_provider_private, ctx_len);
-	kmem_free(ctx->cc_provider_private, ctx_len);
-	ctx->cc_provider_private = NULL;
-
-	return (CRYPTO_SUCCESS);
-}
-
-#endif /* _KERNEL */
-
 void
 SHA2Init(uint64_t mech, SHA2_CTX *ctx)
 {
@@ -2411,7 +708,7 @@
 		break;
 #ifdef _KERNEL
 	default:
-		cmn_err(CE_WARN, "sha2_init: "
+		cmn_err(CE_PANIC, "sha2_init: "
 		    "failed to find a supported algorithm: 0x%x",
 		    (uint32_t)mech);
 
@@ -2422,21 +719,45 @@
 	ctx->count.c64[0] = ctx->count.c64[1] = 0;
 }
 
+#ifndef _KERNEL
+
+#pragma inline(SHA256Init, SHA384Init, SHA512Init)
+void
+SHA256Init(SHA256_CTX *ctx)
+{
+	SHA2Init(SHA256, ctx);
+}
+
+void
+SHA384Init(SHA384_CTX *ctx)
+{
+	SHA2Init(SHA384, ctx);
+}
+
+void
+SHA512Init(SHA512_CTX *ctx)
+{
+	SHA2Init(SHA512, ctx);
+}
+
+#endif /* _KERNEL */
+
 /*
  * SHA2Update()
  *
  * purpose: continues an sha2 digest operation, using the message block
  *          to update the context.
  *   input: SHA2_CTX *	: the context to update
- *          uint8_t *	: the message block
- *          uint32_t    : the length of the message block in bytes
+ *          void *	: the message block
+ *          size_t    : the length of the message block in bytes
  *  output: void
  */
 
 void
-SHA2Update(SHA2_CTX *ctx, const uint8_t *input, uint32_t input_len)
+SHA2Update(SHA2_CTX *ctx, const void *inptr, size_t input_len)
 {
 	uint32_t i, buf_index, buf_len, buf_limit;
+	const uint8_t *input = inptr;
 
 	/* check for noop */
 	if (input_len == 0)
@@ -2529,9 +850,8 @@
  *  output: void
  */
 
-
 void
-SHA2Final(uint8_t *digest, SHA2_CTX *ctx)
+SHA2Final(void *digest, SHA2_CTX *ctx)
 {
 	uint8_t		bitcount_be[sizeof (ctx->count.c32)];
 	uint8_t		bitcount_be64[sizeof (ctx->count.c64)];
--- a/usr/src/common/net/wanboot/crypt/sha1.c	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,775 +0,0 @@
-/*
- * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * The basic framework for this code came from the reference
- * implementation for MD5.  That implementation is Copyright (C)
- * 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- *
- * NOTE: Cleaned-up and optimized, version of SHA1, based on the FIPS 180-1
- * standard, available at http://www.itl.nist.gov/div897/pubs/fip180-1.htm
- * Not as fast as one would like -- further optimizations are encouraged
- * and appreciated.
- */
-
-#include <sys/types.h>
-#include <strings.h>
-#include <sys/sha1.h>
-#include <sys/sha1_consts.h>
-
-#define	RCSID	"$Id: $"
-#if !defined(lint) && !defined(_lint)
-static const char rcsid[] = RCSID;
-#endif
-
-static void Encode(uint8_t *, uint32_t *, size_t);
-static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
-    SHA1_CTX *, const uint8_t *);
-
-static uint8_t PADDING[64] = { 0x80, /* all zeros */ };
-
-/*
- * F, G, and H are the basic SHA1 functions.
- */
-#define	F(b, c, d)	(((b) & (c)) | ((~b) & (d)))
-#define	G(b, c, d)	((b) ^ (c) ^ (d))
-#define	H(b, c, d)	(((b) & (c)) | ((b) & (d)) | ((c) & (d)))
-
-/*
- * ROTATE_LEFT rotates x left n bits.
- */
-#define	ROTATE_LEFT(x, n)	\
-	(((x) << (n)) | ((x) >> ((sizeof (x) * NBBY)-(n))))
-
-/*
- * SHA1Init()
- *
- * purpose: initializes the sha1 context and begins and sha1 digest operation
- *   input: SHA1_CTX *	: the context to initializes.
- *  output: void
- */
-
-void
-SHA1Init(SHA1_CTX *ctx)
-{
-	ctx->count[0] = ctx->count[1] = 0;
-
-	/*
-	 * load magic initialization constants. Tell lint
-	 * that these constants are unsigned by using U.
-	 */
-
-	ctx->state[0] = 0x67452301U;
-	ctx->state[1] = 0xefcdab89U;
-	ctx->state[2] = 0x98badcfeU;
-	ctx->state[3] = 0x10325476U;
-	ctx->state[4] = 0xc3d2e1f0U;
-}
-
-/*
- * SHA1Update()
- *
- * purpose: continues an sha1 digest operation, using the message block
- *          to update the context.
- *   input: SHA1_CTX *	: the context to update
- *          uint8_t *	: the message block
- *          uint32_t    : the length of the message block in bytes
- *  output: void
- */
-
-void
-SHA1Update(SHA1_CTX *ctx, const uint8_t *input, uint32_t input_len)
-{
-	uint32_t i, buf_index, buf_len;
-
-	/* check for noop */
-	if (input_len == 0)
-		return;
-
-	/* compute number of bytes mod 64 */
-	buf_index = (ctx->count[1] >> 3) & 0x3F;
-
-	/* update number of bits */
-	if ((ctx->count[1] += (input_len << 3)) < (input_len << 3))
-		ctx->count[0]++;
-
-	ctx->count[0] += (input_len >> 29);
-
-	buf_len = 64 - buf_index;
-
-	/* transform as many times as possible */
-	i = 0;
-	if (input_len >= buf_len) {
-
-		/*
-		 * general optimization:
-		 *
-		 * only do initial bcopy() and SHA1Transform() if
-		 * buf_index != 0.  if buf_index == 0, we're just
-		 * wasting our time doing the bcopy() since there
-		 * wasn't any data left over from a previous call to
-		 * SHA1Update().
-		 */
-
-		if (buf_index) {
-			bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
-
-
-			SHA1Transform(ctx->state[0], ctx->state[1],
-			    ctx->state[2], ctx->state[3], ctx->state[4], ctx,
-			    ctx->buf_un.buf8);
-
-			i = buf_len;
-		}
-
-		for (; i + 63 < input_len; i += 64)
-			SHA1Transform(ctx->state[0], ctx->state[1],
-			    ctx->state[2], ctx->state[3], ctx->state[4],
-			    ctx, &input[i]);
-
-		/*
-		 * general optimization:
-		 *
-		 * if i and input_len are the same, return now instead
-		 * of calling bcopy(), since the bcopy() in this case
-		 * will be an expensive nop.
-		 */
-
-		if (input_len == i)
-			return;
-
-		buf_index = 0;
-	}
-
-	/* buffer remaining input */
-	bcopy(&input[i], &ctx->buf_un.buf8[buf_index], input_len - i);
-}
-
-/*
- * SHA1Final()
- *
- * purpose: ends an sha1 digest operation, finalizing the message digest and
- *          zeroing the context.
- *   input: uint8_t *	: a buffer to store the digest in
- *          SHA1_CTX *  : the context to finalize, save, and zero
- *  output: void
- */
-
-void
-SHA1Final(uint8_t *digest, SHA1_CTX *ctx)
-{
-	uint8_t		bitcount_be[sizeof (ctx->count)];
-	uint32_t	index = (ctx->count[1] >> 3) & 0x3f;
-
-	/* store bit count, big endian */
-	Encode(bitcount_be, ctx->count, sizeof (bitcount_be));
-
-	/* pad out to 56 mod 64 */
-	SHA1Update(ctx, PADDING, ((index < 56) ? 56 : 120) - index);
-
-	/* append length (before padding) */
-	SHA1Update(ctx, bitcount_be, sizeof (bitcount_be));
-
-	/* store state in digest */
-	Encode(digest, ctx->state, sizeof (ctx->state));
-
-	/* zeroize sensitive information */
-	bzero(ctx, sizeof (*ctx));
-}
-
-/*
- * sparc optimization:
- *
- * on the sparc, we can load big endian 32-bit data easily.  note that
- * special care must be taken to ensure the address is 32-bit aligned.
- * in the interest of speed, we don't check to make sure, since
- * careful programming can guarantee this for us.
- */
-
-#if	defined(__sparc)
-
-#define	LOAD_LITTLE_32(addr)	(*(uint32_t *)(addr))
-
-#else	/* little endian -- will work on big endian, but slowly */
-
-#define	LOAD_LITTLE_32(addr)	\
-	(((addr)[0] << 24) | ((addr)[1] << 16) | ((addr)[2] << 8) | (addr)[3])
-#endif
-
-/*
- * sparc register window optimization:
- *
- * `a', `b', `c', `d', and `e' are passed into SHA1Transform
- * explicitly since it increases the number of registers available to
- * the compiler.  under this scheme, these variables can be held in
- * %i0 - %i4, which leaves more local and out registers available.
- */
-
-/*
- * SHA1Transform()
- *
- * purpose: sha1 transformation -- updates the digest based on `block'
- *   input: uint32_t	: bytes  1 -  4 of the digest
- *          uint32_t	: bytes  5 -  8 of the digest
- *          uint32_t	: bytes  9 - 12 of the digest
- *          uint32_t	: bytes 12 - 16 of the digest
- *          uint32_t	: bytes 16 - 20 of the digest
- *          SHA1_CTX *	: the context to update
- *          uint8_t [64]: the block to use to update the digest
- *  output: void
- */
-
-void
-SHA1Transform(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e,
-    SHA1_CTX *ctx, const uint8_t blk[64])
-{
-	/*
-	 * sparc optimization:
-	 *
-	 * while it is somewhat counter-intuitive, on sparc, it is
-	 * more efficient to place all the constants used in this
-	 * function in an array and load the values out of the array
-	 * than to manually load the constants.  this is because
-	 * setting a register to a 32-bit value takes two ops in most
-	 * cases: a `sethi' and an `or', but loading a 32-bit value
-	 * from memory only takes one `ld' (or `lduw' on v9).  while
-	 * this increases memory usage, the compiler can find enough
-	 * other things to do while waiting to keep the pipeline does
-	 * not stall.  additionally, it is likely that many of these
-	 * constants are cached so that later accesses do not even go
-	 * out to the bus.
-	 *
-	 * this array is declared `static' to keep the compiler from
-	 * having to bcopy() this array onto the stack frame of
-	 * SHA1Transform() each time it is called -- which is
-	 * unacceptably expensive.
-	 *
-	 * the `const' is to ensure that callers are good citizens and
-	 * do not try to munge the array.  since these routines are
-	 * going to be called from inside multithreaded kernelland,
-	 * this is a good safety check. -- `sha1_consts' will end up in
-	 * .rodata.
-	 *
-	 * unfortunately, loading from an array in this manner hurts
-	 * performance under intel.  so, there is a macro,
-	 * SHA1_CONST(), used in SHA1Transform(), that either expands to
-	 * a reference to this array, or to the actual constant,
-	 * depending on what platform this code is compiled for.
-	 */
-
-#if	defined(__sparc)
-	static const uint32_t sha1_consts[] = {
-		SHA1_CONST_0,	SHA1_CONST_1,	SHA1_CONST_2,	SHA1_CONST_3,
-	};
-#endif
-
-	/*
-	 * general optimization:
-	 *
-	 * use individual integers instead of using an array.  this is a
-	 * win, although the amount it wins by seems to vary quite a bit.
-	 */
-
-	uint32_t	w_0, w_1, w_2,  w_3,  w_4,  w_5,  w_6,  w_7;
-	uint32_t	w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15;
-
-	/*
-	 * sparc optimization:
-	 *
-	 * if `block' is already aligned on a 4-byte boundary, use
-	 * LOAD_LITTLE_32() directly.  otherwise, bcopy() into a
-	 * buffer that *is* aligned on a 4-byte boundary and then do
-	 * the LOAD_LITTLE_32() on that buffer.  benchmarks have shown
-	 * that using the bcopy() is better than loading the bytes
-	 * individually and doing the endian-swap by hand.
-	 *
-	 * even though it's quite tempting to assign to do:
-	 *
-	 * blk = bcopy(ctx->buf_un.buf32, blk, sizeof (ctx->buf_un.buf32));
-	 *
-	 * and only have one set of LOAD_LITTLE_32()'s, the compiler
-	 * *does not* like that, so please resist the urge.
-	 */
-
-#if	defined(__sparc)
-	if ((uintptr_t)blk & 0x3) {		/* not 4-byte aligned? */
-		bcopy(blk, ctx->buf_un.buf32,  sizeof (ctx->buf_un.buf32));
-		w_15 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 15);
-		w_14 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 14);
-		w_13 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 13);
-		w_12 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 12);
-		w_11 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 11);
-		w_10 = LOAD_LITTLE_32(ctx->buf_un.buf32 + 10);
-		w_9  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  9);
-		w_8  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  8);
-		w_7  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  7);
-		w_6  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  6);
-		w_5  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  5);
-		w_4  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  4);
-		w_3  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  3);
-		w_2  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  2);
-		w_1  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  1);
-		w_0  = LOAD_LITTLE_32(ctx->buf_un.buf32 +  0);
-	} else {
-		/*LINTED*/
-		w_15 = LOAD_LITTLE_32(blk + 60);
-		/*LINTED*/
-		w_14 = LOAD_LITTLE_32(blk + 56);
-		/*LINTED*/
-		w_13 = LOAD_LITTLE_32(blk + 52);
-		/*LINTED*/
-		w_12 = LOAD_LITTLE_32(blk + 48);
-		/*LINTED*/
-		w_11 = LOAD_LITTLE_32(blk + 44);
-		/*LINTED*/
-		w_10 = LOAD_LITTLE_32(blk + 40);
-		/*LINTED*/
-		w_9  = LOAD_LITTLE_32(blk + 36);
-		/*LINTED*/
-		w_8  = LOAD_LITTLE_32(blk + 32);
-		/*LINTED*/
-		w_7  = LOAD_LITTLE_32(blk + 28);
-		/*LINTED*/
-		w_6  = LOAD_LITTLE_32(blk + 24);
-		/*LINTED*/
-		w_5  = LOAD_LITTLE_32(blk + 20);
-		/*LINTED*/
-		w_4  = LOAD_LITTLE_32(blk + 16);
-		/*LINTED*/
-		w_3  = LOAD_LITTLE_32(blk + 12);
-		/*LINTED*/
-		w_2  = LOAD_LITTLE_32(blk +  8);
-		/*LINTED*/
-		w_1  = LOAD_LITTLE_32(blk +  4);
-		/*LINTED*/
-		w_0  = LOAD_LITTLE_32(blk +  0);
-	}
-#else
-	w_15 = LOAD_LITTLE_32(blk + 60);
-	w_14 = LOAD_LITTLE_32(blk + 56);
-	w_13 = LOAD_LITTLE_32(blk + 52);
-	w_12 = LOAD_LITTLE_32(blk + 48);
-	w_11 = LOAD_LITTLE_32(blk + 44);
-	w_10 = LOAD_LITTLE_32(blk + 40);
-	w_9  = LOAD_LITTLE_32(blk + 36);
-	w_8  = LOAD_LITTLE_32(blk + 32);
-	w_7  = LOAD_LITTLE_32(blk + 28);
-	w_6  = LOAD_LITTLE_32(blk + 24);
-	w_5  = LOAD_LITTLE_32(blk + 20);
-	w_4  = LOAD_LITTLE_32(blk + 16);
-	w_3  = LOAD_LITTLE_32(blk + 12);
-	w_2  = LOAD_LITTLE_32(blk +  8);
-	w_1  = LOAD_LITTLE_32(blk +  4);
-	w_0  = LOAD_LITTLE_32(blk +  0);
-#endif
-	/*
-	 * general optimization:
-	 *
-	 * even though this approach is described in the standard as
-	 * being slower algorithmically, it is 30-40% faster than the
-	 * "faster" version under SPARC, because this version has more
-	 * of the constraints specified at compile-time and uses fewer
-	 * variables (and therefore has better register utilization)
-	 * than its "speedier" brother.  (i've tried both, trust me)
-	 *
-	 * for either method given in the spec, there is an "assignment"
-	 * phase where the following takes place:
-	 *
-	 *	tmp = (main_computation);
-	 *	e = d; d = c; c = rotate_left(b, 30); b = a; a = tmp;
-	 *
-	 * we can make the algorithm go faster by not doing this work,
-	 * but just pretending that `d' is now `e', etc. this works
-	 * really well and obviates the need for a temporary variable.
-	 * however, we still explictly perform the rotate action,
-	 * since it is cheaper on SPARC to do it once than to have to
-	 * do it over and over again.
-	 */
-
-	/* round 1 */
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_0 + SHA1_CONST(0); /* 0 */
-	b = ROTATE_LEFT(b, 30);
-
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_1 + SHA1_CONST(0); /* 1 */
-	a = ROTATE_LEFT(a, 30);
-
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_2 + SHA1_CONST(0); /* 2 */
-	e = ROTATE_LEFT(e, 30);
-
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_3 + SHA1_CONST(0); /* 3 */
-	d = ROTATE_LEFT(d, 30);
-
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_4 + SHA1_CONST(0); /* 4 */
-	c = ROTATE_LEFT(c, 30);
-
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_5 + SHA1_CONST(0); /* 5 */
-	b = ROTATE_LEFT(b, 30);
-
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_6 + SHA1_CONST(0); /* 6 */
-	a = ROTATE_LEFT(a, 30);
-
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_7 + SHA1_CONST(0); /* 7 */
-	e = ROTATE_LEFT(e, 30);
-
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_8 + SHA1_CONST(0); /* 8 */
-	d = ROTATE_LEFT(d, 30);
-
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_9 + SHA1_CONST(0); /* 9 */
-	c = ROTATE_LEFT(c, 30);
-
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_10 + SHA1_CONST(0); /* 10 */
-	b = ROTATE_LEFT(b, 30);
-
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_11 + SHA1_CONST(0); /* 11 */
-	a = ROTATE_LEFT(a, 30);
-
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_12 + SHA1_CONST(0); /* 12 */
-	e = ROTATE_LEFT(e, 30);
-
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_13 + SHA1_CONST(0); /* 13 */
-	d = ROTATE_LEFT(d, 30);
-
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_14 + SHA1_CONST(0); /* 14 */
-	c = ROTATE_LEFT(c, 30);
-
-	e = ROTATE_LEFT(a, 5) + F(b, c, d) + e + w_15 + SHA1_CONST(0); /* 15 */
-	b = ROTATE_LEFT(b, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 16 */
-	d = ROTATE_LEFT(e, 5) + F(a, b, c) + d + w_0 + SHA1_CONST(0);
-	a = ROTATE_LEFT(a, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 17 */
-	c = ROTATE_LEFT(d, 5) + F(e, a, b) + c + w_1 + SHA1_CONST(0);
-	e = ROTATE_LEFT(e, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 18 */
-	b = ROTATE_LEFT(c, 5) + F(d, e, a) + b + w_2 + SHA1_CONST(0);
-	d = ROTATE_LEFT(d, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 19 */
-	a = ROTATE_LEFT(b, 5) + F(c, d, e) + a + w_3 + SHA1_CONST(0);
-	c = ROTATE_LEFT(c, 30);
-
-	/* round 2 */
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 20 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_4 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 21 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_5 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 22 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_6 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 23 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_7 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 24 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_8 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 25 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_9 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 26 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_10 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 27 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_11 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 28 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_12 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 29 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_13 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 30 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_14 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 31 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_15 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 32 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_0 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 33 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_1 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 34 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_2 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 35 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_3 + SHA1_CONST(1);
-	b = ROTATE_LEFT(b, 30);
-
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 36 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_4 + SHA1_CONST(1);
-	a = ROTATE_LEFT(a, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 37 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_5 + SHA1_CONST(1);
-	e = ROTATE_LEFT(e, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 38 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_6 + SHA1_CONST(1);
-	d = ROTATE_LEFT(d, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 39 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_7 + SHA1_CONST(1);
-	c = ROTATE_LEFT(c, 30);
-
-	/* round 3 */
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 40 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_8 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 41 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_9 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 42 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_10 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 43 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_11 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 44 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_12 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 45 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_13 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 46 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_14 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 47 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_15 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 48 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_0 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 49 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_1 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 50 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_2 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 51 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_3 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 52 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_4 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 53 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_5 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 54 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_6 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 55 */
-	e = ROTATE_LEFT(a, 5) + H(b, c, d) + e + w_7 + SHA1_CONST(2);
-	b = ROTATE_LEFT(b, 30);
-
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 56 */
-	d = ROTATE_LEFT(e, 5) + H(a, b, c) + d + w_8 + SHA1_CONST(2);
-	a = ROTATE_LEFT(a, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 57 */
-	c = ROTATE_LEFT(d, 5) + H(e, a, b) + c + w_9 + SHA1_CONST(2);
-	e = ROTATE_LEFT(e, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 58 */
-	b = ROTATE_LEFT(c, 5) + H(d, e, a) + b + w_10 + SHA1_CONST(2);
-	d = ROTATE_LEFT(d, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 59 */
-	a = ROTATE_LEFT(b, 5) + H(c, d, e) + a + w_11 + SHA1_CONST(2);
-	c = ROTATE_LEFT(c, 30);
-
-	/* round 4 */
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 60 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_12 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 61 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_13 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 62 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_14 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 63 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_15 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_0 = ROTATE_LEFT((w_13 ^ w_8 ^ w_2 ^ w_0), 1);		/* 64 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_0 + SHA1_CONST(3);
-	c = ROTATE_LEFT(c, 30);
-
-	w_1 = ROTATE_LEFT((w_14 ^ w_9 ^ w_3 ^ w_1), 1);		/* 65 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_1 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_2 = ROTATE_LEFT((w_15 ^ w_10 ^ w_4 ^ w_2), 1);	/* 66 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_2 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_3 = ROTATE_LEFT((w_0 ^ w_11 ^ w_5 ^ w_3), 1);		/* 67 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_3 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_4 = ROTATE_LEFT((w_1 ^ w_12 ^ w_6 ^ w_4), 1);		/* 68 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_4 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_5 = ROTATE_LEFT((w_2 ^ w_13 ^ w_7 ^ w_5), 1);		/* 69 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_5 + SHA1_CONST(3);
-	c = ROTATE_LEFT(c, 30);
-
-	w_6 = ROTATE_LEFT((w_3 ^ w_14 ^ w_8 ^ w_6), 1);		/* 70 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_6 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_7 = ROTATE_LEFT((w_4 ^ w_15 ^ w_9 ^ w_7), 1);		/* 71 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_7 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_8 = ROTATE_LEFT((w_5 ^ w_0 ^ w_10 ^ w_8), 1);		/* 72 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_8 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_9 = ROTATE_LEFT((w_6 ^ w_1 ^ w_11 ^ w_9), 1);		/* 73 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_9 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_10 = ROTATE_LEFT((w_7 ^ w_2 ^ w_12 ^ w_10), 1);	/* 74 */
-	a = ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_10 + SHA1_CONST(3);
-	c = ROTATE_LEFT(c, 30);
-
-	w_11 = ROTATE_LEFT((w_8 ^ w_3 ^ w_13 ^ w_11), 1);	/* 75 */
-	e = ROTATE_LEFT(a, 5) + G(b, c, d) + e + w_11 + SHA1_CONST(3);
-	b = ROTATE_LEFT(b, 30);
-
-	w_12 = ROTATE_LEFT((w_9 ^ w_4 ^ w_14 ^ w_12), 1);	/* 76 */
-	d = ROTATE_LEFT(e, 5) + G(a, b, c) + d + w_12 + SHA1_CONST(3);
-	a = ROTATE_LEFT(a, 30);
-
-	w_13 = ROTATE_LEFT((w_10 ^ w_5 ^ w_15 ^ w_13), 1);	/* 77 */
-	c = ROTATE_LEFT(d, 5) + G(e, a, b) + c + w_13 + SHA1_CONST(3);
-	e = ROTATE_LEFT(e, 30);
-
-	w_14 = ROTATE_LEFT((w_11 ^ w_6 ^ w_0 ^ w_14), 1);	/* 78 */
-	b = ROTATE_LEFT(c, 5) + G(d, e, a) + b + w_14 + SHA1_CONST(3);
-	d = ROTATE_LEFT(d, 30);
-
-	w_15 = ROTATE_LEFT((w_12 ^ w_7 ^ w_1 ^ w_15), 1);	/* 79 */
-
-	ctx->state[0] += ROTATE_LEFT(b, 5) + G(c, d, e) + a + w_15 +
-	    SHA1_CONST(3);
-	ctx->state[1] += b;
-	ctx->state[2] += ROTATE_LEFT(c, 30);
-	ctx->state[3] += d;
-	ctx->state[4] += e;
-
-	/* zeroize sensitive information */
-	w_0 = w_1 = w_2 = w_3 = w_4 = w_5 = w_6 = w_7 = w_8 = 0;
-	w_9 = w_10 = w_11 = w_12 = w_13 = w_14 = w_15 = 0;
-}
-
-/*
- * devpro compiler optimization:
- *
- * the compiler can generate better code if it knows that `input' and
- * `output' do not point to the same source.  there is no portable
- * way to tell the compiler this, but the sun compiler recognizes the
- * `_Restrict' keyword to indicate this condition.  use it if possible.
- */
-
-#ifdef	__RESTRICT
-#define	restrict	_Restrict
-#else
-#define	restrict	/* nothing */
-#endif
-
-/*
- * Encode()
- *
- * purpose: to convert a list of numbers from little endian to big endian
- *   input: uint8_t *	: place to store the converted big endian numbers
- *	    uint32_t *	: place to get numbers to convert from
- *          size_t	: the length of the input in bytes
- *  output: void
- */
-
-static void
-Encode(uint8_t *restrict output, uint32_t *restrict input, size_t len)
-{
-	size_t		i, j;
-
-	for (i = 0, j = 0; j < len; i++, j += 4) {
-
-#if	defined(__sparc)
-
-		/*LINTED*/
-		*(uint32_t *)(output + j) = input[i];
-
-#else	/* little endian -- will work on big endian, but slowly */
-
-		output[j]	= (input[i] >> 24) & 0xff;
-		output[j + 1]	= (input[i] >> 16) & 0xff;
-		output[j + 2]	= (input[i] >>  8) & 0xff;
-		output[j + 3]	= input[i] & 0xff;
-
-#endif
-	}
-}
--- a/usr/src/head/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/head/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI" 
@@ -97,7 +96,6 @@
 	locale.h	\
 	macros.h	\
 	malloc.h	\
-	md5.h		\
 	mdmn_changelog.h	\
 	memory.h	\
 	meta.h		\
--- a/usr/src/head/md5.h	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright 1999 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _MD5_H
-#define	_MD5_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * MD5.H - header file for MD5C.C
- */
-
-/*
- * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- * rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
-
-#include <sys/md5.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void md5_calc(unsigned char *, unsigned char *, unsigned int);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _MD5_H */
--- a/usr/src/lib/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -65,6 +65,7 @@
 	libc			.WAIT	\
 	libmapmalloc		.WAIT	\
 	../cmd/sgs/libelf	.WAIT	\
+	libmd				\
 	libmd5				\
 	librsm				\
 	libmp			.WAIT	\
@@ -217,8 +218,7 @@
 
 sparc_SUBDIRS= .WAIT	\
 	efcode		\
-	libc_psr	.WAIT	\
-	libmd5_psr	.WAIT
+	libc_psr	.WAIT
 $(CLOSED_BUILD)sparc_SUBDIRS += \
 	$(CLOSED)/lib/libprtdiag	.WAIT	\
 	$(CLOSED)/lib/libprtdiag_psr	\
@@ -328,6 +328,7 @@
         liblaadm        \
 	libmacadm	\
 	libmail		\
+	libmd		\
 	libmtmalloc	\
 	libnvpair	\
 	libnsl		\
@@ -451,12 +452,12 @@
 libuuid:	libsocket
 libinetutil:	libsocket
 libsecdb:	libcmd libnsl
-librt:		libaio libmd5
-libsasl:	libgss libsocket pkcs11 libmd5
+librt:		libaio libmd
+libsasl:	libgss libsocket pkcs11 libmd
 sasl_plugins:	pkcs11 libgss libsocket libsasl
 libsctp:	libsocket
 libsocket:	libnsl
-libldap5:	libsasl libsocket libnsl libmd5
+libldap5:	libsasl libsocket libnsl libmd
 libsldap:	libldap5 libtsol
 libpool:	libnvpair libexacct
 libproject:	libpool libproc libsecdb
@@ -466,7 +467,7 @@
 		libdhcputil openssl
 libwanbootutil:	libnsl
 pam_modules:	libproject passwdutil $(SMARTCARD)
-libscf:		libuutil
+libscf:		libuutil libmd
 libinetsvc:	libscf
 librestart:	libuutil libscf
 ../cmd/sgs/libdl:	../cmd/sgs/libconv
--- a/usr/src/lib/crypt_modules/bsdmd5/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/crypt_modules/bsdmd5/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
@@ -31,7 +30,7 @@
 
 include		../../Makefile.crypt_modules
 
-LDLIBS 		+= -lc -lmd5
+LDLIBS 		+= -lc -lmd
 
 all: $(LIBS)
 
--- a/usr/src/lib/crypt_modules/sunmd5/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/crypt_modules/sunmd5/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
@@ -31,7 +30,7 @@
 
 include		../../Makefile.crypt_modules
 
-LDLIBS 		+= -lc -lmd5
+LDLIBS 		+= -lc -lmd
 
 all: $(LIBS)
 
--- a/usr/src/lib/libbsm/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libbsm/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -99,7 +99,7 @@
 DYNFLAGS +=	-M$(MAPFILE)
 
 LAZYLIBS =	$(ZLAZYLOAD) -ltsol $(ZNOLAZYLOAD)
-LDLIBS +=	-lsocket -lnsl -lmd5 -lc -lsecdb $(LAZYLIBS)
+LDLIBS +=	-lsocket -lnsl -lmd -lc -lsecdb $(LAZYLIBS)
 lint :=		LAZYLIBS = -ltsol
 
 COMDIR=		../common
--- a/usr/src/lib/libinetsvc/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libinetsvc/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
@@ -34,7 +33,7 @@
 
 LIBS =		$(DYNLIB) $(LINTLIB)
 $(LINTLIB) :=	SRCS = $(SRCDIR)/$(LINTSRC)
-LDLIBS +=	-lscf -lc -lsocket -lnsl -lmd5 -luutil
+LDLIBS +=	-lscf -lc -lsocket -lnsl -lmd -luutil
 
 SRCDIR =	../common
 MAPDIR =	../spec/$(TRANSMACH)
--- a/usr/src/lib/libldap4/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libldap4/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -72,7 +72,7 @@
 CPPFLAGS =	$(LOCFLAGS) $(CPPFLAGS.master)
 CFLAGS +=	$(CCVERBOSE)
 DYNFLAGS +=	-M $(MAPFILE)
-LDLIBS +=	-lsocket -lnsl -lresolv -lc -lmd5
+LDLIBS +=	-lsocket -lnsl -lresolv -lc -lmd
 
 .KEEP_STATE:
 
--- a/usr/src/lib/libldap5/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libldap5/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -120,7 +120,7 @@
 
 CFLAGS +=	$(CCVERBOSE) $(LOCFLAGS)
 CFLAGS64 +=	$(LOCFLAGS)
-LDLIBS +=	-lsasl -lsocket -lnsl -lmd5 -lc
+LDLIBS +=	-lsasl -lsocket -lnsl -lmd -lc
 
 .KEEP_STATE:
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,64 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd/Makefile
+#
+
+include ../Makefile.lib
+
+$(SPARC_BLD)PLATFORMS= sun4u sun4v
+
+SUBDIRS=	$(MACH) $(PLATFORMS)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+HDRS =		md4.h md5.h sha1.h sha2.h
+HDRDIR =	common
+
+all :=		TARGET= all
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+install :=	TARGET= install
+lint :=		TARGET= lint
+
+.KEEP_STATE:
+
+.PARALLEL: $(MACH) $(MACH64) $(PLATFORMS)
+
+all install: spec .WAIT $(SUBDIRS)
+
+clean clobber: $(SUBDIRS)
+
+lint:		$(SUBDIRS)
+
+install_h:	$(ROOTHDRS)
+
+check:		$(CHECKHDRS)
+
+spec $(MACH) $(MACH64) $(PLATFORMS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+FRC:
+
+include ../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,124 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# lib/libmd/Makefile.com
+#
+
+# $LIBRARY is set in lower makefiles so we can have platform and
+# processor optimised versions of this library via libmd_psr and libmd_hwcapN
+
+#LIBRARY= libmd.a
+VERS= .1
+
+OBJECTS= md4.o md5.o 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
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.rootfs
+
+LIBS =		$(DYNLIB) $(LINTLIB)
+SRCS = \
+	$(COMDIR)/md4/md4.c \
+	$(COMDIR)/md5/md5.c \
+	$(COMDIR)/sha1/sha1.c \
+	$(COMDIR)/sha2/sha2.c
+
+COMDIR= $(SRC)/common/crypto
+
+$(LINTLIB) :=	SRCS = $(SRCDIR)/$(LINTSRC)
+LDLIBS +=	-lc
+
+SRCDIR =	../common
+COMDIR =	$(SRC)/common/crypto
+MAPDIR =	../spec/$(TRANSMACH)
+SPECMAPFILE =	$(MAPDIR)/mapfile
+
+CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
+CFLAGS64 += $(C_BIGPICFLAGS)
+CPPFLAGS += -I$(SRCDIR)
+
+# The md5 and sha1 code is very careful about data alignment
+# but lint doesn't know that, so just shut lint up.
+LINTFLAGS += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
+LINTFLAGS64 += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
+
+
+ROOTLINT= $(LINTSRC:%=$(ROOTLIBDIR)/%)
+
+.KEEP_STATE:
+
+all: $(LIBS) fnamecheck
+
+lint: lintcheck
+
+pics/%.o: $(COMDIR)/md4/%.c
+	$(COMPILE.c) -I$(COMDIR)/md4 -o $@ $<
+	$(POST_PROCESS_O)
+
+pics/%.o: $(COMDIR)/md5/%.c
+	$(COMPILE.c) -I$(COMDIR)/md5 $(INLINES) -o $@ $<
+	$(POST_PROCESS_O)
+
+pics/%.o: $(COMDIR)/sha1/%.c
+	$(COMPILE.c) -I$(COMDIR)/sha1 -o $@ $<
+	$(POST_PROCESS_O)
+
+pics/%.o: $(COMDIR)/sha1/sparc/$(PLATFORM)/sha1_asm.s
+	$(COMPILE.s) -P -DPIC -D_ASM -o $@ $<
+	$(POST_PROCESS_O)
+
+pics/%.o: $(COMDIR)/sha2/%.c
+	$(COMPILE.c) -I$(COMDIR)/sha2 -o $@ $<
+	$(POST_PROCESS_O)
+
+#
+# Used when building links in /platform/$(PLATFORM)/lib for libmd_psr.so.1
+#
+
+LIBMD_PSR_DIRS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib)
+LIBMD_PSR_LINKS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MODULE))
+
+LIBMD_PSR64_DIRS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MACH64))
+LIBMD_PSR64_LINKS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MACH64)/$(MODULE))
+
+INS.slink6 = $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/lib/$(MODULE) $@ $(CHOWNLINK) $(CHGRPLINK)
+
+INS.slink64 = $(RM) -r $@; $(SYMLINK) ../../../$(PLATFORM)/lib/$(MACH64)/$(MODULE) $@ $(CHOWNLINK) $(CHGRPLINK)
+
+$(LIBMD_PSR_DIRS):
+	-$(INS.dir.root.bin)
+
+$(LIBMD_PSR_LINKS): $(LIBMD_PSR_DIRS)
+	-$(INS.slink6)
+
+$(LIBMD_PSR64_DIRS):
+	-$(INS.dir.root.bin)
+
+$(LIBMD_PSR64_LINKS): $(LIBMD_PSR64_DIRS)
+	-$(INS.slink64)
+
+include $(SRC)/lib/Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/amd64/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+LIBRARY= libmd.a
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/common/llib-lmd	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,34 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* LINTLIBRARY */
+/* PROTOLIB1 */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <md5.h>
+#include <sha1.h>
+#include <sha2.h>
+#include <md4.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/common/md4.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef	__MD4_H
+#define	__MD4_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+
+/*
+ * MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
+ */
+
+/*
+ * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD4 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/* MD4 context. */
+typedef struct {
+	ulong_t state[4];	/* state (ABCD) */
+	ulong_t count[2];	/* number of bits, modulo 2^64 (lsb first) */
+	unsigned char buffer[64];	/* input buffer */
+} MD4_CTX;
+
+void MD4Init(MD4_CTX *);
+void MD4Update(MD4_CTX *, const void *_RESTRICT_KYWD, size_t);
+void MD4Final(void *, MD4_CTX *);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* __MD4_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/common/md5.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _MD5_H
+#define	_MD5_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+/*
+ * MD5.H - header file for MD5C.C
+ */
+
+/*
+ * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ * rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD5 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+
+#include <sys/md5.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void md5_calc(void *, const void*, unsigned int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* _MD5_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/common/sha1.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,34 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SHA1_H
+#define	_SHA1_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <sys/sha1.h>
+
+#endif	/* _SHA1_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/common/sha2.h	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,34 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SHA2_H
+#define	_SHA2_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <sys/sha2.h>
+
+#endif	/* _SHA2_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/i386/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+LIBRARY= libmd.a
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/inc.flg	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#ident	"%Z%%M%	%I%	%E% SMI"
+
+find_files "s.*" usr/src/common/crypto/md4
+find_files "s.*" usr/src/common/crypto/md5
+find_files "s.*" usr/src/common/crypto/sha1
+find_files "s.*" usr/src/common/crypto/sha2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+
+LIBRARY= libmd.a
+
+include ../Makefile.com
+
+DYNFLAGS += -Wl,-f/platform/\$$PLATFORM/lib/$(DYNLIBPSR)
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+
+LIBRARY= libmd.a
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+DYNFLAGS += -Wl,-f/platform/\$$PLATFORM/lib/$(MACH64)/$(DYNLIBPSR)
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,29 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+include $(SRC)/lib/Makefile.spec.arch
+
+$(SPARC_BLD)SUBDIRS += sun4u sun4v
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/Makefile.targ	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+LIBRARY= libmd.a
+VERS= .1
+
+OBJECTS= md.o
+
+SPECCPP += -I../../
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/amd64/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,35 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+include $(SRC)/lib/Makefile.spec
+
+.KEEP_STATE:
+
+install: $(ROOTABILIB64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/i386/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,34 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd5/spec/i386/Makefile
+#
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/md.spec	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,192 @@
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+function	MD5Init
+include		<md5.h>
+declaration	void MD5Init(MD5_CTX *context)
+version		SUNW_1.1
+end
+
+function	MD5Update
+include		<md5.h>
+declaration	void MD5Update(MD5_CTX *context, \
+				const void *input, \
+				unsigned int inputLen)
+version		SUNW_1.1
+end
+
+function	MD5Final
+include		<md5.h>
+declaration	void MD5Final(void *digest, MD5_CTX *context)
+version		SUNW_1.1
+end
+
+function	md5_calc
+declaration	void md5_calc(void *output, \
+				const void *input, \
+				unsigned int inlen)
+version		SUNW_1.1
+end
+
+function	SHA1Init
+include		<sha1.h>
+declaration	void SHA1Init(SHA1_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA1Update
+include		<sha1.h>
+declaration	void SHA1Update(SHA1_CTX *context, \
+				const void *input, \
+				unsigned int inputLen)
+version		SUNW_1.1
+end
+
+function	SHA1Final
+include		<sha1.h>
+declaration	void SHA1Final(void *, SHA1_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA1Init
+include		<sha1.h>
+declaration	void SHA1Init(SHA1_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA1Update
+include		<sha1.h>
+declaration	void SHA1Update(SHA1_CTX *context, \
+				const void *input, \
+				unsigned int inputLen)
+version		SUNW_1.1
+end
+
+function	SHA1Final
+include		<sha1.h>
+declaration	void SHA1Final(void *digest, SHA1_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA2Init
+include		<sha2.h>
+declaration	void SHA2Init(uint64_t mech, SHA2_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA2Update
+include		<sha2.h>
+declaration	void SHA2Update(SHA2_CTX *context, \
+				const void *input, \
+				size_t inputLen)
+version		SUNW_1.1
+end
+
+function	SHA2Final
+include		<sha2.h>
+declaration	void SHA2Final(void *digest, SHA2_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA256Init
+include		<sha2.h>
+declaration	void SHA2Init(uint64_t mech, SHA2_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA256Update
+include		<sha2.h>
+declaration	void SHA2Update(SHA2_CTX *context, \
+				const void *input, \
+				size_t inputLen)
+version		SUNW_1.1
+end
+
+function	SHA256Final
+include		<sha2.h>
+declaration	void SHA256Final(void *digest, SHA256_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA384Init
+include		<sha2.h>
+declaration	void SHA384Init(uint64_t mech, SHA384_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA384Update
+include		<sha2.h>
+declaration	void SHA384Update(SHA384_CTX *context, \
+				const void *input, \
+				size_t inputLen)
+version		SUNW_1.1
+end
+
+function	SHA384Final
+include		<sha2.h>
+declaration	void SHA384Final(void *digest, SHA384_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA512Init
+include		<sha2.h>
+declaration	void SHA512Init(uint64_t mech, SHA512_CTX *context)
+version		SUNW_1.1
+end
+
+function	SHA512Update
+include		<sha2.h>
+declaration	void SHA512Update(SHA512_CTX *context, \
+				const void *input, \
+				size_t inputLen)
+version		SUNW_1.1
+end
+
+function	SHA512Final
+include		<sha2.h>
+declaration	void SHA512Final(void *digest, SHA512_CTX *context)
+version		SUNW_1.1
+end
+
+function	MD4Init
+include		<md4.h>
+declaration	void MD4Init(MD4_CTX *context)
+version		SUNW_1.1
+end
+
+function	MD4Update
+include		<md4.h>
+declaration	void MD4Update(MD4_CTX *context, \
+				const void *input, \
+				unsigned int inputLen)
+version		SUNW_1.1
+end
+
+function	MD4Final
+include		<md4.h>
+declaration	void MD4Final(void *digest, MD4_CTX *context)
+version		SUNW_1.1
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,35 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd/spec/sparcv9/Makefile
+#
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/spec/versions	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,37 @@
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+sparc {
+	SUNW_1.1;
+}
+sparcv9 {
+	SUNW_1.1;
+}
+i386 {
+	SUNW_1.1;
+}
+amd64 {
+	SUNW_1.1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+include $(SRC)/Makefile.master
+
+SUBDIRS= $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all :=		TARGET= all
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+lint :=		TARGET= lint
+install :=	TARGET= install
+
+.KEEP_STATE:
+
+.PARALLEL: $(MACH) $(MACH64)
+
+all clean clobber lint install: $(SUBDIRS)
+
+$(MACH) $(MACH64): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,42 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+LIBRARY= libmd_psr.a
+
+include $(SRC)/Makefile.psm
+include ../Makefile.links
+include ../../Makefile.com
+
+LIBS= $(DYNLIB)
+
+CFLAGS += -xarch=v8plusa
+CPPFLAGS += -D$(PLATFORM) -DVIS_SHA1
+ASFLAGS	= -P $(ASDEFS)
+
+INLINES= $(COMDIR)/md5/$(MACH)/$(PLATFORM)/byteswap.il
+
+# XXX This seems wrong since we explicitly set LIBS to be DYNLIB only
+$(LINTLIB):= SRCS= ../../common/llib-lmd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/Makefile.links	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,66 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd/Makefile.sun4u.links
+#
+#
+# Used when building links in /platform/sun4u/lib 
+#
+LINKED_PLATFORMS	= SUNW,Ultra-2
+LINKED_PLATFORMS	+= SUNW,Ultra-4
+LINKED_PLATFORMS	+= SUNW,Ultra-5_10
+LINKED_PLATFORMS	+= SUNW,Ultra-30
+LINKED_PLATFORMS	+= SUNW,Ultra-60
+LINKED_PLATFORMS	+= SUNW,Ultra-80
+LINKED_PLATFORMS	+= SUNW,Ultra-250
+LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise
+LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise-10000
+LINKED_PLATFORMS	+= SUNW,UltraAX-i2
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIi-Netract
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-40
+LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-60
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-100
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-1000
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-1500
+LINKED_PLATFORMS	+= SUNW,Sun-Blade-2500
+LINKED_PLATFORMS	+= SUNW,A70
+LINKED_PLATFORMS	+= SUNW,Sun-Fire
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V215
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V240
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V250
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V440
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V445
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-280R
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-15000
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-880
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-480R
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V890
+LINKED_PLATFORMS	+= SUNW,Sun-Fire-V490
+LINKED_PLATFORMS	+= SUNW,Serverblade1
+LINKED_PLATFORMS	+= SUNW,Netra-T12
+LINKED_PLATFORMS	+= SUNW,Netra-T4
+LINKED_PLATFORMS	+= SUNW,Netra-CP2300
+LINKED_PLATFORMS	+= SUNW,Netra-CP3010
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,58 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+CLASS		= 32
+PLATFORM	= sun4u
+MODULE		= libmd_psr.so.1
+
+include	../Makefile.com
+
+# Override OBJECTS here because each $MACH/$PLATFORM can have a different
+# set of algortithm optimisations and thus different source and object files.
+OBJECTS		= md5.o sha1.o sha1_asm.o
+
+SPECMAPFILE=
+MAPFILE=	mapfile
+DYNFLAGS +=	-M$(MAPFILE)
+
+ASFLAGS	+=	-xarch=v8plusa -warn
+
+# Redefine shared object build rule to use $(LD) directly (this avoids .init
+# and .fini sections being added).
+ 
+BUILD.SO=	$(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(LDLIBS)
+
+$(DYNLIB):	$(MAPFILE)
+
+.KEEP_STATE:
+
+all:		$(LIBS)
+
+$(ROOT_PSM_LIB_DIR)/% := FILEMODE = 755
+
+install:	all $(LIBMD_PSR_LINKS) $(ROOT_PSM_LIBS)
+
+include $(SRC)/Makefile.psm.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/sparc/mapfile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,37 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+SUNW_1.1 {
+	global:
+		MD5Init;
+		MD5Update;
+		MD5Final;
+		SHA1Init;
+		SHA1Update;
+		SHA1Final;
+	local:
+		*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,60 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+CLASS		= 64
+PLATFORM	= sun4u
+MODULE		= libmd_psr.so.1
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+# Override OBJECTS here because each $MACH/$PLATFORM can have a different
+# set of algortithm optimisations and thus different source and object files.
+OBJECTS		= md5.o sha1.o sha1_asm.o
+
+SPECMAPFILE=
+MAPFILE=	mapfile
+DYNFLAGS +=	-M$(MAPFILE)
+
+ASDEFS +=	-D__sparcv9
+ASFLAGS	+=	-xarch=v9a $(AS_BIGPICFLAGS)
+
+# Redefine shared object build rule to use $(LD) directly (this avoids .init
+# and .fini sections being added).
+ 
+BUILD.SO=	$(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(LDLIBS)
+
+$(DYNLIB):	$(MAPFILE)
+
+.KEEP_STATE:
+
+all:		$(LIBS)
+
+$(ROOT_PSM_LIB64_DIR)/% := FILEMODE = 755
+
+install:	all $(LIBMD_PSR64_LINKS) $(ROOT_PSM_LIB64_DIR)/$(LIBS)
+
+include $(SRC)/Makefile.psm.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4u/sparcv9/mapfile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,37 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+SUNW_1.1 {
+	global:
+		MD5Init;
+		MD5Update;
+		MD5Final;
+		SHA1Init;
+		SHA1Update;
+		SHA1Final;
+	local:
+		*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+include $(SRC)/Makefile.master
+
+SUBDIRS= $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all :=		TARGET= all
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+lint :=		TARGET= lint
+install :=	TARGET= install
+
+.KEEP_STATE:
+
+.PARALLEL: $(MACH) $(MACH64)
+
+all clean clobber lint install: $(SUBDIRS)
+
+$(MACH) $(MACH64): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,42 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+LIBRARY= libmd_psr.a
+
+include $(SRC)/Makefile.psm
+include ../Makefile.links
+include ../../Makefile.com
+
+LIBS= $(DYNLIB)
+
+CFLAGS += -xarch=v8plusa
+CPPFLAGS += -D$(PLATFORM)
+ASFLAGS	= -P $(ASDEFS)
+
+INLINES= $(COMDIR)/md5/$(MACH)/$(PLATFORM)/byteswap.il
+
+# XXX This seems wrong since we explicitly set LIBS to be DYNLIB only
+$(LINTLIB):= SRCS= ../../common/llib-lmd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/Makefile.links	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# lib/libmd/Makefile.sun4v.links
+#
+#
+# Used when building links in /platform/sun4v/lib 
+#
+LINKED_PLATFORMS	= SUNW,Sun-Fire-T200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,58 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+CLASS		= 32
+PLATFORM	= sun4v
+MODULE		= libmd_psr.so.1
+
+include ../Makefile.com
+
+# Override OBJECTS here because each $MACH/$PLATFORM can have a different
+# set of algortithm optimisations and thus different source and object files.
+OBJECTS		= md5.o
+
+SPECMAPFILE=
+MAPFILE=	mapfile
+DYNFLAGS +=	-M$(MAPFILE)
+
+ASFLAGS	+=	-xarch=v8plusa -warn
+
+# Redefine shared object build rule to use $(LD) directly (this avoids .init
+# and .fini sections being added).
+ 
+BUILD.SO=	$(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(LDLIBS)
+
+$(DYNLIB):	$(MAPFILE)
+
+.KEEP_STATE:
+
+all:		$(LIBS)
+
+$(ROOT_PSM_LIB_DIR)/% := FILEMODE = 755
+
+install:	all $(LIBMD_PSR_LINKS) $(ROOT_PSM_LIBS)
+
+include $(SRC)/Makefile.psm.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/sparc/mapfile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+SUNW_1.1 {
+	global:
+		MD5Init;
+		MD5Update;
+		MD5Final;
+	local:
+		*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,60 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+CLASS		= 64
+PLATFORM	= sun4v
+MODULE		= libmd_psr.so.1
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+# Override OBJECTS here because each $MACH/$PLATFORM can have a different
+# set of algortithm optimisations and thus different source and object files.
+OBJECTS		= md5.o
+
+SPECMAPFILE=
+MAPFILE=	mapfile
+DYNFLAGS +=	-M$(MAPFILE)
+
+ASDEFS +=	-D__sparcv9
+ASFLAGS	+=	-xarch=v9a $(AS_PICFLAGS)
+
+# Redefine shared object build rule to use $(LD) directly (this avoids .init
+# and .fini sections being added).
+ 
+BUILD.SO=	$(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(LDLIBS)
+
+$(DYNLIB):	$(MAPFILE)
+
+.KEEP_STATE:
+
+all:		$(LIBS)
+
+$(ROOT_PSM_LIB64_DIR)/% := FILEMODE = 755
+
+install:	all $(LIBMD_PSR64_LINKS) $(ROOT_PSM_LIB64_DIR)/$(LIBS)
+
+include $(SRC)/Makefile.psm.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd/sun4v/sparcv9/mapfile	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+SUNW_1.1 {
+	global:
+		MD5Init;
+		MD5Update;
+		MD5Final;
+	local:
+		*;
+};
--- a/usr/src/lib/libmd5/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libmd5/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -19,34 +18,31 @@
 #
 # CDDL HEADER END
 #
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
 # lib/libmd5/Makefile
-#
 
 include $(SRC)/Makefile.master
 
-SUBDIRS= spec .WAIT $(MACH) $(BUILD64) $(MACH64)
+SUBDIRS= $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
 
 all :=		TARGET= all
 clean :=	TARGET= clean
 clobber :=	TARGET= clobber
-lint :=		TARGET= lint
 install :=	TARGET= install
 
 .KEEP_STATE:
 
 .PARALLEL: $(MACH) $(MACH64)
 
-all clean clobber lint install: $(SUBDIRS)
+all clean clobber install: $(SUBDIRS)
 
-spec $(MACH) $(MACH64): FRC
+$(SUBDIRS):	FRC
 	@cd $@; pwd; $(MAKE) $(TARGET)
 
-_msg install_h check:
-
 FRC:
--- a/usr/src/lib/libmd5/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libmd5/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -31,51 +30,31 @@
 LIBRARY= libmd5.a
 VERS= .1
 
-OBJECTS= md5.o
-COMMON= $(SRC)/common/crypto/md5
-
 include ../../Makefile.lib
-
-# install this library in the root filesystem
 include ../../Makefile.rootfs
 
-LIBS= $(DYNLIB) $(LINTLIB)
+MAPFILES=       $(SRCDIR)/mapfile-vers $(MAPFILE-FLTR)
+MAPOPTS=        $(MAPFILES:%=-M %)
 
-# Macros to help build the shared object
-MAPFILE= $(MAPDIR)/mapfile
-DYNFLAGS += -M$(MAPFILE)
-CPPFLAGS += -D__RESTRICT
-CFLAGS += $(CCVERBOSE)
+DYNFLAGS +=     -F libmd.so.1 $(MAPOPTS)
 
-DYNFLAGS +=	$(BDIRECT)
-LDLIBS +=	-lc
+LIBS =          $(DYNLIB) $(LINTLIB)
 
-# Macros to help build the lint library
-LINTSRC= $(LINTLIB:%.ln=%)
-$(LINTLIB) := SRCS= ../$(LINTSRC)
-SRCS= $(OBJECTS:%.o=$(COMMON)/%.c)
-ROOTLINT= $(LINTSRC:%=$(ROOTLIBDIR)/%)
-$(ROOTLIBDIR)/%: ../%
-	$(INS.file)
+SRCDIR =        ../common
+$(LINTLIB) :=   SRCS = $(SRCDIR)/llib-lmd5
+
 
-# The md5 code is very careful about data alignment
-# but lint doesn't know that, so just shut lint up.
-lint := LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN
-lint := LINTFLAGS64 += -erroff=E_BAD_PTR_CAST_ALIGN
+# Redefine shared object build rule to use $(LD) directly (this avoids .init
+# and .fini sections being added).  Also, since there are no OBJECTS, turn
+# off CTF.
+
+BUILD.SO=       $(LD) -o $@ -G $(DYNFLAGS)
+CTFMERGE_LIB=   :
 
 .KEEP_STATE:
 
-$(DYNLIB): $(MAPFILE)
-
-$(MAPFILE):
-	@cd $(MAPDIR); pwd; $(MAKE) mapfile
-
-all: $(LIBS) fnamecheck
+all: $(LIBS)
 
-lint: lintcheck
-
-include $(SRC)/lib/Makefile.targ
+include ../../Makefile.targ
 
-pics/%.o: $(COMMON)/%.c
-	$(COMPILE.c) -o $@ $<
-	$(POST_PROCESS_O)
+$(DYNLIB):      $(MAPFILES)
--- a/usr/src/lib/libmd5/amd64/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libmd5/amd64/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -25,9 +24,12 @@
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
+# lib/libmd5/amd64/Makefile
+#
 
-MAPDIR= ../spec/amd64
 include ../Makefile.com
-include $(SRC)/lib/Makefile.lib.64
+include ../../Makefile.lib.64
+
+BUILD.SO=	$(LD) -o $@ -G -64 $(DYNFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd5/common/llib-lmd5	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* LINTLIBRARY */
+/* PROTOLIB1 */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <md5.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libmd5/common/mapfile-vers	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,42 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+
+#
+# DO NOT TOUCH THIS FILE.
+# This file declares interfaces that are cast in stone.
+# The real interface is now libmd, libmd5 is just a filter library
+# for legacy reasons.
+# They offer interfaces that will never change.
+# DO NOT TOUCH THIS FILE.
+#
+
+
+SUNW_1.1 {
+	global:
+		MD5Init = FUNCTION;
+		MD5Update = FUNCTION;
+		MD5Final = FUNCTION;
+		md5_calc = FUNCTION;
+};
--- a/usr/src/lib/libmd5/llib-lmd5	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* LINTLIBRARY */
-/* PROTOLIB1 */
-
-/*
- * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/types.h>
-#include <md5.h>
-
-void MD5Init(MD5_CTX *);
-void MD5Update(MD5_CTX *, const void *, unsigned int);
-void MD5Final(unsigned char [16], MD5_CTX *);
-void md5_calc(unsigned char *, unsigned char *, unsigned int);
--- a/usr/src/lib/libmd5/sparc/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libmd5/sparc/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -28,9 +27,6 @@
 # lib/libmd5/sparc/Makefile
 #
 
-MAPDIR= ../spec/sparc
 include ../Makefile.com
 
-DYNFLAGS += -Wl,-f/platform/\$$PLATFORM/lib/$(DYNLIBPSR)
-
 install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- a/usr/src/lib/libmd5/sparcv9/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libmd5/sparcv9/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -28,10 +27,9 @@
 # lib/libmd5/sparcv9/Makefile
 #
 
-MAPDIR= ../spec/sparcv9
 include ../Makefile.com
-include $(SRC)/lib/Makefile.lib.64
+include ../../Makefile.lib.64
 
-DYNFLAGS += -Wl,-f/platform/\$$PLATFORM/lib/sparcv9/$(DYNLIBPSR)
+BUILD.SO=	$(LD) -o $@ -G -64 $(DYNFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
--- a/usr/src/lib/libmd5/spec/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5/spec/Makefile
-#
-
-include $(SRC)/lib/Makefile.spec.arch
--- a/usr/src/lib/libmd5/spec/Makefile.targ	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5/spec/Makefile.targ
-#
-
-LIBRARY= libmd5.a
-VERS= .1
-
-OBJECTS= md5.o
-
-SPECCPP += -I../../
--- a/usr/src/lib/libmd5/spec/amd64/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-include ../Makefile.targ
-
-# Add arch specific objects here
-OBJECTS +=
-
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/lib/Makefile.lib.64
-
-# Uncomment the following if the linker complains
-#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS)
-
-include $(SRC)/lib/Makefile.spec
-
-.KEEP_STATE:
-
-install: $(ROOTABILIB64)
--- a/usr/src/lib/libmd5/spec/i386/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5/spec/i386/Makefile
-#
-
-include ../Makefile.targ
-
-# Add arch specific objects here
-OBJECTS +=
-
-include $(SRC)/lib/Makefile.lib
-
-# Uncomment the following if the linker complains
-#i386_C_PICFLAGS  = -K PIC
-
-include $(SRC)/lib/Makefile.spec
-
-.KEEP_STATE:
-
-install: $(ROOTABILIB)
--- a/usr/src/lib/libmd5/spec/md5.spec	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# lib/libmd5/spec/md5.spec
-#
-
-function	MD5Init
-include		<md5.h>
-declaration	void MD5Init(MD5_CTX *context)
-version		SUNW_1.1
-end
-
-function	MD5Update
-include		<md5.h>
-declaration	void MD5Update(MD5_CTX *context, \
-				const void *input, \
-				unsigned int inputLen)
-version		SUNW_1.1
-end
-
-function	MD5Final
-include		<md5.h>
-declaration	void MD5Final(unsigned char digest[16], MD5_CTX *context)
-version		SUNW_1.1
-end
-
-function	md5_calc
-declaration	void md5_calc(unsigned char *output, \
-				unsigned char *input, \
-				unsigned int inlen)
-version		SUNW_1.1
-end
--- a/usr/src/lib/libmd5/spec/sparc/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5/spec/sparc/Makefile
-#
-
-include ../Makefile.targ
-
-# Add arch specific objects here
-OBJECTS +=
-
-include $(SRC)/lib/Makefile.lib
-
-# Uncomment the following if the linker complains
-#sparc_C_PICFLAGS  = -K PIC
-
-include $(SRC)/lib/Makefile.spec
-
-.KEEP_STATE:
-
-install: $(ROOTABILIB)
--- a/usr/src/lib/libmd5/spec/sparcv9/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5/spec/sparcv9/Makefile
-#
-
-include ../Makefile.targ
-
-# Add arch specific objects here
-OBJECTS +=
-
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/lib/Makefile.lib.64
-
-# Uncomment the following if the linker complains
-#sparcv9_C_PICFLAGS  = -K PIC
-
-include $(SRC)/lib/Makefile.spec
-
-.KEEP_STATE:
-
-install: $(ROOTABILIB64)
--- a/usr/src/lib/libmd5/spec/versions	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-sparc {
-	SUNW_1.1;
-}
-sparcv9 {
-	SUNW_1.1;
-}
-i386 {
-	SUNW_1.1;
-}
-amd64 {
-	SUNW_1.1;
-}
--- a/usr/src/lib/libmd5_psr/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/Makefile
-#
-
-include $(SRC)/Makefile.master
-
-SUBDIRS= spec .WAIT $(MACH) $(BUILD64) $(MACH64)
-
-all :=		TARGET= all
-clean :=	TARGET= clean
-clobber :=	TARGET= clobber
-install :=	TARGET= install
-
-.KEEP_STATE:
-
-.PARALLEL: $(MACH) $(MACH64)
-
-all clean clobber install: $(SUBDIRS)
-
-spec $(MACH) $(MACH64): FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
-
-#
-# Empty targets.
-# lint is an empty target since md5.c is already linted
-# up and down in the kernel and a lint library is already
-# created in lib/libmd5.
-#
-_msg install_h check lint:
-
-FRC:
--- a/usr/src/lib/libmd5_psr/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# lib/libmd5_psr/Makefile.com
-#
-
-#
-# Create default so empty rules don't confuse make
-#
-CLASS= 32
-
-LIBRARY= libmd5_psr.a
-VERS= .1
-
-OBJECTS= md5.o
-COMMON= $(SRC)/common/crypto/md5
-
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/Makefile.psm
-
-#
-# Macros to help build the shared object
-#
-LIBS= $(DYNLIB)
-DYNFLAGS += $(BDIRECT)
-LDLIBS += -lc
-CPPFLAGS += -D__RESTRICT
-
-#
-# Macros for the mapfile. Other makefiles need to include this file
-# after setting MAPDIR
-#
-MAPFILE=	$(MAPDIR)/mapfile-$(PLATFORM)
-DYNFLAGS +=	-M$(MAPFILE)
-CLOBBERFILES +=	$(MAPFILE)
-
-#
-# Used when building links in /platform/$(PLATFORM)/lib 
-#
-LINKED_PLATFORMS	= SUNW,Ultra-2
-LINKED_PLATFORMS	+= SUNW,Ultra-4
-LINKED_PLATFORMS	+= SUNW,Ultra-5_10
-LINKED_PLATFORMS	+= SUNW,Ultra-30
-LINKED_PLATFORMS	+= SUNW,Ultra-60
-LINKED_PLATFORMS	+= SUNW,Ultra-80
-LINKED_PLATFORMS	+= SUNW,Ultra-250
-LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise
-LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise-10000
-LINKED_PLATFORMS	+= SUNW,UltraAX-i2
-LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIi-Netract
-LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-40
-LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-60
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-100
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-1000
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-1500
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-2500
-LINKED_PLATFORMS	+= SUNW,A70
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V445
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V215
-LINKED_PLATFORMS	+= SUNW,Sun-Fire
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V240
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V250
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V440
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-280R
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-15000
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-880
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-480R
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V890
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V490
-LINKED_PLATFORMS	+= SUNW,Serverblade1
-LINKED_PLATFORMS	+= SUNW,Netra-T12
-LINKED_PLATFORMS	+= SUNW,Netra-T4
-LINKED_PLATFORMS	+= SUNW,Netra-CP2300
-LINKED_PLATFORMS	+= SUNW,Netra-CP3010
-
-.KEEP_STATE:
--- a/usr/src/lib/libmd5_psr/Makefile.targ	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/Makefile.targ
-#
-
-#
-# This makefile defines common targets. Other makefiles should
-# include this after defining default targets.
-#
-
-include $(SRC)/lib/Makefile.targ
-include $(SRC)/Makefile.psm.targ
-
-INLINES= $(COMMON)/$(MACH)/$(PLATFORM)/byteswap.il
-
-$(MAPFILE):
-	@cd $(MAPDIR); pwd; $(MAKE) $(TARGET)
-
-pics/%.o: $(COMMON)/%.c $(INLINES)
-	$(COMPILE.c) $(INLINES) -o $@ $<
-	$(POST_PROCESS_O)
-
-$(DYNLIB):	$(MAPFILE)
--- a/usr/src/lib/libmd5_psr/inc.flg	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-
-find_files "s.*" usr/src/common/crypto/md5
--- a/usr/src/lib/libmd5_psr/sparc/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/sparc/Makefile
-#
-
-SUBDIRS= sun4u
-
-all :=		TARGET= all
-install :=	TARGET= install
-clean :=	TARGET= clean
-clobber :=	TARGET= clobber
-
-.KEEP_STATE:
-
-all install clean clobber : $(SUBDIRS)
-
-$(SUBDIRS): FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
--- a/usr/src/lib/libmd5_psr/sparc/sun4u/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Platform specific Makefile for libmd5_psr.
-#
-# PLATFORM is the target for the binary installation.
-#
-PLATFORM = sun4u
-
-MAPDIR = ../../spec/$(MACH)/$(PLATFORM)
-
-include ../../Makefile.com
-
-#
-# Defining sun4u turns on sun4u-specific optimization
-#
-CPPFLAGS += -Dsun4u
-CFLAGS += -xarch=v8plusa
-
-.KEEP_STATE:
-
-#
-# Used when building links in /platform/$(PLATFORM)/lib for libmd5_psr.so.1
-#
-MODULE	= libmd5_psr.so.1
-
-LIBMD5_PSR_DIRS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib)
-LIBMD5_PSR_LINKS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MODULE))
-INS.slink6 = $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/lib/$(MODULE) $@ $(CHOWNLINK) $(CHGRPLINK)
-
-$(LIBMD5_PSR_DIRS):
-	-$(INS.dir.root.bin)
-
-$(LIBMD5_PSR_LINKS): $(LIBMD5_PSR_DIRS)
-	-$(INS.slink6)
-
-all:		$(LIBS)
-
-install:	all $(LIBMD5_PSR_LINKS) $(ROOT_PSM_LIBS)
-
-include	../../Makefile.targ
--- a/usr/src/lib/libmd5_psr/sparcv9/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/sparcv9/Makefile
-#
-SUBDIRS= sun4u
-
-all :=		TARGET= all
-install :=	TARGET= install
-clean :=	TARGET= clean
-clobber :=	TARGET= clobber
-
-.KEEP_STATE:
-
-all install clean clobber : $(SUBDIRS)
-
-$(SUBDIRS): FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
--- a/usr/src/lib/libmd5_psr/sparcv9/sun4u/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Platform specific Makefile for libmd5_psr.
-#
-# PLATFORM is the target for the binary installation.
-#
-PLATFORM = sun4u
-
-MAPDIR = ../../spec/$(MACH64)/$(PLATFORM)
-
-include ../../Makefile.com
-include $(SRC)/Makefile.master.64
-
-#
-# Defining sun4u turns on sun4u-specific optimization
-#
-CPPFLAGS += -Dsun4u
-
-.KEEP_STATE:
-
-MODULE  = libmd5_psr.so.1
-
-LIBMD5_PSR64_DIRS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MACH64))
-LIBMD5_PSR64_LINKS = $(LINKED_PLATFORMS:%=$(ROOT_PLAT_DIR)/%/lib/$(MACH64)/$(MODULE))
-INS.slink7 = $(RM) -r $@; $(SYMLINK) ../../../$(PLATFORM)/lib/$(MACH64)/$(MODULE) $@ $(CHOWNLINK) $(CHGRPLINK)
-
-$(LIBMD5_PSR64_DIRS):
-	-$(INS.dir.root.bin)
-
-$(LIBMD5_PSR64_LINKS): $(LIBMD5_PSR64_DIRS)
-	-$(INS.slink7)
-
-all:		$(LIBS)
-
-install:	all $(LIBMD5_PSR64_LINKS) $(ROOT_PSM_LIB64_DIR)/$(LIBS) 
-
-include ../../Makefile.targ
--- a/usr/src/lib/libmd5_psr/spec/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/spec/Makefile
-
-include	$(SRC)/lib/Makefile.spec.arch
--- a/usr/src/lib/libmd5_psr/spec/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# lib/libmd5_psr/spec/Makefile.com
-
-include $(SRC)/Makefile.psm
-
-MODULE=		abi
-
-#
-# links in /usr/platform
-#
-LINKED_PLATFORMS	= SUNW,Ultra-2
-LINKED_PLATFORMS	+= SUNW,Ultra-4
-LINKED_PLATFORMS	+= SUNW,Ultra-250
-LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise
-LINKED_PLATFORMS	+= SUNW,Ultra-Enterprise-10000
-LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIi-Netract
-LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-40
-LINKED_PLATFORMS	+= SUNW,UltraSPARC-IIe-NetraCT-60
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-100
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-1000
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-1500
-LINKED_PLATFORMS	+= SUNW,Sun-Blade-2500
-LINKED_PLATFORMS	+= SUNW,A70
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V445
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V215
-LINKED_PLATFORMS	+= SUNW,Sun-Fire
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V240
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V250
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V440
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-280R
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-15000
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-880
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-480R
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V890
-LINKED_PLATFORMS	+= SUNW,Sun-Fire-V490
-LINKED_PLATFORMS	+= SUNW,Serverblade1
-LINKED_PLATFORMS	+= SUNW,Netra-T12
-LINKED_PLATFORMS	+= SUNW,Netra-T4
-LINKED_PLATFORMS	+= SUNW,Netra-CP2300
-LINKED_PLATFORMS	+= SUNW,Netra-CP3010
-
-LINKED_DIRS	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%)
-LINKED_LIB_DIRS	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib)
-LINKED_ABI_DIRS	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi)
-LINKED_ABI_DIRS64 = $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi/$(MACH64))
-ABI_LINKS32	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi/abi_$(DYNLIB))
-ABI_LINKS64	= $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/abi/$(MACH64)/abi_$(DYNLIB))
-ABI_LINKS	= $(ABI_LINKS$(CLASS))
-
-links:
-
-FRC:
--- a/usr/src/lib/libmd5_psr/spec/sparc/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/spec/sparc/Makefile
-
-SUBDIRS=	sun4u
-
-all		:=	TARGET= all
-install		:=	TARGET= install
-clean		:=	TARGET= clean
-clobber		:=	TARGET= clobber
-lint		:=	TARGET= lint
-
-.KEEP_STATE:
-
-all install clean clobber lint: $(SUBDIRS)
-
-# spec files do not have msgs or catalogs
-_msg catalog:
-
-$(SUBDIRS): FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
--- a/usr/src/lib/libmd5_psr/spec/sparc/md5_psr-sun4u.spec	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# lib/libmd5_psr/spec/sparc/md5_psr-sun4u.spec
-#
-
-function	MD5Init extends libmd5/spec/md5.spec
-arch		sparc
-version		SUNWprivate_1.1
-end
-
-function	MD5Update extends libmd5/spec/md5.spec
-arch		sparc
-version		SUNWprivate_1.1
-end
-
-function	MD5Final extends libmd5/spec/md5.spec
-arch		sparc
-version		SUNWprivate_1.1
-end
-
-function	md5_calc extends libmd5/spec/md5.spec
-arch		sparc
-version		SUNWprivate_1.1
-end
--- a/usr/src/lib/libmd5_psr/spec/sparc/sun4u/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# lib/libmd5_psr/sparc/spec/sun4u/Makefile
-
-.KEEP_STATE:
-
-LIBRARY	=	libmd5_psr.a
-VERS	=	.1
-
-PLATFORM=	sun4u
-CLASS=		32
-
-OBJECTS	=	md5_psr-$(PLATFORM).o
-
-SPECVERS =	-$(PLATFORM)
-
-include	$(SRC)/lib/Makefile.lib
-
-# Uncomment the following if the linker complains
-#sparc_C_PICFLAGS  = -K PIC
-
-include	$(SRC)/lib/Makefile.spec
-include $(SRC)/lib/Makefile.spec.psm
-include $(SRC)/lib/libmd5_psr/spec/Makefile.com
-
-install:
--- a/usr/src/lib/libmd5_psr/spec/sparc/versions-sun4u	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# lib/libmd5_psr/spec/sparc/versions-sun4u
-#
-
-sparc {
-	SUNWprivate_1.1;
-}
--- a/usr/src/lib/libmd5_psr/spec/sparcv9/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# lib/libmd5_psr/spec/sparcv9/Makefile
-
-SUBDIRS=	sun4u
-
-all		:=	TARGET= all
-install		:=	TARGET= install
-clean		:=	TARGET= clean
-clobber		:=	TARGET= clobber
-lint		:=	TARGET= lint
-
-.KEEP_STATE:
-
-all install clean clobber lint: $(SUBDIRS)
-
-# spec files do not have msgs or catalogs
-_msg catalog:
-
-$(SUBDIRS): FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
--- a/usr/src/lib/libmd5_psr/spec/sparcv9/md5_psr-sun4u.spec	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# lib/libmd5_psr/spec/sparcv9/md5_psr-sun4u.spec
-#
-
-function	MD5Init extends libmd5/spec/md5.spec
-arch		sparcv9
-version		SUNWprivate_1.1
-end
-
-function	MD5Update extends libmd5/spec/md5.spec
-arch		sparcv9
-version		SUNWprivate_1.1
-end
-
-function	MD5Final extends libmd5/spec/md5.spec
-arch		sparcv9
-version		SUNWprivate_1.1
-end
-
-function	md5_calc extends libmd5/spec/md5.spec
-arch		sparcv9
-version		SUNWprivate_1.1
-end
--- a/usr/src/lib/libmd5_psr/spec/sparcv9/sun4u/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# lib/libmd5_psr/sparcv9/spec/sun4u/Makefile
-
-.KEEP_STATE:
-
-LIBRARY	=	libmd5_psr.a
-VERS	=	.1
-
-PLATFORM=	sun4u
-CLASS=		64
-
-OBJECTS	=	md5_psr-$(PLATFORM).o
-
-SPECVERS=	-$(PLATFORM)
-
-include	$(SRC)/lib/Makefile.lib
-include	$(SRC)/lib/Makefile.lib.64
-include $(SRC)/lib/libmd5_psr/spec/Makefile.com
-
-# Uncomment the following if the linker complains
-#sparcv9_C_PICFLAGS  = -K PIC
-
-include	$(SRC)/lib/Makefile.spec
-include $(SRC)/lib/Makefile.spec.psm
-
-install:
--- a/usr/src/lib/libmd5_psr/spec/sparcv9/versions-sun4u	Mon Mar 27 18:01:01 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# lib/libmd5_psr/spec/sparcv9/versions-sun4u
-#
-
-sparcv9 {
-	SUNWprivate_1.1;
-}
--- a/usr/src/lib/libnsl/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libnsl/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -207,8 +207,8 @@
 
 CFLAGS +=	-v
 
-LAZYLIBS = $(ZLAZYLOAD) -lmp -lmd5 -lscf $(ZNOLAZYLOAD)
-lint := LAZYLIBS = -lmd5
+LAZYLIBS = $(ZLAZYLOAD) -lmp -lmd -lscf $(ZNOLAZYLOAD)
+lint := LAZYLIBS = -lmd
 LDLIBS +=	$(LAZYLIBS) -lc
 DYNFLAGS +=	$(MAPOPTS)
 
--- a/usr/src/lib/libresolv2/dnssafe/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libresolv2/dnssafe/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -41,7 +41,7 @@
 
 LIBNAME=	$(LIBRARY:%.a=%)
 LIBS=		$(DYNLIB)
-LDLIBS +=	-lmd5 -lresolv -lc
+LDLIBS +=	-lmd -lresolv -lc
 
 MAPDIR =	../spec/$(TRANSMACH)
 SPECMAPFILE =	$(MAPDIR)/mapfile
--- a/usr/src/lib/librt/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/librt/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -47,7 +46,7 @@
 include ../../Makefile.rootfs
 
 LIBS =		$(DYNLIB) $(LINTLIB)
-LDLIBS += 	-laio -lmd5 -lc
+LDLIBS += 	-laio -lmd -lc
 $(LINTLIB) :=	SRCS = $(SRCDIR)/$(LINTSRC)
 
 SRCDIR=		../common
--- a/usr/src/lib/librt/common/pos4obj.c	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/librt/common/pos4obj.c	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -44,7 +43,6 @@
 #include "pos4.h"
 #include "pos4obj.h"
 
-#define	MD5LEN		16
 #define	HASHSTRLEN	32
 
 static	char	*__pos4obj_name(const char *, const char *);
@@ -99,7 +97,7 @@
 	size_t	len;
 	char	*dfile;
 	unsigned char	hashbuf[HASHSTRLEN + 1];
-	unsigned char	md5_digest[MD5LEN];
+	unsigned char	md5_digest[MD5_DIGEST_LENGTH];
 
 	/*
 	 * If the path is path_max - strlen(type) characters or less,
@@ -235,7 +233,7 @@
 	/* LINTED pointer cast may result in improper alignment */
 	p = (uint32_t *)src;
 
-	for (i = 0; i < (MD5LEN / 4); i++)
+	for (i = 0; i < (MD5_DIGEST_LENGTH / 4); i++)
 		(void) snprintf((char *)dest + (i * 8), 9, "%.8x", *p++);
 
 	dest[HASHSTRLEN] = '\0';
--- a/usr/src/lib/libsasl/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libsasl/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -23,7 +23,7 @@
 LIBS=		$(DYNLIB) $(LINTLIB)
 SRCS=		$(SASLOBJS:%.o=../lib/%.c) $(COMMONOBJS:%.o=$(PLUGDIR)/%.c)
 $(LINTLIB):= 	SRCS = $(SRCDIR)/$(LINTSRC)
-LDLIBS +=	-lsocket -lc -lmd5
+LDLIBS +=	-lsocket -lc -lmd
 LINTFLAGS +=	-DPIC
 LINTFLAGS64 +=	-DPIC
 
--- a/usr/src/lib/libwanbootutil/Makefile.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libwanbootutil/Makefile.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -39,7 +38,6 @@
 # The crypto modules are located under usr/src/common.
 CRYPTO_DIR =	$(SRC)/common/net/wanboot/crypt
 CRYPTO_OBJS =	hmac_sha1.o \
-		sha1.o \
 		aes.o \
 		des3.o \
 		des.o \
@@ -52,7 +50,7 @@
 include $(SRC)/lib/Makefile.lib
 
 LIBS +=		$(LINTLIB)
-LDLIBS +=	-lc -lnsl
+LDLIBS +=	-lc -lnsl -lmd
 
 # Must override SRCS from Makefile.lib since sources have
 # multiple source directories.
--- a/usr/src/lib/libwanbootutil/spec/wanbootutil.spec	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/libwanbootutil/spec/wanbootutil.spec	Tue Mar 28 08:45:30 2006 -0800
@@ -1,13 +1,12 @@
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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.
@@ -132,18 +131,6 @@
 version		SUNWprivate_1.1
 end
 
-function	SHA1Init
-version		SUNWprivate_1.1
-end
-
-function	SHA1Update
-version		SUNWprivate_1.1
-end
-
-function	SHA1Final
-version		SUNWprivate_1.1
-end
-
 function	wbio_nwrite
 version		SUNWprivate_1.1
 end
--- a/usr/src/lib/pkcs11/Makefile.softtoken.com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/pkcs11/Makefile.softtoken.com	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -72,8 +71,6 @@
 ARCFOUR_COBJECTS = arcfour_crypt.o
 DES_COBJECTS = des_cbc_crypt.o des_impl.o des_ks.o
 RSA_COBJECTS = rsa_impl.o
-SHA1_COBJECTS = sha1.o
-SHA2_COBJECTS = sha2.o
 BIGNUM_COBJECTS = bignumimpl.o
 
 AES_OBJECTS = $(AES_COBJECTS) $(AES_PSR_OBJECTS)
@@ -127,8 +124,6 @@
 ARCFOURDIR=	$(SRC)/common/crypto/arcfour
 DESDIR=		$(SRC)/common/crypto/des
 RSADIR=		$(SRC)/common/crypto/rsa
-SHA1DIR=	$(SRC)/common/crypto/sha1
-SHA2DIR=	$(SRC)/common/crypto/sha2
 BIGNUMDIR=	$(SRC)/common/bignum
 BERDIR=		../../../libldap5/sources/ldap/ber
 
@@ -152,7 +147,7 @@
 	$(BIGNUM_PSR_SRCS)
 
 LIBS    =       $(DYNLIB)
-LDLIBS  +=      -lc -lmd5
+LDLIBS  +=      -lc -lmd
 
 MAPDIR  = ../spec/$(TRANSMACH)
 SPECMAPFILE = $(MAPDIR)/mapfile
--- a/usr/src/lib/pkcs11/Makefile.softtoken.sparc	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/pkcs11/Makefile.softtoken.sparc	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -33,13 +32,11 @@
 ARCFOUR_PSR_OBJECTS = arcfour_crypt_sparc.o
 DES_PSR_OBJECTS = des_crypt_sparc.o
 RSA_PSR_OBJECTS = 
-SHA1_PSR_OBJECTS = sha1_asm_sparc.o
 BIGNUM_PSR_OBJECTS = mont_mulf_sparc.o
 BIGNUM_CFG = -DUSE_FLOATING_POINT
 
 include ../Makefile.com
 CFLAGS	+=	-Dsun4u
-pics/sha1.o	:=	CFLAGS	+= -DVIS_SHA1
 
 install: all $(ROOTLIBS) $(ROOTLINKS)
 
@@ -59,11 +56,6 @@
 		$(DESDIR)/sun4u/des_crypt_asm.s
 	$(POST_PROCESS_O)
 
-pics/sha1_asm_sparc.o: $(SHA1DIR)/sparc/sun4u/sha1_asm.s
-	$(COMPILE.s) -K PIC -P -DPIC -D_ASM -xarch=v8plusa -o $@ \
-		$(SHA1DIR)/sparc/sun4u/sha1_asm.s
-	$(POST_PROCESS_O)
-
 pics/mont_mulf_sparc.o: $(BIGNUMDIR)/sun4u/mont_mulf_v8plus.s
 	$(COMPILE.s) $(AS_BIGPICFLAGS) -xarch=v8plus -o $@ \
 		$(BIGNUMDIR)/sun4u/mont_mulf_v8plus.s
--- a/usr/src/lib/pkcs11/Makefile.softtoken.sparcv9	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/lib/pkcs11/Makefile.softtoken.sparcv9	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -33,14 +32,12 @@
 ARCFOUR_PSR_OBJECTS = arcfour_crypt_sparcv9.o
 DES_PSR_OBJECTS = des_crypt_sparcv9.o
 RSA_PSR_OBJECTS = 
-SHA1_PSR_OBJECTS = sha1_asm_sparcv9.o
 BIGNUM_PSR_OBJECTS = mont_mulf_sparcv9.o
 BIGNUM_CFG = -DUSE_FLOATING_POINT
 
 include ../Makefile.com
 include ../../../Makefile.lib.64
 CFLAGS64	+=	-Dsun4u
-pics/sha1.o	:=	CFLAGS64	+= -DVIS_SHA1
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
 
@@ -60,11 +57,6 @@
 		$(DESDIR)/sun4u/des_crypt_asm.s
 	$(POST_PROCESS_O)
 
-pics/sha1_asm_sparcv9.o: $(SHA1DIR)/sparc/sun4u/sha1_asm.s
-	$(COMPILE.s) -K PIC -P -DPIC -D_ASM -xarch=v9a -o $@ \
-		$(SHA1DIR)/sparc/sun4u/sha1_asm.s
-	$(POST_PROCESS_O)
-
 pics/mont_mulf_sparcv9.o: $(BIGNUMDIR)/sun4u/mont_mulf_v9.s
 	$(COMPILE.s) $(AS_BIGPICFLAGS) -xarch=v9 -o $@ $(BIGNUMDIR)/sun4u/mont_mulf_v9.s
 	$(POST_PROCESS_O)
--- a/usr/src/pkgdefs/SUNWarcr/prototype_com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWarcr/prototype_com	Tue Mar 28 08:45:30 2006 -0800
@@ -86,6 +86,8 @@
 f none lib/llib-lintl.ln 644 root bin
 f none lib/llib-lkstat 644 root bin
 f none lib/llib-lkstat.ln 644 root bin
+f none lib/llib-lmd 644 root bin
+f none lib/llib-lmd.ln 644 root bin
 f none lib/llib-lmd5 644 root bin
 f none lib/llib-lmd5.ln 644 root bin
 f none lib/llib-lnsl 644 root bin
--- a/usr/src/pkgdefs/SUNWarcr/prototype_i386	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWarcr/prototype_i386	Tue Mar 28 08:45:30 2006 -0800
@@ -71,6 +71,7 @@
 f none lib/amd64/llib-lgen.ln 644 root bin
 f none lib/amd64/llib-lintl.ln 644 root bin
 f none lib/amd64/llib-lkstat.ln 644 root bin
+f none lib/amd64/llib-lmd.ln 644 root bin
 f none lib/amd64/llib-lmd5.ln 644 root bin
 f none lib/amd64/llib-lnsl.ln 644 root bin
 f none lib/amd64/llib-lnvpair.ln 644 root bin
--- a/usr/src/pkgdefs/SUNWarcr/prototype_sparc	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWarcr/prototype_sparc	Tue Mar 28 08:45:30 2006 -0800
@@ -71,6 +71,7 @@
 f none lib/sparcv9/llib-lgen.ln 644 root bin
 f none lib/sparcv9/llib-lintl.ln 644 root bin
 f none lib/sparcv9/llib-lkstat.ln 644 root bin
+f none lib/sparcv9/llib-lmd.ln 644 root bin
 f none lib/sparcv9/llib-lmd5.ln 644 root bin
 f none lib/sparcv9/llib-lnsl.ln 644 root bin
 f none lib/sparcv9/llib-lnvpair.ln 644 root bin
--- a/usr/src/pkgdefs/SUNWcar.u/prototype_com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcar.u/prototype_com	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -169,40 +168,40 @@
 s none platform/SUNW,UltraSPARC-IIe-NetraCT-60/lib/sparcv9/libc_psr.so.1=../../../sun4u/lib/sparcv9/libc_psr.so.1
 s none platform/SUNW,UltraSPARC-IIi-Netract/lib/sparcv9/libc_psr.so.1=../../../sun4u/lib/sparcv9/libc_psr.so.1
 s none platform/SUNW,Netra-CP2300/lib/sparcv9/libc_psr.so.1=../../../sun4u/lib/sparcv9/libc_psr.so.1
-f none platform/sun4u/lib/sparcv9/libmd5_psr.so.1 755 root bin
-s none platform/SUNW,Netra-T12/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Netra-T4/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Serverblade1/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-100/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-1000/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-1500/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-2500/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,A70/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V445/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V215/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Netra-CP3010/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-15000/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-480R/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V240/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V250/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V440/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-280R/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-880/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-2/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-250/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-30/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-4/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-5_10/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-60/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-80/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,UltraAX-i2/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-Enterprise-10000/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Ultra-Enterprise/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,UltraSPARC-IIe-NetraCT-40/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,UltraSPARC-IIe-NetraCT-60/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,UltraSPARC-IIi-Netract/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
-s none platform/SUNW,Netra-CP2300/lib/sparcv9/libmd5_psr.so.1=../../../sun4u/lib/sparcv9/libmd5_psr.so.1
+f none platform/sun4u/lib/sparcv9/libmd_psr.so.1 755 root bin
+s none platform/SUNW,Netra-T12/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Netra-T4/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Serverblade1/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-100/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-1000/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-1500/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-2500/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,A70/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V445/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V215/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Netra-CP3010/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-15000/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-480R/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V240/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V250/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V440/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-280R/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-880/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-2/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-250/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-30/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-4/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-5_10/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-60/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-80/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,UltraAX-i2/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-Enterprise-10000/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Ultra-Enterprise/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,UltraSPARC-IIe-NetraCT-40/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,UltraSPARC-IIe-NetraCT-60/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,UltraSPARC-IIi-Netract/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
+s none platform/SUNW,Netra-CP2300/lib/sparcv9/libmd_psr.so.1=../../../sun4u/lib/sparcv9/libmd_psr.so.1
 #
 # lib/libc_psr.so.1 and links to it for each sun4u platform
 #
@@ -280,39 +279,39 @@
 s none platform/SUNW,UltraSPARC-IIe-NetraCT-60/lib/libc_psr.so.1=../../sun4u/lib/libc_psr.so.1
 s none platform/SUNW,Netra-CP2300/lib/libc_psr.so.1=../../sun4u/lib/libc_psr.so.1
 #
-# lib/libmd5_psr.so.1 and links to it for each sun4u platform
+# lib/libmd_psr.so.1 and links to it for each sun4u platform
 #
-f none platform/sun4u/lib/libmd5_psr.so.1 755 root bin
-s none platform/SUNW,Ultra-2/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-250/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-30/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-4/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-5_10/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-60/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-80/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,UltraAX-i2/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-Enterprise/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Ultra-Enterprise-10000/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Serverblade1/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-100/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-1000/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-1500/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Blade-2500/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,A70/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V445/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V215/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Netra-CP3010/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V240/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V250/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-V440/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-280R/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-15000/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-880/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Sun-Fire-480R/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Netra-T4/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Netra-T12/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,UltraSPARC-IIi-Netract/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,UltraSPARC-IIe-NetraCT-40/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,UltraSPARC-IIe-NetraCT-60/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
-s none platform/SUNW,Netra-CP2300/lib/libmd5_psr.so.1=../../sun4u/lib/libmd5_psr.so.1
+f none platform/sun4u/lib/libmd_psr.so.1 755 root bin
+s none platform/SUNW,Ultra-2/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-250/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-30/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-4/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-5_10/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-60/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-80/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,UltraAX-i2/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-Enterprise/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Ultra-Enterprise-10000/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Serverblade1/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-100/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-1000/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-1500/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Blade-2500/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,A70/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V445/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V215/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Netra-CP3010/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V240/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V250/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-V440/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-280R/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-15000/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-880/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Sun-Fire-480R/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Netra-T4/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Netra-T12/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,UltraSPARC-IIi-Netract/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,UltraSPARC-IIe-NetraCT-40/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,UltraSPARC-IIe-NetraCT-60/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
+s none platform/SUNW,Netra-CP2300/lib/libmd_psr.so.1=../../sun4u/lib/libmd_psr.so.1
--- a/usr/src/pkgdefs/SUNWcar.v/prototype_com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcar.v/prototype_com	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -52,6 +51,8 @@
 d none platform/sun4v/lib/sparcv9 755 root bin
 v none platform/sun4v/lib/sparcv9/libc_psr.so.1 644 root bin
 d none platform/sun4v/lib/sparcv9/libc_psr 755 root bin
+f none platform/sun4v/lib/libmd_psr.so.1 755 root bin
+f none platform/sun4v/lib/sparcv9/libmd_psr.so.1 755 root bin
 d none etc 755 root sys
 d none etc/flash 755 root sys
 d none etc/flash/precreation 700 root sys
--- a/usr/src/pkgdefs/SUNWcsl/prototype_com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcsl/prototype_com	Tue Mar 28 08:45:30 2006 -0800
@@ -163,6 +163,8 @@
 s none usr/ccs/lib/libmalloc.so=../../lib/libmalloc.so.1
 s none usr/lib/libmapmalloc.so=./libmapmalloc.so.1
 f none usr/lib/libmapmalloc.so.1 755 root bin
+s none usr/lib/libmd.so.1=../../lib/libmd.so.1
+s none usr/lib/libmd.so=../../lib/libmd.so.1
 s none usr/lib/libmd5.so.1=../../lib/libmd5.so.1
 s none usr/lib/libmd5.so=../../lib/libmd5.so.1
 f none usr/lib/libmenu.so.1 755 root bin
--- a/usr/src/pkgdefs/SUNWcsl/prototype_i386	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcsl/prototype_i386	Tue Mar 28 08:45:30 2006 -0800
@@ -173,6 +173,8 @@
 s none usr/lib/amd64/liblgrp.so=liblgrp.so.1
 f none usr/lib/amd64/libmalloc.so.1 755 root bin
 s none usr/lib/amd64/libmalloc.so=libmalloc.so.1
+s none usr/lib/amd64/libmd.so.1=../../../lib/amd64/libmd.so.1
+s none usr/lib/amd64/libmd.so=../../../lib/amd64/libmd.so.1
 s none usr/lib/amd64/libmd5.so.1=../../../lib/amd64/libmd5.so.1
 s none usr/lib/amd64/libmd5.so=../../../lib/amd64/libmd5.so.1
 f none usr/lib/amd64/libmenu.so.1 755 root bin
--- a/usr/src/pkgdefs/SUNWcsl/prototype_sparc	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcsl/prototype_sparc	Tue Mar 28 08:45:30 2006 -0800
@@ -166,6 +166,8 @@
 s none usr/lib/sparcv9/liblgrp.so=liblgrp.so.1
 f none usr/lib/sparcv9/libmalloc.so.1 755 root bin
 s none usr/lib/sparcv9/libmalloc.so=libmalloc.so.1
+s none usr/lib/sparcv9/libmd.so.1=../../../lib/sparcv9/libmd.so.1
+s none usr/lib/sparcv9/libmd.so=../../../lib/sparcv9/libmd.so.1
 s none usr/lib/sparcv9/libmd5.so.1=../../../lib/sparcv9/libmd5.so.1
 s none usr/lib/sparcv9/libmd5.so=../../../lib/sparcv9/libmd5.so.1
 f none usr/lib/sparcv9/libmenu.so.1 755 root bin
--- a/usr/src/pkgdefs/SUNWcslr/prototype_com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcslr/prototype_com	Tue Mar 28 08:45:30 2006 -0800
@@ -98,6 +98,8 @@
 f none lib/libld.so.4 755 root bin
 f none lib/liblddbg.so.4 755 root bin
 f none lib/libmacadm.so.1 755 root bin
+s none lib/libmd.so=libmd.so.1
+f none lib/libmd.so.1 755 root bin
 s none lib/libmd5.so=libmd5.so.1
 f none lib/libmd5.so.1 755 root bin
 s none lib/libmp.so=libmp.so.2
--- a/usr/src/pkgdefs/SUNWcslr/prototype_i386	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcslr/prototype_i386	Tue Mar 28 08:45:30 2006 -0800
@@ -95,6 +95,8 @@
 f none lib/amd64/libkstat.so.1 755 root bin
 f none lib/amd64/libld.so.4 755 root bin
 f none lib/amd64/liblddbg.so.4 755 root bin
+s none lib/amd64/libmd.so=libmd.so.1
+f none lib/amd64/libmd.so.1 755 root bin
 s none lib/amd64/libmd5.so=libmd5.so.1
 f none lib/amd64/libmd5.so.1 755 root bin
 s none lib/amd64/libmp.so=libmp.so.2
--- a/usr/src/pkgdefs/SUNWcslr/prototype_sparc	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWcslr/prototype_sparc	Tue Mar 28 08:45:30 2006 -0800
@@ -98,6 +98,8 @@
 f none lib/sparcv9/libkstat.so.1 755 root bin
 f none lib/sparcv9/libld.so.4 755 root bin
 f none lib/sparcv9/liblddbg.so.4 755 root bin
+s none lib/sparcv9/libmd.so=libmd.so.1
+f none lib/sparcv9/libmd.so.1 755 root bin
 s none lib/sparcv9/libmd5.so=libmd5.so.1
 f none lib/sparcv9/libmd5.so.1 755 root bin
 s none lib/sparcv9/libmp.so=libmp.so.2
--- a/usr/src/pkgdefs/SUNWhea/prototype_com	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/pkgdefs/SUNWhea/prototype_com	Tue Mar 28 08:45:30 2006 -0800
@@ -201,6 +201,7 @@
 f none usr/include/macros.h 644 root bin
 f none usr/include/maillock.h 644 root bin
 f none usr/include/malloc.h 644 root bin
+f none usr/include/md4.h 644 root bin
 f none usr/include/md5.h 644 root bin
 f none usr/include/mdmn_changelog.h 644 root bin
 f none usr/include/memory.h 644 root bin
@@ -467,6 +468,8 @@
 f none usr/include/semaphore.h 644 root bin
 f none usr/include/setjmp.h 644 root bin
 f none usr/include/sgtty.h 644 root bin
+f none usr/include/sha1.h 644 root bin
+f none usr/include/sha2.h 644 root bin
 f none usr/include/shadow.h 644 root bin
 f none usr/include/siginfo.h 644 root bin
 f none usr/include/signal.h 644 root bin
@@ -1014,6 +1017,8 @@
 f none usr/include/sys/sendfile.h 644 root bin
 f none usr/include/sys/ser_sync.h 644 root bin
 f none usr/include/sys/session.h 644 root bin
+f none usr/include/sys/sha1.h 644 root bin
+f none usr/include/sys/sha2.h 644 root bin
 f none usr/include/sys/share.h 644 root bin
 f none usr/include/sys/shm.h 644 root bin
 f none usr/include/sys/shm_impl.h 644 root bin
--- a/usr/src/stand/lib/Makefile.targ	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/stand/lib/Makefile.targ	Tue Mar 28 08:45:30 2006 -0800
@@ -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,9 +19,9 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# 
+#
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
 
@@ -57,6 +56,10 @@
 	$(COMPILE.c) -o $@ $<
 	$(POST_PROCESS_O)
 
+objs/%.o: $(SHA1DIR)/%.c
+	$(COMPILE.c) -o $@ $<
+	$(POST_PROCESS_O)
+
 $(ROOTLIBDIR):
 	$(INS.dir)
 
--- a/usr/src/stand/lib/scrypt/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/stand/lib/scrypt/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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,18 +19,21 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# 
+#
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
 
 LIBRARY = libscrypt.a
-OBJECTS = sha1.o hmac_sha1.o des3.o des.o aes.o cbc.o
+COBJECTS = hmac_sha1.o des3.o des.o aes.o cbc.o
+SHA1_OBJS = sha1.o
+OBJECTS = $(COBJECTS) $(SHA1_OBJS)
 
 include ../Makefile.com
 
 CMNDIR  = $(TOPDIR)/common/net/wanboot/crypt
-SRCS	= $(OBJECTS:%.o=$(CMNDIR)/%.c)
+SHA1DIR  = $(TOPDIR)/common/crypto/sha1
+SRCS	= $(COBJECTS:%.o=$(CMNDIR)/%.c) $(SHA1_OBJS:%.o=$(SHA1DIR)/%.c)
 
 include ../Makefile.targ
--- a/usr/src/uts/common/Makefile.files	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/uts/common/Makefile.files	Tue Mar 28 08:45:30 2006 -0800
@@ -393,11 +393,11 @@
 
 SAD_OBJS +=	sad.o
 
-MD5_OBJS +=	md5.o
+MD5_OBJS +=	md5.o md5_mod.o
 
-SHA1_OBJS +=	sha1.o
+SHA1_OBJS +=	sha1.o sha1_mod.o
 
-SHA2_OBJS +=	sha2.o
+SHA2_OBJS +=	sha2.o sha2_mod.o
 
 IPGPC_OBJS +=   classifierddi.o classifier.o filters.o trie.o table.o \
 		ba_table.o
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/uts/common/crypto/io/md5_mod.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,1500 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+/*
+ * In kernel module, the md5 module is created with two modlinkages:
+ * - a modlmisc that allows consumers to directly call the entry points
+ *   MD5Init, MD5Update, and MD5Final.
+ * - a modlcrypto that allows the module to register with the Kernel
+ *   Cryptographic Framework (KCF) as a software provider for the MD5
+ *   mechanisms.
+ */
+
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/modctl.h>
+#include <sys/cmn_err.h>
+#include <sys/ddi.h>
+#include <sys/crypto/common.h>
+#include <sys/crypto/spi.h>
+#include <sys/sysmacros.h>
+#include <sys/strsun.h>
+#include <sys/note.h>
+#include <sys/md5.h>
+
+extern struct mod_ops mod_miscops;
+extern struct mod_ops mod_cryptoops;
+
+/*
+ * Module linkage information for the kernel.
+ */
+
+static struct modlmisc modlmisc = {
+	&mod_miscops,
+	"MD5 Message-Digest Algorithm"
+};
+
+static struct modlcrypto modlcrypto = {
+	&mod_cryptoops,
+	"MD5 Kernel SW Provider %I%"
+};
+
+static struct modlinkage modlinkage = {
+	MODREV_1,
+	(void *)&modlmisc,
+	(void *)&modlcrypto,
+	NULL
+};
+
+/*
+ * CSPI information (entry points, provider info, etc.)
+ */
+
+typedef enum md5_mech_type {
+	MD5_MECH_INFO_TYPE,		/* SUN_CKM_MD5 */
+	MD5_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_MD5_HMAC */
+	MD5_HMAC_GEN_MECH_INFO_TYPE	/* SUN_CKM_MD5_HMAC_GENERAL */
+} md5_mech_type_t;
+
+#define	MD5_DIGEST_LENGTH	16	/* MD5 digest length in bytes */
+#define	MD5_HMAC_BLOCK_SIZE	64	/* MD5 block size */
+#define	MD5_HMAC_MIN_KEY_LEN	8	/* MD5-HMAC min key length in bits */
+#define	MD5_HMAC_MAX_KEY_LEN	INT_MAX	/* MD5-HMAC max key length in bits */
+#define	MD5_HMAC_INTS_PER_BLOCK	(MD5_HMAC_BLOCK_SIZE/sizeof (uint32_t))
+
+/*
+ * Context for MD5 mechanism.
+ */
+typedef struct md5_ctx {
+	md5_mech_type_t		mc_mech_type;	/* type of context */
+	MD5_CTX			mc_md5_ctx;	/* MD5 context */
+} md5_ctx_t;
+
+/*
+ * Context for MD5-HMAC and MD5-HMAC-GENERAL mechanisms.
+ */
+typedef struct md5_hmac_ctx {
+	md5_mech_type_t		hc_mech_type;	/* type of context */
+	uint32_t		hc_digest_len;	/* digest len in bytes */
+	MD5_CTX			hc_icontext;	/* inner MD5 context */
+	MD5_CTX			hc_ocontext;	/* outer MD5 context */
+} md5_hmac_ctx_t;
+
+/*
+ * Macros to access the MD5 or MD5-HMAC contexts from a context passed
+ * by KCF to one of the entry points.
+ */
+
+#define	PROV_MD5_CTX(ctx)	((md5_ctx_t *)(ctx)->cc_provider_private)
+#define	PROV_MD5_HMAC_CTX(ctx)	((md5_hmac_ctx_t *)(ctx)->cc_provider_private)
+/* to extract the digest length passed as mechanism parameter */
+
+#define	PROV_MD5_GET_DIGEST_LEN(m, len) {				\
+	if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))		\
+		(len) = (uint32_t)*((ulong_t *)mechanism->cm_param);	\
+	else {								\
+		ulong_t tmp_ulong;					\
+		bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));	\
+		(len) = (uint32_t)tmp_ulong;				\
+	}								\
+}
+
+#define	PROV_MD5_DIGEST_KEY(ctx, key, len, digest) {	\
+	MD5Init(ctx);					\
+	MD5Update(ctx, key, len);			\
+	MD5Final(digest, ctx);				\
+}
+
+/*
+ * Mechanism info structure passed to KCF during registration.
+ */
+static crypto_mech_info_t md5_mech_info_tab[] = {
+	/* MD5 */
+	{SUN_CKM_MD5, MD5_MECH_INFO_TYPE,
+	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
+	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* MD5-HMAC */
+	{SUN_CKM_MD5_HMAC, MD5_HMAC_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    MD5_HMAC_MIN_KEY_LEN, MD5_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* MD5-HMAC GENERAL */
+	{SUN_CKM_MD5_HMAC_GENERAL, MD5_HMAC_GEN_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    MD5_HMAC_MIN_KEY_LEN, MD5_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS}
+};
+
+static void md5_provider_status(crypto_provider_handle_t, uint_t *);
+
+static crypto_control_ops_t md5_control_ops = {
+	md5_provider_status
+};
+
+static int md5_digest_init(crypto_ctx_t *, crypto_mechanism_t *,
+    crypto_req_handle_t);
+static int md5_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int md5_digest_update(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int md5_digest_final(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int md5_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
+    crypto_req_handle_t);
+
+static crypto_digest_ops_t md5_digest_ops = {
+	md5_digest_init,
+	md5_digest,
+	md5_digest_update,
+	NULL,
+	md5_digest_final,
+	md5_digest_atomic
+};
+
+static int md5_mac_init(crypto_ctx_t *, crypto_mechanism_t *, crypto_key_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+static int md5_mac_update(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
+static int md5_mac_final(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
+static int md5_mac_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+static int md5_mac_verify_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+
+static crypto_mac_ops_t md5_mac_ops = {
+	md5_mac_init,
+	NULL,
+	md5_mac_update,
+	md5_mac_final,
+	md5_mac_atomic,
+	md5_mac_verify_atomic
+};
+
+static int md5_create_ctx_template(crypto_provider_handle_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
+    size_t *, crypto_req_handle_t);
+static int md5_free_context(crypto_ctx_t *);
+
+static crypto_ctx_ops_t md5_ctx_ops = {
+	md5_create_ctx_template,
+	md5_free_context
+};
+
+static crypto_ops_t md5_crypto_ops = {
+	&md5_control_ops,
+	&md5_digest_ops,
+	NULL,
+	&md5_mac_ops,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	&md5_ctx_ops
+};
+
+static crypto_provider_info_t md5_prov_info = {
+	CRYPTO_SPI_VERSION_1,
+	"MD5 Software Provider",
+	CRYPTO_SW_PROVIDER,
+	{&modlinkage},
+	NULL,
+	&md5_crypto_ops,
+	sizeof (md5_mech_info_tab)/sizeof (crypto_mech_info_t),
+	md5_mech_info_tab
+};
+
+static crypto_kcf_provider_handle_t md5_prov_handle = NULL;
+
+int
+_init(void)
+{
+	int ret;
+
+	if ((ret = mod_install(&modlinkage)) != 0)
+		return (ret);
+
+	/*
+	 * Register with KCF. If the registration fails, log an
+	 * error but do not uninstall the module, since the functionality
+	 * provided by misc/md5 should still be available.
+	 */
+	if ((ret = crypto_register_provider(&md5_prov_info,
+	    &md5_prov_handle)) != CRYPTO_SUCCESS)
+		cmn_err(CE_WARN, "md5 _init: "
+		    "crypto_register_provider() failed (0x%x)", ret);
+
+	return (0);
+}
+
+int
+_fini(void)
+{
+	int ret;
+
+	/*
+	 * Unregister from KCF if previous registration succeeded.
+	 */
+	if (md5_prov_handle != NULL) {
+		if ((ret = crypto_unregister_provider(md5_prov_handle)) !=
+		    CRYPTO_SUCCESS) {
+			cmn_err(CE_WARN, "md5 _fini: "
+			    "crypto_unregister_provider() failed (0x%x)", ret);
+			return (EBUSY);
+		}
+		md5_prov_handle = NULL;
+	}
+
+	return (mod_remove(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+	return (mod_info(&modlinkage, modinfop));
+}
+
+/*
+ * KCF software provider control entry points.
+ */
+/* ARGSUSED */
+static void
+md5_provider_status(crypto_provider_handle_t provider, uint_t *status)
+{
+	*status = CRYPTO_PROVIDER_READY;
+}
+
+/*
+ * KCF software provider digest entry points.
+ */
+
+static int
+md5_digest_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
+    crypto_req_handle_t req)
+{
+	if (mechanism->cm_type != MD5_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/*
+	 * Allocate and initialize MD5 context.
+	 */
+	ctx->cc_provider_private = kmem_alloc(sizeof (md5_ctx_t),
+	    crypto_kmflag(req));
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	PROV_MD5_CTX(ctx)->mc_mech_type = MD5_MECH_INFO_TYPE;
+	MD5Init(&PROV_MD5_CTX(ctx)->mc_md5_ctx);
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper MD5 digest update function for uio data.
+ */
+static int
+md5_digest_update_uio(MD5_CTX *md5_ctx, crypto_data_t *data)
+{
+	off_t offset = data->cd_offset;
+	size_t length = data->cd_length;
+	uint_t vec_idx;
+	size_t cur_len;
+
+	/* we support only kernel buffer */
+	if (data->cd_uio->uio_segflg != UIO_SYSSPACE)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Jump to the first iovec containing data to be
+	 * digested.
+	 */
+	for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
+	    offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
+	    offset -= data->cd_uio->uio_iov[vec_idx++].iov_len);
+	if (vec_idx == data->cd_uio->uio_iovcnt) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	/*
+	 * Now do the digesting on the iovecs.
+	 */
+	while (vec_idx < data->cd_uio->uio_iovcnt && length > 0) {
+		cur_len = MIN(data->cd_uio->uio_iov[vec_idx].iov_len -
+		    offset, length);
+
+		MD5Update(md5_ctx, data->cd_uio->uio_iov[vec_idx].iov_base +
+		    offset, cur_len);
+
+		length -= cur_len;
+		vec_idx++;
+		offset = 0;
+	}
+
+	if (vec_idx == data->cd_uio->uio_iovcnt && length > 0) {
+		/*
+		 * The end of the specified iovec's was reached but
+		 * the length requested could not be processed, i.e.
+		 * The caller requested to digest more data than it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper MD5 digest final function for uio data.
+ * digest_len is the length of the desired digest. If digest_len
+ * is smaller than the default MD5 digest length, the caller
+ * must pass a scratch buffer, digest_scratch, which must
+ * be at least MD5_DIGEST_LENGTH bytes.
+ */
+static int
+md5_digest_final_uio(MD5_CTX *md5_ctx, crypto_data_t *digest,
+    ulong_t digest_len, uchar_t *digest_scratch)
+{
+	off_t offset = digest->cd_offset;
+	uint_t vec_idx;
+
+	/* we support only kernel buffer */
+	if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Jump to the first iovec containing ptr to the digest to
+	 * be returned.
+	 */
+	for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
+	    vec_idx < digest->cd_uio->uio_iovcnt;
+	    offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len);
+	if (vec_idx == digest->cd_uio->uio_iovcnt) {
+		/*
+		 * The caller specified an offset that is
+		 * larger than the total size of the buffers
+		 * it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	if (offset + digest_len <=
+	    digest->cd_uio->uio_iov[vec_idx].iov_len) {
+		/*
+		 * The computed MD5 digest will fit in the current
+		 * iovec.
+		 */
+		if (digest_len != MD5_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			MD5Final(digest_scratch, md5_ctx);
+			bcopy(digest_scratch, (uchar_t *)digest->
+			    cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    digest_len);
+		} else {
+			MD5Final((uchar_t *)digest->
+			    cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    md5_ctx);
+		}
+	} else {
+		/*
+		 * The computed digest will be crossing one or more iovec's.
+		 * This is bad performance-wise but we need to support it.
+		 * Allocate a small scratch buffer on the stack and
+		 * copy it piece meal to the specified digest iovec's.
+		 */
+		uchar_t digest_tmp[MD5_DIGEST_LENGTH];
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		MD5Final(digest_tmp, md5_ctx);
+
+		while (vec_idx < digest->cd_uio->uio_iovcnt && length > 0) {
+			cur_len = MIN(digest->cd_uio->uio_iov[vec_idx].iov_len -
+			    offset, length);
+			bcopy(digest_tmp + scratch_offset,
+			    digest->cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    cur_len);
+
+			length -= cur_len;
+			vec_idx++;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+
+		if (vec_idx == digest->cd_uio->uio_iovcnt && length > 0) {
+			/*
+			 * The end of the specified iovec's was reached but
+			 * the length requested could not be processed, i.e.
+			 * The caller requested to digest more data than it
+			 * provided.
+			 */
+			return (CRYPTO_DATA_LEN_RANGE);
+		}
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper MD5 digest update for mblk's.
+ */
+static int
+md5_digest_update_mblk(MD5_CTX *md5_ctx, crypto_data_t *data)
+{
+	off_t offset = data->cd_offset;
+	size_t length = data->cd_length;
+	mblk_t *mp;
+	size_t cur_len;
+
+	/*
+	 * Jump to the first mblk_t containing data to be digested.
+	 */
+	for (mp = data->cd_mp; mp != NULL && offset >= MBLKL(mp);
+	    offset -= MBLKL(mp), mp = mp->b_cont);
+	if (mp == NULL) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	/*
+	 * Now do the digesting on the mblk chain.
+	 */
+	while (mp != NULL && length > 0) {
+		cur_len = MIN(MBLKL(mp) - offset, length);
+		MD5Update(md5_ctx, mp->b_rptr + offset, cur_len);
+		length -= cur_len;
+		offset = 0;
+		mp = mp->b_cont;
+	}
+
+	if (mp == NULL && length > 0) {
+		/*
+		 * The end of the mblk was reached but the length requested
+		 * could not be processed, i.e. The caller requested
+		 * to digest more data than it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper MD5 digest final for mblk's.
+ * digest_len is the length of the desired digest. If digest_len
+ * is smaller than the default MD5 digest length, the caller
+ * must pass a scratch buffer, digest_scratch, which must
+ * be at least MD5_DIGEST_LENGTH bytes.
+ */
+static int
+md5_digest_final_mblk(MD5_CTX *md5_ctx, crypto_data_t *digest,
+    ulong_t digest_len, uchar_t *digest_scratch)
+{
+	off_t offset = digest->cd_offset;
+	mblk_t *mp;
+
+	/*
+	 * Jump to the first mblk_t that will be used to store the digest.
+	 */
+	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
+	    offset -= MBLKL(mp), mp = mp->b_cont);
+	if (mp == NULL) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	if (offset + digest_len <= MBLKL(mp)) {
+		/*
+		 * The computed MD5 digest will fit in the current mblk.
+		 * Do the MD5Final() in-place.
+		 */
+		if (digest_len != MD5_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			MD5Final(digest_scratch, md5_ctx);
+			bcopy(digest_scratch, mp->b_rptr + offset, digest_len);
+		} else {
+			MD5Final(mp->b_rptr + offset, md5_ctx);
+		}
+	} else {
+		/*
+		 * The computed digest will be crossing one or more mblk's.
+		 * This is bad performance-wise but we need to support it.
+		 * Allocate a small scratch buffer on the stack and
+		 * copy it piece meal to the specified digest iovec's.
+		 */
+		uchar_t digest_tmp[MD5_DIGEST_LENGTH];
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		MD5Final(digest_tmp, md5_ctx);
+
+		while (mp != NULL && length > 0) {
+			cur_len = MIN(MBLKL(mp) - offset, length);
+			bcopy(digest_tmp + scratch_offset,
+			    mp->b_rptr + offset, cur_len);
+
+			length -= cur_len;
+			mp = mp->b_cont;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+
+		if (mp == NULL && length > 0) {
+			/*
+			 * The end of the specified mblk was reached but
+			 * the length requested could not be processed, i.e.
+			 * The caller requested to digest more data than it
+			 * provided.
+			 */
+			return (CRYPTO_DATA_LEN_RANGE);
+		}
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/* ARGSUSED */
+static int
+md5_digest(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((digest->cd_length == 0) ||
+	    (digest->cd_length < MD5_DIGEST_LENGTH)) {
+		digest->cd_length = MD5_DIGEST_LENGTH;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do the MD5 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Update(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_update_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_update_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		/* the update failed, free context and bail */
+		kmem_free(ctx->cc_provider_private, sizeof (md5_ctx_t));
+		ctx->cc_provider_private = NULL;
+		digest->cd_length = 0;
+		return (ret);
+	}
+
+	/*
+	 * Do an MD5 final, must be done separately since the digest
+	 * type can be different than the input data type.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &PROV_MD5_CTX(ctx)->mc_md5_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_final_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    digest, MD5_DIGEST_LENGTH, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_final_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    digest, MD5_DIGEST_LENGTH, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/* all done, free context and return */
+
+	if (ret == CRYPTO_SUCCESS) {
+		digest->cd_length = MD5_DIGEST_LENGTH;
+	} else {
+		digest->cd_length = 0;
+	}
+
+	kmem_free(ctx->cc_provider_private, sizeof (md5_ctx_t));
+	ctx->cc_provider_private = NULL;
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+md5_digest_update(crypto_ctx_t *ctx, crypto_data_t *data,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * Do the MD5 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Update(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_update_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_update_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+md5_digest_final(crypto_ctx_t *ctx, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((digest->cd_length == 0) ||
+	    (digest->cd_length < MD5_DIGEST_LENGTH)) {
+		digest->cd_length = MD5_DIGEST_LENGTH;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do an MD5 final.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &PROV_MD5_CTX(ctx)->mc_md5_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_final_uio(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    digest, MD5_DIGEST_LENGTH, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_final_mblk(&PROV_MD5_CTX(ctx)->mc_md5_ctx,
+		    digest, MD5_DIGEST_LENGTH, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/* all done, free context and return */
+
+	if (ret == CRYPTO_SUCCESS) {
+		digest->cd_length = MD5_DIGEST_LENGTH;
+	} else {
+		digest->cd_length = 0;
+	}
+
+	kmem_free(ctx->cc_provider_private, sizeof (md5_ctx_t));
+	ctx->cc_provider_private = NULL;
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+md5_digest_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_data_t *data, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	MD5_CTX md5_ctx;
+
+	if (mechanism->cm_type != MD5_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/*
+	 * Do the MD5 init.
+	 */
+	MD5Init(&md5_ctx);
+
+	/*
+	 * Do the MD5 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Update(&md5_ctx, data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_update_uio(&md5_ctx, data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_update_mblk(&md5_ctx, data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		/* the update failed, bail */
+		digest->cd_length = 0;
+		return (ret);
+	}
+
+	/*
+	 * Do an MD5 final, must be done separately since the digest
+	 * type can be different than the input data type.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &md5_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_final_uio(&md5_ctx, digest,
+		    MD5_DIGEST_LENGTH, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_final_mblk(&md5_ctx, digest,
+		    MD5_DIGEST_LENGTH, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		digest->cd_length = MD5_DIGEST_LENGTH;
+	} else {
+		digest->cd_length = 0;
+	}
+
+	return (ret);
+}
+
+/*
+ * KCF software provider mac entry points.
+ *
+ * MD5 HMAC is: MD5(key XOR opad, MD5(key XOR ipad, text))
+ *
+ * Init:
+ * The initialization routine initializes what we denote
+ * as the inner and outer contexts by doing
+ * - for inner context: MD5(key XOR ipad)
+ * - for outer context: MD5(key XOR opad)
+ *
+ * Update:
+ * Each subsequent MD5 HMAC update will result in an
+ * update of the inner context with the specified data.
+ *
+ * Final:
+ * The MD5 HMAC final will do a MD5 final operation on the
+ * inner context, and the resulting digest will be used
+ * as the data for an update on the outer context. Last
+ * but not least, an MD5 final on the outer context will
+ * be performed to obtain the MD5 HMAC digest to return
+ * to the user.
+ */
+
+/*
+ * Initialize a MD5-HMAC context.
+ */
+static void
+md5_mac_init_ctx(md5_hmac_ctx_t *ctx, void *keyval, uint_t length_in_bytes)
+{
+	uint32_t ipad[MD5_HMAC_INTS_PER_BLOCK];
+	uint32_t opad[MD5_HMAC_INTS_PER_BLOCK];
+	uint_t i;
+
+	bzero(ipad, MD5_HMAC_BLOCK_SIZE);
+	bzero(opad, MD5_HMAC_BLOCK_SIZE);
+
+	bcopy(keyval, ipad, length_in_bytes);
+	bcopy(keyval, opad, length_in_bytes);
+
+	/* XOR key with ipad (0x36) and opad (0x5c) */
+	for (i = 0; i < MD5_HMAC_INTS_PER_BLOCK; i++) {
+		ipad[i] ^= 0x36363636;
+		opad[i] ^= 0x5c5c5c5c;
+	}
+
+	/* perform MD5 on ipad */
+	MD5Init(&ctx->hc_icontext);
+	MD5Update(&ctx->hc_icontext, ipad, MD5_HMAC_BLOCK_SIZE);
+
+	/* perform MD5 on opad */
+	MD5Init(&ctx->hc_ocontext);
+	MD5Update(&ctx->hc_ocontext, opad, MD5_HMAC_BLOCK_SIZE);
+}
+
+/*
+ * Initializes a multi-part MAC operation.
+ */
+static int
+md5_mac_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if (mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE &&
+	    mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	ctx->cc_provider_private = kmem_alloc(sizeof (md5_hmac_ctx_t),
+	    crypto_kmflag(req));
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, PROV_MD5_HMAC_CTX(ctx),
+		    sizeof (md5_hmac_ctx_t));
+	} else {
+		/* no context template, compute context */
+		if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
+			uchar_t digested_key[MD5_DIGEST_LENGTH];
+			md5_hmac_ctx_t *hmac_ctx = ctx->cc_provider_private;
+
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_MD5_DIGEST_KEY(&hmac_ctx->hc_icontext,
+			    key->ck_data, keylen_in_bytes, digested_key);
+			md5_mac_init_ctx(PROV_MD5_HMAC_CTX(ctx),
+			    digested_key, MD5_DIGEST_LENGTH);
+		} else {
+			md5_mac_init_ctx(PROV_MD5_HMAC_CTX(ctx),
+			    key->ck_data, keylen_in_bytes);
+		}
+	}
+
+	/*
+	 * Get the mechanism parameters, if applicable.
+	 */
+	PROV_MD5_HMAC_CTX(ctx)->hc_mech_type = mechanism->cm_type;
+	if (mechanism->cm_type == MD5_HMAC_GEN_MECH_INFO_TYPE) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t))
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+		PROV_MD5_GET_DIGEST_LEN(mechanism,
+		    PROV_MD5_HMAC_CTX(ctx)->hc_digest_len);
+		if (PROV_MD5_HMAC_CTX(ctx)->hc_digest_len >
+		    MD5_DIGEST_LENGTH)
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		bzero(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
+		kmem_free(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
+		ctx->cc_provider_private = NULL;
+	}
+
+	return (ret);
+}
+
+
+/* ARGSUSED */
+static int
+md5_mac_update(crypto_ctx_t *ctx, crypto_data_t *data, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * Do an MD5 update of the inner context using the specified
+	 * data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		MD5Update(&PROV_MD5_HMAC_CTX(ctx)->hc_icontext,
+		    data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_update_uio(
+		    &PROV_MD5_HMAC_CTX(ctx)->hc_icontext, data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_update_mblk(
+		    &PROV_MD5_HMAC_CTX(ctx)->hc_icontext, data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+md5_mac_final(crypto_ctx_t *ctx, crypto_data_t *mac, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[MD5_DIGEST_LENGTH];
+	uint32_t digest_len = MD5_DIGEST_LENGTH;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	if (PROV_MD5_HMAC_CTX(ctx)->hc_mech_type == MD5_HMAC_GEN_MECH_INFO_TYPE)
+	    digest_len = PROV_MD5_HMAC_CTX(ctx)->hc_digest_len;
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((mac->cd_length == 0) || (mac->cd_length < digest_len)) {
+		mac->cd_length = digest_len;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do an MD5 final on the inner context.
+	 */
+	MD5Final(digest, &PROV_MD5_HMAC_CTX(ctx)->hc_icontext);
+
+	/*
+	 * Do an MD5 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	MD5Update(&PROV_MD5_HMAC_CTX(ctx)->hc_ocontext, digest,
+	    MD5_DIGEST_LENGTH);
+
+	/*
+	 * Do an MD5 final on the outer context, storing the computing
+	 * digest in the users buffer.
+	 */
+	switch (mac->cd_format) {
+	case CRYPTO_DATA_RAW:
+		if (digest_len != MD5_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			MD5Final(digest,
+			    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext);
+			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, digest_len);
+		} else {
+			MD5Final((unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset,
+			    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext);
+		}
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_final_uio(
+		    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_final_mblk(
+		    &PROV_MD5_HMAC_CTX(ctx)->hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		mac->cd_length = digest_len;
+	} else {
+		mac->cd_length = 0;
+	}
+
+	bzero(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
+	kmem_free(ctx->cc_provider_private, sizeof (md5_hmac_ctx_t));
+	ctx->cc_provider_private = NULL;
+
+	return (ret);
+}
+
+#define	MD5_MAC_UPDATE(data, ctx, ret) {				\
+	switch (data->cd_format) {					\
+	case CRYPTO_DATA_RAW:						\
+		MD5Update(&(ctx).hc_icontext,				\
+		    data->cd_raw.iov_base + data->cd_offset,		\
+		    data->cd_length);					\
+		break;							\
+	case CRYPTO_DATA_UIO:						\
+		ret = md5_digest_update_uio(&(ctx).hc_icontext,	data);	\
+		break;							\
+	case CRYPTO_DATA_MBLK:						\
+		ret = md5_digest_update_mblk(&(ctx).hc_icontext,	\
+		    data);						\
+		break;							\
+	default:							\
+		ret = CRYPTO_ARGUMENTS_BAD;				\
+	}								\
+}
+
+
+/* ARGSUSED */
+static int
+md5_mac_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
+    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[MD5_DIGEST_LENGTH];
+	md5_hmac_ctx_t md5_hmac_ctx;
+	uint32_t digest_len = MD5_DIGEST_LENGTH;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if (mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE &&
+	    mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, &md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
+	} else {
+		/* no context template, compute context */
+		if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_MD5_DIGEST_KEY(&md5_hmac_ctx.hc_icontext,
+			    key->ck_data, keylen_in_bytes, digest);
+			md5_mac_init_ctx(&md5_hmac_ctx, digest,
+			    MD5_DIGEST_LENGTH);
+		} else {
+			md5_mac_init_ctx(&md5_hmac_ctx, key->ck_data,
+			    keylen_in_bytes);
+		}
+	}
+
+	/*
+	 * Get the mechanism parameters, if applicable.
+	 */
+	if (mechanism->cm_type == MD5_HMAC_GEN_MECH_INFO_TYPE) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t)) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+		PROV_MD5_GET_DIGEST_LEN(mechanism, digest_len);
+		if (digest_len > MD5_DIGEST_LENGTH) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+	}
+
+	/* do an MD5 update of the inner context using the specified data */
+	MD5_MAC_UPDATE(data, md5_hmac_ctx, ret);
+	if (ret != CRYPTO_SUCCESS)
+		/* the update failed, free context and bail */
+		goto bail;
+
+	/* do an MD5 final on the inner context */
+	MD5Final(digest, &md5_hmac_ctx.hc_icontext);
+
+	/*
+	 * Do an MD5 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	MD5Update(&md5_hmac_ctx.hc_ocontext, digest, MD5_DIGEST_LENGTH);
+
+	/*
+	 * Do an MD5 final on the outer context, storing the computed
+	 * digest in the users buffer.
+	 */
+	switch (mac->cd_format) {
+	case CRYPTO_DATA_RAW:
+		if (digest_len != MD5_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			MD5Final(digest, &md5_hmac_ctx.hc_ocontext);
+			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, digest_len);
+		} else {
+			MD5Final((unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, &md5_hmac_ctx.hc_ocontext);
+		}
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = md5_digest_final_uio(&md5_hmac_ctx.hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = md5_digest_final_mblk(&md5_hmac_ctx.hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		mac->cd_length = digest_len;
+	} else {
+		mac->cd_length = 0;
+	}
+	/* Extra paranoia: zeroizing the local context on the stack */
+	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
+
+	return (ret);
+bail:
+	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
+	mac->cd_length = 0;
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+md5_mac_verify_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
+    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[MD5_DIGEST_LENGTH];
+	md5_hmac_ctx_t md5_hmac_ctx;
+	uint32_t digest_len = MD5_DIGEST_LENGTH;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if (mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE &&
+	    mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, &md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
+	} else {
+		/* no context template, compute context */
+		if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_MD5_DIGEST_KEY(&md5_hmac_ctx.hc_icontext,
+			    key->ck_data, keylen_in_bytes, digest);
+			md5_mac_init_ctx(&md5_hmac_ctx, digest,
+			    MD5_DIGEST_LENGTH);
+		} else {
+			md5_mac_init_ctx(&md5_hmac_ctx, key->ck_data,
+			    keylen_in_bytes);
+		}
+	}
+
+	/*
+	 * Get the mechanism parameters, if applicable.
+	 */
+	if (mechanism->cm_type == MD5_HMAC_GEN_MECH_INFO_TYPE) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t)) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+		PROV_MD5_GET_DIGEST_LEN(mechanism, digest_len);
+		if (digest_len > MD5_DIGEST_LENGTH) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+	}
+
+	if (mac->cd_length != digest_len) {
+		ret = CRYPTO_INVALID_MAC;
+		goto bail;
+	}
+
+	/* do an MD5 update of the inner context using the specified data */
+	MD5_MAC_UPDATE(data, md5_hmac_ctx, ret);
+	if (ret != CRYPTO_SUCCESS)
+		/* the update failed, free context and bail */
+		goto bail;
+
+	/* do an MD5 final on the inner context */
+	MD5Final(digest, &md5_hmac_ctx.hc_icontext);
+
+	/*
+	 * Do an MD5 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	MD5Update(&md5_hmac_ctx.hc_ocontext, digest, MD5_DIGEST_LENGTH);
+
+	/*
+	 * Do an MD5 final on the outer context, storing the computed
+	 * digest in the local digest buffer.
+	 */
+	MD5Final(digest, &md5_hmac_ctx.hc_ocontext);
+
+	/*
+	 * Compare the computed digest against the expected digest passed
+	 * as argument.
+	 */
+	switch (mac->cd_format) {
+
+	case CRYPTO_DATA_RAW:
+		if (bcmp(digest, (unsigned char *)mac->cd_raw.iov_base +
+		    mac->cd_offset, digest_len) != 0)
+			ret = CRYPTO_INVALID_MAC;
+		break;
+
+	case CRYPTO_DATA_UIO: {
+		off_t offset = mac->cd_offset;
+		uint_t vec_idx;
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		/* we support only kernel buffer */
+		if (mac->cd_uio->uio_segflg != UIO_SYSSPACE)
+			return (CRYPTO_ARGUMENTS_BAD);
+
+		/* jump to the first iovec containing the expected digest */
+		for (vec_idx = 0;
+		    offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
+		    vec_idx < mac->cd_uio->uio_iovcnt;
+		    offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len);
+		if (vec_idx == mac->cd_uio->uio_iovcnt) {
+			/*
+			 * The caller specified an offset that is
+			 * larger than the total size of the buffers
+			 * it provided.
+			 */
+			ret = CRYPTO_DATA_LEN_RANGE;
+			break;
+		}
+
+		/* do the comparison of computed digest vs specified one */
+		while (vec_idx < mac->cd_uio->uio_iovcnt && length > 0) {
+			cur_len = MIN(mac->cd_uio->uio_iov[vec_idx].iov_len -
+			    offset, length);
+
+			if (bcmp(digest + scratch_offset,
+			    mac->cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    cur_len) != 0) {
+				ret = CRYPTO_INVALID_MAC;
+				break;
+			}
+
+			length -= cur_len;
+			vec_idx++;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+		break;
+	}
+
+	case CRYPTO_DATA_MBLK: {
+		off_t offset = mac->cd_offset;
+		mblk_t *mp;
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		/* jump to the first mblk_t containing the expected digest */
+		for (mp = mac->cd_mp; mp != NULL && offset >= MBLKL(mp);
+		    offset -= MBLKL(mp), mp = mp->b_cont);
+		if (mp == NULL) {
+			/*
+			 * The caller specified an offset that is larger than
+			 * the total size of the buffers it provided.
+			 */
+			ret = CRYPTO_DATA_LEN_RANGE;
+			break;
+		}
+
+		while (mp != NULL && length > 0) {
+			cur_len = MIN(MBLKL(mp) - offset, length);
+			if (bcmp(digest + scratch_offset,
+			    mp->b_rptr + offset, cur_len) != 0) {
+				ret = CRYPTO_INVALID_MAC;
+				break;
+			}
+
+			length -= cur_len;
+			mp = mp->b_cont;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+		break;
+	}
+
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
+	return (ret);
+bail:
+	bzero(&md5_hmac_ctx, sizeof (md5_hmac_ctx_t));
+	mac->cd_length = 0;
+	return (ret);
+}
+
+/*
+ * KCF software provider context management entry points.
+ */
+
+/* ARGSUSED */
+static int
+md5_create_ctx_template(crypto_provider_handle_t provider,
+    crypto_mechanism_t *mechanism, crypto_key_t *key,
+    crypto_spi_ctx_template_t *ctx_template, size_t *ctx_template_size,
+    crypto_req_handle_t req)
+{
+	md5_hmac_ctx_t *md5_hmac_ctx_tmpl;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if ((mechanism->cm_type != MD5_HMAC_MECH_INFO_TYPE) &&
+	    (mechanism->cm_type != MD5_HMAC_GEN_MECH_INFO_TYPE))
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Allocate and initialize MD5 context.
+	 */
+	md5_hmac_ctx_tmpl = kmem_alloc(sizeof (md5_hmac_ctx_t),
+	    crypto_kmflag(req));
+	if (md5_hmac_ctx_tmpl == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	if (keylen_in_bytes > MD5_HMAC_BLOCK_SIZE) {
+		uchar_t digested_key[MD5_DIGEST_LENGTH];
+
+		/*
+		 * Hash the passed-in key to get a smaller key.
+		 * The inner context is used since it hasn't been
+		 * initialized yet.
+		 */
+		PROV_MD5_DIGEST_KEY(&md5_hmac_ctx_tmpl->hc_icontext,
+		    key->ck_data, keylen_in_bytes, digested_key);
+		md5_mac_init_ctx(md5_hmac_ctx_tmpl, digested_key,
+		    MD5_DIGEST_LENGTH);
+	} else {
+		md5_mac_init_ctx(md5_hmac_ctx_tmpl, key->ck_data,
+		    keylen_in_bytes);
+	}
+
+	md5_hmac_ctx_tmpl->hc_mech_type = mechanism->cm_type;
+	*ctx_template = (crypto_spi_ctx_template_t)md5_hmac_ctx_tmpl;
+	*ctx_template_size = sizeof (md5_hmac_ctx_t);
+
+	return (CRYPTO_SUCCESS);
+}
+
+static int
+md5_free_context(crypto_ctx_t *ctx)
+{
+	uint_t ctx_len;
+	md5_mech_type_t mech_type;
+
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_SUCCESS);
+
+	/*
+	 * We have to free either MD5 or MD5-HMAC contexts, which
+	 * have different lengths.
+	 */
+
+	mech_type = PROV_MD5_CTX(ctx)->mc_mech_type;
+	if (mech_type == MD5_MECH_INFO_TYPE)
+		ctx_len = sizeof (md5_ctx_t);
+	else {
+		ASSERT(mech_type == MD5_HMAC_MECH_INFO_TYPE ||
+		    mech_type == MD5_HMAC_GEN_MECH_INFO_TYPE);
+		ctx_len = sizeof (md5_hmac_ctx_t);
+	}
+
+	bzero(ctx->cc_provider_private, ctx_len);
+	kmem_free(ctx->cc_provider_private, ctx_len);
+	ctx->cc_provider_private = NULL;
+
+	return (CRYPTO_SUCCESS);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/uts/common/crypto/io/sha1_mod.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,1471 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <sys/modctl.h>
+#include <sys/cmn_err.h>
+#include <sys/note.h>
+#include <sys/crypto/common.h>
+#include <sys/crypto/spi.h>
+#include <sys/strsun.h>
+#include <sys/systm.h>
+#include <sys/sysmacros.h>
+
+#include <sys/sha1.h>
+
+/*
+ * The sha1 module is created with two modlinkages:
+ * - a modlmisc that allows consumers to directly call the entry points
+ *   SHA1Init, SHA1Update, and SHA1Final.
+ * - a modlcrypto that allows the module to register with the Kernel
+ *   Cryptographic Framework (KCF) as a software provider for the SHA1
+ *   mechanisms.
+ */
+
+static struct modlmisc modlmisc = {
+	&mod_miscops,
+	"SHA1 Message-Digest Algorithm"
+};
+
+static struct modlcrypto modlcrypto = {
+	&mod_cryptoops,
+	"SHA1 Kernel SW Provider 1.1"
+};
+
+static struct modlinkage modlinkage = {
+	MODREV_1, &modlmisc, &modlcrypto, NULL
+};
+
+/*
+ * CSPI information (entry points, provider info, etc.)
+ */
+
+typedef enum sha1_mech_type {
+	SHA1_MECH_INFO_TYPE,		/* SUN_CKM_SHA1 */
+	SHA1_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA1_HMAC */
+	SHA1_HMAC_GEN_MECH_INFO_TYPE	/* SUN_CKM_SHA1_HMAC_GENERAL */
+} sha1_mech_type_t;
+
+#define	SHA1_DIGEST_LENGTH	20	/* SHA1 digest length in bytes */
+#define	SHA1_HMAC_BLOCK_SIZE	64	/* SHA1-HMAC block size */
+#define	SHA1_HMAC_MIN_KEY_LEN	8	/* SHA1-HMAC min key length in bits */
+#define	SHA1_HMAC_MAX_KEY_LEN	INT_MAX /* SHA1-HMAC max key length in bits */
+#define	SHA1_HMAC_INTS_PER_BLOCK	(SHA1_HMAC_BLOCK_SIZE/sizeof (uint32_t))
+
+/*
+ * Context for SHA1 mechanism.
+ */
+typedef struct sha1_ctx {
+	sha1_mech_type_t	sc_mech_type;	/* type of context */
+	SHA1_CTX		sc_sha1_ctx;	/* SHA1 context */
+} sha1_ctx_t;
+
+/*
+ * Context for SHA1-HMAC and SHA1-HMAC-GENERAL mechanisms.
+ */
+typedef struct sha1_hmac_ctx {
+	sha1_mech_type_t	hc_mech_type;	/* type of context */
+	uint32_t		hc_digest_len;	/* digest len in bytes */
+	SHA1_CTX		hc_icontext;	/* inner SHA1 context */
+	SHA1_CTX		hc_ocontext;	/* outer SHA1 context */
+} sha1_hmac_ctx_t;
+
+/*
+ * Macros to access the SHA1 or SHA1-HMAC contexts from a context passed
+ * by KCF to one of the entry points.
+ */
+
+#define	PROV_SHA1_CTX(ctx)	((sha1_ctx_t *)(ctx)->cc_provider_private)
+#define	PROV_SHA1_HMAC_CTX(ctx)	((sha1_hmac_ctx_t *)(ctx)->cc_provider_private)
+
+/* to extract the digest length passed as mechanism parameter */
+#define	PROV_SHA1_GET_DIGEST_LEN(m, len) {				\
+	if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))		\
+		(len) = (uint32_t)*((ulong_t *)mechanism->cm_param);	\
+	else {								\
+		ulong_t tmp_ulong;					\
+		bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));	\
+		(len) = (uint32_t)tmp_ulong;				\
+	}								\
+}
+
+#define	PROV_SHA1_DIGEST_KEY(ctx, key, len, digest) {	\
+	SHA1Init(ctx);					\
+	SHA1Update(ctx, key, len);			\
+	SHA1Final(digest, ctx);				\
+}
+
+/*
+ * Mechanism info structure passed to KCF during registration.
+ */
+static crypto_mech_info_t sha1_mech_info_tab[] = {
+	/* SHA1 */
+	{SUN_CKM_SHA1, SHA1_MECH_INFO_TYPE,
+	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
+	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA1-HMAC */
+	{SUN_CKM_SHA1_HMAC, SHA1_HMAC_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA1_HMAC_MIN_KEY_LEN, SHA1_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA1-HMAC GENERAL */
+	{SUN_CKM_SHA1_HMAC_GENERAL, SHA1_HMAC_GEN_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA1_HMAC_MIN_KEY_LEN, SHA1_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS}
+};
+
+static void sha1_provider_status(crypto_provider_handle_t, uint_t *);
+
+static crypto_control_ops_t sha1_control_ops = {
+	sha1_provider_status
+};
+
+static int sha1_digest_init(crypto_ctx_t *, crypto_mechanism_t *,
+    crypto_req_handle_t);
+static int sha1_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha1_digest_update(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha1_digest_final(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha1_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
+    crypto_req_handle_t);
+
+static crypto_digest_ops_t sha1_digest_ops = {
+	sha1_digest_init,
+	sha1_digest,
+	sha1_digest_update,
+	NULL,
+	sha1_digest_final,
+	sha1_digest_atomic
+};
+
+static int sha1_mac_init(crypto_ctx_t *, crypto_mechanism_t *, crypto_key_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+static int sha1_mac_update(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha1_mac_final(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
+static int sha1_mac_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+static int sha1_mac_verify_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+
+static crypto_mac_ops_t sha1_mac_ops = {
+	sha1_mac_init,
+	NULL,
+	sha1_mac_update,
+	sha1_mac_final,
+	sha1_mac_atomic,
+	sha1_mac_verify_atomic
+};
+
+static int sha1_create_ctx_template(crypto_provider_handle_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
+    size_t *, crypto_req_handle_t);
+static int sha1_free_context(crypto_ctx_t *);
+
+static crypto_ctx_ops_t sha1_ctx_ops = {
+	sha1_create_ctx_template,
+	sha1_free_context
+};
+
+static crypto_ops_t sha1_crypto_ops = {
+	&sha1_control_ops,
+	&sha1_digest_ops,
+	NULL,
+	&sha1_mac_ops,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	&sha1_ctx_ops
+};
+
+static crypto_provider_info_t sha1_prov_info = {
+	CRYPTO_SPI_VERSION_1,
+	"SHA1 Software Provider",
+	CRYPTO_SW_PROVIDER,
+	{&modlinkage},
+	NULL,
+	&sha1_crypto_ops,
+	sizeof (sha1_mech_info_tab)/sizeof (crypto_mech_info_t),
+	sha1_mech_info_tab
+};
+
+static crypto_kcf_provider_handle_t sha1_prov_handle = NULL;
+
+int
+_init()
+{
+	int ret;
+
+	if ((ret = mod_install(&modlinkage)) != 0)
+		return (ret);
+
+	/*
+	 * Register with KCF. If the registration fails, log an
+	 * error but do not uninstall the module, since the functionality
+	 * provided by misc/sha1 should still be available.
+	 */
+	if ((ret = crypto_register_provider(&sha1_prov_info,
+	    &sha1_prov_handle)) != CRYPTO_SUCCESS)
+		cmn_err(CE_WARN, "sha1 _init: "
+		    "crypto_register_provider() failed (0x%x)", ret);
+
+	return (0);
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+	return (mod_info(&modlinkage, modinfop));
+}
+
+/*
+ * KCF software provider control entry points.
+ */
+/* ARGSUSED */
+static void
+sha1_provider_status(crypto_provider_handle_t provider, uint_t *status)
+{
+	*status = CRYPTO_PROVIDER_READY;
+}
+
+/*
+ * KCF software provider digest entry points.
+ */
+
+static int
+sha1_digest_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
+    crypto_req_handle_t req)
+{
+	if (mechanism->cm_type != SHA1_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/*
+	 * Allocate and initialize SHA1 context.
+	 */
+	ctx->cc_provider_private = kmem_alloc(sizeof (sha1_ctx_t),
+	    crypto_kmflag(req));
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	PROV_SHA1_CTX(ctx)->sc_mech_type = SHA1_MECH_INFO_TYPE;
+	SHA1Init(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx);
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA1 digest update function for uio data.
+ */
+static int
+sha1_digest_update_uio(SHA1_CTX *sha1_ctx, crypto_data_t *data)
+{
+	off_t offset = data->cd_offset;
+	size_t length = data->cd_length;
+	uint_t vec_idx;
+	size_t cur_len;
+
+	/* we support only kernel buffer */
+	if (data->cd_uio->uio_segflg != UIO_SYSSPACE)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Jump to the first iovec containing data to be
+	 * digested.
+	 */
+	for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
+	    offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
+	    offset -= data->cd_uio->uio_iov[vec_idx++].iov_len);
+	if (vec_idx == data->cd_uio->uio_iovcnt) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	/*
+	 * Now do the digesting on the iovecs.
+	 */
+	while (vec_idx < data->cd_uio->uio_iovcnt && length > 0) {
+		cur_len = MIN(data->cd_uio->uio_iov[vec_idx].iov_len -
+		    offset, length);
+
+		SHA1Update(sha1_ctx,
+		    (uint8_t *)data->cd_uio->uio_iov[vec_idx].iov_base + offset,
+		    cur_len);
+
+		length -= cur_len;
+		vec_idx++;
+		offset = 0;
+	}
+
+	if (vec_idx == data->cd_uio->uio_iovcnt && length > 0) {
+		/*
+		 * The end of the specified iovec's was reached but
+		 * the length requested could not be processed, i.e.
+		 * The caller requested to digest more data than it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA1 digest final function for uio data.
+ * digest_len is the length of the desired digest. If digest_len
+ * is smaller than the default SHA1 digest length, the caller
+ * must pass a scratch buffer, digest_scratch, which must
+ * be at least SHA1_DIGEST_LENGTH bytes.
+ */
+static int
+sha1_digest_final_uio(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
+    ulong_t digest_len, uchar_t *digest_scratch)
+{
+	off_t offset = digest->cd_offset;
+	uint_t vec_idx;
+
+	/* we support only kernel buffer */
+	if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Jump to the first iovec containing ptr to the digest to
+	 * be returned.
+	 */
+	for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
+	    vec_idx < digest->cd_uio->uio_iovcnt;
+	    offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len);
+	if (vec_idx == digest->cd_uio->uio_iovcnt) {
+		/*
+		 * The caller specified an offset that is
+		 * larger than the total size of the buffers
+		 * it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	if (offset + digest_len <=
+	    digest->cd_uio->uio_iov[vec_idx].iov_len) {
+		/*
+		 * The computed SHA1 digest will fit in the current
+		 * iovec.
+		 */
+		if (digest_len != SHA1_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA1Final(digest_scratch, sha1_ctx);
+			bcopy(digest_scratch, (uchar_t *)digest->
+			    cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    digest_len);
+		} else {
+			SHA1Final((uchar_t *)digest->
+			    cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    sha1_ctx);
+		}
+	} else {
+		/*
+		 * The computed digest will be crossing one or more iovec's.
+		 * This is bad performance-wise but we need to support it.
+		 * Allocate a small scratch buffer on the stack and
+		 * copy it piece meal to the specified digest iovec's.
+		 */
+		uchar_t digest_tmp[SHA1_DIGEST_LENGTH];
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		SHA1Final(digest_tmp, sha1_ctx);
+
+		while (vec_idx < digest->cd_uio->uio_iovcnt && length > 0) {
+			cur_len = MIN(digest->cd_uio->uio_iov[vec_idx].iov_len -
+			    offset, length);
+			bcopy(digest_tmp + scratch_offset,
+			    digest->cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    cur_len);
+
+			length -= cur_len;
+			vec_idx++;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+
+		if (vec_idx == digest->cd_uio->uio_iovcnt && length > 0) {
+			/*
+			 * The end of the specified iovec's was reached but
+			 * the length requested could not be processed, i.e.
+			 * The caller requested to digest more data than it
+			 * provided.
+			 */
+			return (CRYPTO_DATA_LEN_RANGE);
+		}
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA1 digest update for mblk's.
+ */
+static int
+sha1_digest_update_mblk(SHA1_CTX *sha1_ctx, crypto_data_t *data)
+{
+	off_t offset = data->cd_offset;
+	size_t length = data->cd_length;
+	mblk_t *mp;
+	size_t cur_len;
+
+	/*
+	 * Jump to the first mblk_t containing data to be digested.
+	 */
+	for (mp = data->cd_mp; mp != NULL && offset >= MBLKL(mp);
+	    offset -= MBLKL(mp), mp = mp->b_cont);
+	if (mp == NULL) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	/*
+	 * Now do the digesting on the mblk chain.
+	 */
+	while (mp != NULL && length > 0) {
+		cur_len = MIN(MBLKL(mp) - offset, length);
+		SHA1Update(sha1_ctx, mp->b_rptr + offset, cur_len);
+		length -= cur_len;
+		offset = 0;
+		mp = mp->b_cont;
+	}
+
+	if (mp == NULL && length > 0) {
+		/*
+		 * The end of the mblk was reached but the length requested
+		 * could not be processed, i.e. The caller requested
+		 * to digest more data than it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA1 digest final for mblk's.
+ * digest_len is the length of the desired digest. If digest_len
+ * is smaller than the default SHA1 digest length, the caller
+ * must pass a scratch buffer, digest_scratch, which must
+ * be at least SHA1_DIGEST_LENGTH bytes.
+ */
+static int
+sha1_digest_final_mblk(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
+    ulong_t digest_len, uchar_t *digest_scratch)
+{
+	off_t offset = digest->cd_offset;
+	mblk_t *mp;
+
+	/*
+	 * Jump to the first mblk_t that will be used to store the digest.
+	 */
+	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
+	    offset -= MBLKL(mp), mp = mp->b_cont);
+	if (mp == NULL) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	if (offset + digest_len <= MBLKL(mp)) {
+		/*
+		 * The computed SHA1 digest will fit in the current mblk.
+		 * Do the SHA1Final() in-place.
+		 */
+		if (digest_len != SHA1_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA1Final(digest_scratch, sha1_ctx);
+			bcopy(digest_scratch, mp->b_rptr + offset, digest_len);
+		} else {
+			SHA1Final(mp->b_rptr + offset, sha1_ctx);
+		}
+	} else {
+		/*
+		 * The computed digest will be crossing one or more mblk's.
+		 * This is bad performance-wise but we need to support it.
+		 * Allocate a small scratch buffer on the stack and
+		 * copy it piece meal to the specified digest iovec's.
+		 */
+		uchar_t digest_tmp[SHA1_DIGEST_LENGTH];
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		SHA1Final(digest_tmp, sha1_ctx);
+
+		while (mp != NULL && length > 0) {
+			cur_len = MIN(MBLKL(mp) - offset, length);
+			bcopy(digest_tmp + scratch_offset,
+			    mp->b_rptr + offset, cur_len);
+
+			length -= cur_len;
+			mp = mp->b_cont;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+
+		if (mp == NULL && length > 0) {
+			/*
+			 * The end of the specified mblk was reached but
+			 * the length requested could not be processed, i.e.
+			 * The caller requested to digest more data than it
+			 * provided.
+			 */
+			return (CRYPTO_DATA_LEN_RANGE);
+		}
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/* ARGSUSED */
+static int
+sha1_digest(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((digest->cd_length == 0) ||
+	    (digest->cd_length < SHA1_DIGEST_LENGTH)) {
+		digest->cd_length = SHA1_DIGEST_LENGTH;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do the SHA1 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Update(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_update_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_update_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		/* the update failed, free context and bail */
+		kmem_free(ctx->cc_provider_private, sizeof (sha1_ctx_t));
+		ctx->cc_provider_private = NULL;
+		digest->cd_length = 0;
+		return (ret);
+	}
+
+	/*
+	 * Do a SHA1 final, must be done separately since the digest
+	 * type can be different than the input data type.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &PROV_SHA1_CTX(ctx)->sc_sha1_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_final_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    digest, SHA1_DIGEST_LENGTH, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_final_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    digest, SHA1_DIGEST_LENGTH, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/* all done, free context and return */
+
+	if (ret == CRYPTO_SUCCESS) {
+		digest->cd_length = SHA1_DIGEST_LENGTH;
+	} else {
+		digest->cd_length = 0;
+	}
+
+	kmem_free(ctx->cc_provider_private, sizeof (sha1_ctx_t));
+	ctx->cc_provider_private = NULL;
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha1_digest_update(crypto_ctx_t *ctx, crypto_data_t *data,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * Do the SHA1 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Update(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_update_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_update_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha1_digest_final(crypto_ctx_t *ctx, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((digest->cd_length == 0) ||
+	    (digest->cd_length < SHA1_DIGEST_LENGTH)) {
+		digest->cd_length = SHA1_DIGEST_LENGTH;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do a SHA1 final.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &PROV_SHA1_CTX(ctx)->sc_sha1_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_final_uio(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    digest, SHA1_DIGEST_LENGTH, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_final_mblk(&PROV_SHA1_CTX(ctx)->sc_sha1_ctx,
+		    digest, SHA1_DIGEST_LENGTH, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/* all done, free context and return */
+
+	if (ret == CRYPTO_SUCCESS) {
+		digest->cd_length = SHA1_DIGEST_LENGTH;
+	} else {
+		digest->cd_length = 0;
+	}
+
+	kmem_free(ctx->cc_provider_private, sizeof (sha1_ctx_t));
+	ctx->cc_provider_private = NULL;
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha1_digest_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_data_t *data, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	SHA1_CTX sha1_ctx;
+
+	if (mechanism->cm_type != SHA1_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/*
+	 * Do the SHA1 init.
+	 */
+	SHA1Init(&sha1_ctx);
+
+	/*
+	 * Do the SHA1 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Update(&sha1_ctx,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_update_uio(&sha1_ctx, data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_update_mblk(&sha1_ctx, data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		/* the update failed, bail */
+		digest->cd_length = 0;
+		return (ret);
+	}
+
+	/*
+	 * Do a SHA1 final, must be done separately since the digest
+	 * type can be different than the input data type.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &sha1_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_final_uio(&sha1_ctx, digest,
+		    SHA1_DIGEST_LENGTH, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_final_mblk(&sha1_ctx, digest,
+		    SHA1_DIGEST_LENGTH, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		digest->cd_length = SHA1_DIGEST_LENGTH;
+	} else {
+		digest->cd_length = 0;
+	}
+
+	return (ret);
+}
+
+/*
+ * KCF software provider mac entry points.
+ *
+ * SHA1 HMAC is: SHA1(key XOR opad, SHA1(key XOR ipad, text))
+ *
+ * Init:
+ * The initialization routine initializes what we denote
+ * as the inner and outer contexts by doing
+ * - for inner context: SHA1(key XOR ipad)
+ * - for outer context: SHA1(key XOR opad)
+ *
+ * Update:
+ * Each subsequent SHA1 HMAC update will result in an
+ * update of the inner context with the specified data.
+ *
+ * Final:
+ * The SHA1 HMAC final will do a SHA1 final operation on the
+ * inner context, and the resulting digest will be used
+ * as the data for an update on the outer context. Last
+ * but not least, a SHA1 final on the outer context will
+ * be performed to obtain the SHA1 HMAC digest to return
+ * to the user.
+ */
+
+/*
+ * Initialize a SHA1-HMAC context.
+ */
+static void
+sha1_mac_init_ctx(sha1_hmac_ctx_t *ctx, void *keyval, uint_t length_in_bytes)
+{
+	uint32_t ipad[SHA1_HMAC_INTS_PER_BLOCK];
+	uint32_t opad[SHA1_HMAC_INTS_PER_BLOCK];
+	uint_t i;
+
+	bzero(ipad, SHA1_HMAC_BLOCK_SIZE);
+	bzero(opad, SHA1_HMAC_BLOCK_SIZE);
+
+	bcopy(keyval, ipad, length_in_bytes);
+	bcopy(keyval, opad, length_in_bytes);
+
+	/* XOR key with ipad (0x36) and opad (0x5c) */
+	for (i = 0; i < SHA1_HMAC_INTS_PER_BLOCK; i++) {
+		ipad[i] ^= 0x36363636;
+		opad[i] ^= 0x5c5c5c5c;
+	}
+
+	/* perform SHA1 on ipad */
+	SHA1Init(&ctx->hc_icontext);
+	SHA1Update(&ctx->hc_icontext, (uint8_t *)ipad, SHA1_HMAC_BLOCK_SIZE);
+
+	/* perform SHA1 on opad */
+	SHA1Init(&ctx->hc_ocontext);
+	SHA1Update(&ctx->hc_ocontext, (uint8_t *)opad, SHA1_HMAC_BLOCK_SIZE);
+}
+
+/*
+ */
+static int
+sha1_mac_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if (mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE &&
+	    mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	ctx->cc_provider_private = kmem_alloc(sizeof (sha1_hmac_ctx_t),
+	    crypto_kmflag(req));
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, PROV_SHA1_HMAC_CTX(ctx),
+		    sizeof (sha1_hmac_ctx_t));
+	} else {
+		/* no context template, compute context */
+		if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
+			uchar_t digested_key[SHA1_DIGEST_LENGTH];
+			sha1_hmac_ctx_t *hmac_ctx = ctx->cc_provider_private;
+
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_SHA1_DIGEST_KEY(&hmac_ctx->hc_icontext,
+			    key->ck_data, keylen_in_bytes, digested_key);
+			sha1_mac_init_ctx(PROV_SHA1_HMAC_CTX(ctx),
+			    digested_key, SHA1_DIGEST_LENGTH);
+		} else {
+			sha1_mac_init_ctx(PROV_SHA1_HMAC_CTX(ctx),
+			    key->ck_data, keylen_in_bytes);
+		}
+	}
+
+	/*
+	 * Get the mechanism parameters, if applicable.
+	 */
+	PROV_SHA1_HMAC_CTX(ctx)->hc_mech_type = mechanism->cm_type;
+	if (mechanism->cm_type == SHA1_HMAC_GEN_MECH_INFO_TYPE) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t))
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+		PROV_SHA1_GET_DIGEST_LEN(mechanism,
+		    PROV_SHA1_HMAC_CTX(ctx)->hc_digest_len);
+		if (PROV_SHA1_HMAC_CTX(ctx)->hc_digest_len >
+		    SHA1_DIGEST_LENGTH)
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		bzero(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
+		kmem_free(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
+		ctx->cc_provider_private = NULL;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha1_mac_update(crypto_ctx_t *ctx, crypto_data_t *data, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * Do a SHA1 update of the inner context using the specified
+	 * data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA1Update(&PROV_SHA1_HMAC_CTX(ctx)->hc_icontext,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_update_uio(
+		    &PROV_SHA1_HMAC_CTX(ctx)->hc_icontext, data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_update_mblk(
+		    &PROV_SHA1_HMAC_CTX(ctx)->hc_icontext, data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha1_mac_final(crypto_ctx_t *ctx, crypto_data_t *mac, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[SHA1_DIGEST_LENGTH];
+	uint32_t digest_len = SHA1_DIGEST_LENGTH;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	if (PROV_SHA1_HMAC_CTX(ctx)->hc_mech_type ==
+	    SHA1_HMAC_GEN_MECH_INFO_TYPE)
+		digest_len = PROV_SHA1_HMAC_CTX(ctx)->hc_digest_len;
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((mac->cd_length == 0) || (mac->cd_length < digest_len)) {
+		mac->cd_length = digest_len;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do a SHA1 final on the inner context.
+	 */
+	SHA1Final(digest, &PROV_SHA1_HMAC_CTX(ctx)->hc_icontext);
+
+	/*
+	 * Do a SHA1 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	SHA1Update(&PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext, digest,
+	    SHA1_DIGEST_LENGTH);
+
+	/*
+	 * Do a SHA1 final on the outer context, storing the computing
+	 * digest in the users buffer.
+	 */
+	switch (mac->cd_format) {
+	case CRYPTO_DATA_RAW:
+		if (digest_len != SHA1_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA1Final(digest,
+			    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext);
+			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, digest_len);
+		} else {
+			SHA1Final((unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset,
+			    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext);
+		}
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_final_uio(
+		    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_final_mblk(
+		    &PROV_SHA1_HMAC_CTX(ctx)->hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		mac->cd_length = digest_len;
+	} else {
+		mac->cd_length = 0;
+	}
+
+	bzero(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
+	kmem_free(ctx->cc_provider_private, sizeof (sha1_hmac_ctx_t));
+	ctx->cc_provider_private = NULL;
+
+	return (ret);
+}
+
+#define	SHA1_MAC_UPDATE(data, ctx, ret) {				\
+	switch (data->cd_format) {					\
+	case CRYPTO_DATA_RAW:						\
+		SHA1Update(&(ctx).hc_icontext,				\
+		    (uint8_t *)data->cd_raw.iov_base +			\
+		    data->cd_offset, data->cd_length);			\
+		break;							\
+	case CRYPTO_DATA_UIO:						\
+		ret = sha1_digest_update_uio(&(ctx).hc_icontext, data); \
+		break;							\
+	case CRYPTO_DATA_MBLK:						\
+		ret = sha1_digest_update_mblk(&(ctx).hc_icontext,	\
+		    data);						\
+		break;							\
+	default:							\
+		ret = CRYPTO_ARGUMENTS_BAD;				\
+	}								\
+}
+
+/* ARGSUSED */
+static int
+sha1_mac_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
+    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[SHA1_DIGEST_LENGTH];
+	sha1_hmac_ctx_t sha1_hmac_ctx;
+	uint32_t digest_len = SHA1_DIGEST_LENGTH;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if (mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE &&
+	    mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, &sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
+	} else {
+		/* no context template, initialize context */
+		if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_SHA1_DIGEST_KEY(&sha1_hmac_ctx.hc_icontext,
+			    key->ck_data, keylen_in_bytes, digest);
+			sha1_mac_init_ctx(&sha1_hmac_ctx, digest,
+			    SHA1_DIGEST_LENGTH);
+		} else {
+			sha1_mac_init_ctx(&sha1_hmac_ctx, key->ck_data,
+			    keylen_in_bytes);
+		}
+	}
+
+	/* get the mechanism parameters, if applicable */
+	if (mechanism->cm_type == SHA1_HMAC_GEN_MECH_INFO_TYPE) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t)) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+		PROV_SHA1_GET_DIGEST_LEN(mechanism, digest_len);
+		if (digest_len > SHA1_DIGEST_LENGTH) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+	}
+
+	/* do a SHA1 update of the inner context using the specified data */
+	SHA1_MAC_UPDATE(data, sha1_hmac_ctx, ret);
+	if (ret != CRYPTO_SUCCESS)
+		/* the update failed, free context and bail */
+		goto bail;
+
+	/*
+	 * Do a SHA1 final on the inner context.
+	 */
+	SHA1Final(digest, &sha1_hmac_ctx.hc_icontext);
+
+	/*
+	 * Do an SHA1 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	SHA1Update(&sha1_hmac_ctx.hc_ocontext, digest, SHA1_DIGEST_LENGTH);
+
+	/*
+	 * Do a SHA1 final on the outer context, storing the computed
+	 * digest in the users buffer.
+	 */
+	switch (mac->cd_format) {
+	case CRYPTO_DATA_RAW:
+		if (digest_len != SHA1_DIGEST_LENGTH) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA1Final(digest, &sha1_hmac_ctx.hc_ocontext);
+			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, digest_len);
+		} else {
+			SHA1Final((unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, &sha1_hmac_ctx.hc_ocontext);
+		}
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha1_digest_final_uio(&sha1_hmac_ctx.hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha1_digest_final_mblk(&sha1_hmac_ctx.hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		mac->cd_length = digest_len;
+	} else {
+		mac->cd_length = 0;
+	}
+	/* Extra paranoia: zeroize the context on the stack */
+	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
+
+	return (ret);
+bail:
+	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
+	mac->cd_length = 0;
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha1_mac_verify_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
+    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[SHA1_DIGEST_LENGTH];
+	sha1_hmac_ctx_t sha1_hmac_ctx;
+	uint32_t digest_len = SHA1_DIGEST_LENGTH;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if (mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE &&
+	    mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)
+		return (CRYPTO_MECHANISM_INVALID);
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, &sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
+	} else {
+		/* no context template, initialize context */
+		if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_SHA1_DIGEST_KEY(&sha1_hmac_ctx.hc_icontext,
+			    key->ck_data, keylen_in_bytes, digest);
+			sha1_mac_init_ctx(&sha1_hmac_ctx, digest,
+			    SHA1_DIGEST_LENGTH);
+		} else {
+			sha1_mac_init_ctx(&sha1_hmac_ctx, key->ck_data,
+			    keylen_in_bytes);
+		}
+	}
+
+	/* get the mechanism parameters, if applicable */
+	if (mechanism->cm_type == SHA1_HMAC_GEN_MECH_INFO_TYPE) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t)) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+		PROV_SHA1_GET_DIGEST_LEN(mechanism, digest_len);
+		if (digest_len > SHA1_DIGEST_LENGTH) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+	}
+
+	if (mac->cd_length != digest_len) {
+		ret = CRYPTO_INVALID_MAC;
+		goto bail;
+	}
+
+	/* do a SHA1 update of the inner context using the specified data */
+	SHA1_MAC_UPDATE(data, sha1_hmac_ctx, ret);
+	if (ret != CRYPTO_SUCCESS)
+		/* the update failed, free context and bail */
+		goto bail;
+
+	/* do a SHA1 final on the inner context */
+	SHA1Final(digest, &sha1_hmac_ctx.hc_icontext);
+
+	/*
+	 * Do an SHA1 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	SHA1Update(&sha1_hmac_ctx.hc_ocontext, digest, SHA1_DIGEST_LENGTH);
+
+	/*
+	 * Do a SHA1 final on the outer context, storing the computed
+	 * digest in the users buffer.
+	 */
+	SHA1Final(digest, &sha1_hmac_ctx.hc_ocontext);
+
+	/*
+	 * Compare the computed digest against the expected digest passed
+	 * as argument.
+	 */
+
+	switch (mac->cd_format) {
+
+	case CRYPTO_DATA_RAW:
+		if (bcmp(digest, (unsigned char *)mac->cd_raw.iov_base +
+		    mac->cd_offset, digest_len) != 0)
+			ret = CRYPTO_INVALID_MAC;
+		break;
+
+	case CRYPTO_DATA_UIO: {
+		off_t offset = mac->cd_offset;
+		uint_t vec_idx;
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		/* we support only kernel buffer */
+		if (mac->cd_uio->uio_segflg != UIO_SYSSPACE)
+			return (CRYPTO_ARGUMENTS_BAD);
+
+		/* jump to the first iovec containing the expected digest */
+		for (vec_idx = 0;
+		    offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
+		    vec_idx < mac->cd_uio->uio_iovcnt;
+		    offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len);
+		if (vec_idx == mac->cd_uio->uio_iovcnt) {
+			/*
+			 * The caller specified an offset that is
+			 * larger than the total size of the buffers
+			 * it provided.
+			 */
+			ret = CRYPTO_DATA_LEN_RANGE;
+			break;
+		}
+
+		/* do the comparison of computed digest vs specified one */
+		while (vec_idx < mac->cd_uio->uio_iovcnt && length > 0) {
+			cur_len = MIN(mac->cd_uio->uio_iov[vec_idx].iov_len -
+			    offset, length);
+
+			if (bcmp(digest + scratch_offset,
+			    mac->cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    cur_len) != 0) {
+				ret = CRYPTO_INVALID_MAC;
+				break;
+			}
+
+			length -= cur_len;
+			vec_idx++;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+		break;
+	}
+
+	case CRYPTO_DATA_MBLK: {
+		off_t offset = mac->cd_offset;
+		mblk_t *mp;
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		/* jump to the first mblk_t containing the expected digest */
+		for (mp = mac->cd_mp; mp != NULL && offset >= MBLKL(mp);
+		    offset -= MBLKL(mp), mp = mp->b_cont);
+		if (mp == NULL) {
+			/*
+			 * The caller specified an offset that is larger than
+			 * the total size of the buffers it provided.
+			 */
+			ret = CRYPTO_DATA_LEN_RANGE;
+			break;
+		}
+
+		while (mp != NULL && length > 0) {
+			cur_len = MIN(MBLKL(mp) - offset, length);
+			if (bcmp(digest + scratch_offset,
+			    mp->b_rptr + offset, cur_len) != 0) {
+				ret = CRYPTO_INVALID_MAC;
+				break;
+			}
+
+			length -= cur_len;
+			mp = mp->b_cont;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+		break;
+	}
+
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
+	return (ret);
+bail:
+	bzero(&sha1_hmac_ctx, sizeof (sha1_hmac_ctx_t));
+	mac->cd_length = 0;
+	return (ret);
+}
+
+/*
+ * KCF software provider context management entry points.
+ */
+
+/* ARGSUSED */
+static int
+sha1_create_ctx_template(crypto_provider_handle_t provider,
+    crypto_mechanism_t *mechanism, crypto_key_t *key,
+    crypto_spi_ctx_template_t *ctx_template, size_t *ctx_template_size,
+    crypto_req_handle_t req)
+{
+	sha1_hmac_ctx_t *sha1_hmac_ctx_tmpl;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	if ((mechanism->cm_type != SHA1_HMAC_MECH_INFO_TYPE) &&
+	    (mechanism->cm_type != SHA1_HMAC_GEN_MECH_INFO_TYPE)) {
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Allocate and initialize SHA1 context.
+	 */
+	sha1_hmac_ctx_tmpl = kmem_alloc(sizeof (sha1_hmac_ctx_t),
+	    crypto_kmflag(req));
+	if (sha1_hmac_ctx_tmpl == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	if (keylen_in_bytes > SHA1_HMAC_BLOCK_SIZE) {
+		uchar_t digested_key[SHA1_DIGEST_LENGTH];
+
+		/*
+		 * Hash the passed-in key to get a smaller key.
+		 * The inner context is used since it hasn't been
+		 * initialized yet.
+		 */
+		PROV_SHA1_DIGEST_KEY(&sha1_hmac_ctx_tmpl->hc_icontext,
+		    key->ck_data, keylen_in_bytes, digested_key);
+		sha1_mac_init_ctx(sha1_hmac_ctx_tmpl, digested_key,
+		    SHA1_DIGEST_LENGTH);
+	} else {
+		sha1_mac_init_ctx(sha1_hmac_ctx_tmpl, key->ck_data,
+		    keylen_in_bytes);
+	}
+
+	sha1_hmac_ctx_tmpl->hc_mech_type = mechanism->cm_type;
+	*ctx_template = (crypto_spi_ctx_template_t)sha1_hmac_ctx_tmpl;
+	*ctx_template_size = sizeof (sha1_hmac_ctx_t);
+
+
+	return (CRYPTO_SUCCESS);
+}
+
+static int
+sha1_free_context(crypto_ctx_t *ctx)
+{
+	uint_t ctx_len;
+	sha1_mech_type_t mech_type;
+
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_SUCCESS);
+
+	/*
+	 * We have to free either SHA1 or SHA1-HMAC contexts, which
+	 * have different lengths.
+	 */
+
+	mech_type = PROV_SHA1_CTX(ctx)->sc_mech_type;
+	if (mech_type == SHA1_MECH_INFO_TYPE)
+		ctx_len = sizeof (sha1_ctx_t);
+	else {
+		ASSERT(mech_type == SHA1_HMAC_MECH_INFO_TYPE ||
+		    mech_type == SHA1_HMAC_GEN_MECH_INFO_TYPE);
+		ctx_len = sizeof (sha1_hmac_ctx_t);
+	}
+
+	bzero(ctx->cc_provider_private, ctx_len);
+	kmem_free(ctx->cc_provider_private, ctx_len);
+	ctx->cc_provider_private = NULL;
+
+	return (CRYPTO_SUCCESS);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/uts/common/crypto/io/sha2_mod.c	Tue Mar 28 08:45:30 2006 -0800
@@ -0,0 +1,1618 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <sys/modctl.h>
+#include <sys/cmn_err.h>
+#include <sys/crypto/common.h>
+#include <sys/crypto/spi.h>
+#include <sys/strsun.h>
+#include <sys/systm.h>
+#include <sys/sysmacros.h>
+#define	_SHA2_IMPL
+#include <sys/sha2.h>
+
+/*
+ * The sha2 module is created with two modlinkages:
+ * - a modlmisc that allows consumers to directly call the entry points
+ *   SHA2Init, SHA2Update, and SHA2Final.
+ * - a modlcrypto that allows the module to register with the Kernel
+ *   Cryptographic Framework (KCF) as a software provider for the SHA2
+ *   mechanisms.
+ */
+
+static struct modlmisc modlmisc = {
+	&mod_miscops,
+	"SHA2 Message-Digest Algorithm"
+};
+
+static struct modlcrypto modlcrypto = {
+	&mod_cryptoops,
+	"SHA2 Kernel SW Provider %I%"
+};
+
+static struct modlinkage modlinkage = {
+	MODREV_1, &modlmisc, &modlcrypto, NULL
+};
+
+/*
+ * CSPI information (entry points, provider info, etc.)
+ */
+
+/*
+ * Context for SHA2 mechanism.
+ */
+typedef struct sha2_ctx {
+	sha2_mech_type_t	sc_mech_type;	/* type of context */
+	SHA2_CTX		sc_sha2_ctx;	/* SHA2 context */
+} sha2_ctx_t;
+
+/*
+ * Context for SHA2 HMAC and HMAC GENERAL mechanisms.
+ */
+typedef struct sha2_hmac_ctx {
+	sha2_mech_type_t	hc_mech_type;	/* type of context */
+	uint32_t		hc_digest_len;	/* digest len in bytes */
+	SHA2_CTX		hc_icontext;	/* inner SHA2 context */
+	SHA2_CTX		hc_ocontext;	/* outer SHA2 context */
+} sha2_hmac_ctx_t;
+
+/*
+ * Macros to access the SHA2 or SHA2-HMAC contexts from a context passed
+ * by KCF to one of the entry points.
+ */
+
+#define	PROV_SHA2_CTX(ctx)	((sha2_ctx_t *)(ctx)->cc_provider_private)
+#define	PROV_SHA2_HMAC_CTX(ctx)	((sha2_hmac_ctx_t *)(ctx)->cc_provider_private)
+
+/* to extract the digest length passed as mechanism parameter */
+#define	PROV_SHA2_GET_DIGEST_LEN(m, len) {				\
+	if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))		\
+		(len) = (uint32_t)*((ulong_t *)(m)->cm_param);	\
+	else {								\
+		ulong_t tmp_ulong;					\
+		bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));	\
+		(len) = (uint32_t)tmp_ulong;				\
+	}								\
+}
+
+#define	PROV_SHA2_DIGEST_KEY(mech, ctx, key, len, digest) {	\
+	SHA2Init(mech, ctx);				\
+	SHA2Update(ctx, key, len);			\
+	SHA2Final(digest, ctx);				\
+}
+
+/*
+ * Mechanism info structure passed to KCF during registration.
+ */
+static crypto_mech_info_t sha2_mech_info_tab[] = {
+	/* SHA256 */
+	{SUN_CKM_SHA256, SHA256_MECH_INFO_TYPE,
+	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
+	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA256-HMAC */
+	{SUN_CKM_SHA256_HMAC, SHA256_HMAC_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA256-HMAC GENERAL */
+	{SUN_CKM_SHA256_HMAC_GENERAL, SHA256_HMAC_GEN_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA384 */
+	{SUN_CKM_SHA384, SHA384_MECH_INFO_TYPE,
+	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
+	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA384-HMAC */
+	{SUN_CKM_SHA384_HMAC, SHA384_HMAC_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA384-HMAC GENERAL */
+	{SUN_CKM_SHA384_HMAC_GENERAL, SHA384_HMAC_GEN_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA512 */
+	{SUN_CKM_SHA512, SHA512_MECH_INFO_TYPE,
+	    CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
+	    0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA512-HMAC */
+	{SUN_CKM_SHA512_HMAC, SHA512_HMAC_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS},
+	/* SHA512-HMAC GENERAL */
+	{SUN_CKM_SHA512_HMAC_GENERAL, SHA512_HMAC_GEN_MECH_INFO_TYPE,
+	    CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC,
+	    SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
+	    CRYPTO_KEYSIZE_UNIT_IN_BITS}
+};
+
+static void sha2_provider_status(crypto_provider_handle_t, uint_t *);
+
+static crypto_control_ops_t sha2_control_ops = {
+	sha2_provider_status
+};
+
+static int sha2_digest_init(crypto_ctx_t *, crypto_mechanism_t *,
+    crypto_req_handle_t);
+static int sha2_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha2_digest_update(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha2_digest_final(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha2_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
+    crypto_req_handle_t);
+
+static crypto_digest_ops_t sha2_digest_ops = {
+	sha2_digest_init,
+	sha2_digest,
+	sha2_digest_update,
+	NULL,
+	sha2_digest_final,
+	sha2_digest_atomic
+};
+
+static int sha2_mac_init(crypto_ctx_t *, crypto_mechanism_t *, crypto_key_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+static int sha2_mac_update(crypto_ctx_t *, crypto_data_t *,
+    crypto_req_handle_t);
+static int sha2_mac_final(crypto_ctx_t *, crypto_data_t *, crypto_req_handle_t);
+static int sha2_mac_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+static int sha2_mac_verify_atomic(crypto_provider_handle_t, crypto_session_id_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, crypto_data_t *,
+    crypto_spi_ctx_template_t, crypto_req_handle_t);
+
+static crypto_mac_ops_t sha2_mac_ops = {
+	sha2_mac_init,
+	NULL,
+	sha2_mac_update,
+	sha2_mac_final,
+	sha2_mac_atomic,
+	sha2_mac_verify_atomic
+};
+
+static int sha2_create_ctx_template(crypto_provider_handle_t,
+    crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
+    size_t *, crypto_req_handle_t);
+static int sha2_free_context(crypto_ctx_t *);
+
+static crypto_ctx_ops_t sha2_ctx_ops = {
+	sha2_create_ctx_template,
+	sha2_free_context
+};
+
+static crypto_ops_t sha2_crypto_ops = {
+	&sha2_control_ops,
+	&sha2_digest_ops,
+	NULL,
+	&sha2_mac_ops,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	&sha2_ctx_ops
+};
+
+static crypto_provider_info_t sha2_prov_info = {
+	CRYPTO_SPI_VERSION_1,
+	"SHA2 Software Provider",
+	CRYPTO_SW_PROVIDER,
+	{&modlinkage},
+	NULL,
+	&sha2_crypto_ops,
+	sizeof (sha2_mech_info_tab)/sizeof (crypto_mech_info_t),
+	sha2_mech_info_tab
+};
+
+static crypto_kcf_provider_handle_t sha2_prov_handle = NULL;
+
+int
+_init()
+{
+	int ret;
+
+	if ((ret = mod_install(&modlinkage)) != 0)
+		return (ret);
+
+	/*
+	 * Register with KCF. If the registration fails, log an
+	 * error but do not uninstall the module, since the functionality
+	 * provided by misc/sha2 should still be available.
+	 */
+	if ((ret = crypto_register_provider(&sha2_prov_info,
+	    &sha2_prov_handle)) != CRYPTO_SUCCESS)
+		cmn_err(CE_WARN, "sha2 _init: "
+		    "crypto_register_provider() failed (0x%x)", ret);
+
+	return (0);
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+	return (mod_info(&modlinkage, modinfop));
+}
+
+/*
+ * KCF software provider control entry points.
+ */
+/* ARGSUSED */
+static void
+sha2_provider_status(crypto_provider_handle_t provider, uint_t *status)
+{
+	*status = CRYPTO_PROVIDER_READY;
+}
+
+/*
+ * KCF software provider digest entry points.
+ */
+
+static int
+sha2_digest_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
+    crypto_req_handle_t req)
+{
+
+	/*
+	 * Allocate and initialize SHA2 context.
+	 */
+	ctx->cc_provider_private = kmem_alloc(sizeof (sha2_ctx_t),
+	    crypto_kmflag(req));
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	PROV_SHA2_CTX(ctx)->sc_mech_type = mechanism->cm_type;
+	SHA2Init(mechanism->cm_type, &PROV_SHA2_CTX(ctx)->sc_sha2_ctx);
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA2 digest update function for uio data.
+ */
+static int
+sha2_digest_update_uio(SHA2_CTX *sha2_ctx, crypto_data_t *data)
+{
+	off_t offset = data->cd_offset;
+	size_t length = data->cd_length;
+	uint_t vec_idx;
+	size_t cur_len;
+
+	/* we support only kernel buffer */
+	if (data->cd_uio->uio_segflg != UIO_SYSSPACE)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Jump to the first iovec containing data to be
+	 * digested.
+	 */
+	for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
+	    offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
+	    offset -= data->cd_uio->uio_iov[vec_idx++].iov_len);
+	if (vec_idx == data->cd_uio->uio_iovcnt) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	/*
+	 * Now do the digesting on the iovecs.
+	 */
+	while (vec_idx < data->cd_uio->uio_iovcnt && length > 0) {
+		cur_len = MIN(data->cd_uio->uio_iov[vec_idx].iov_len -
+		    offset, length);
+
+		SHA2Update(sha2_ctx, (uint8_t *)data->cd_uio->
+		    uio_iov[vec_idx].iov_base + offset, cur_len);
+		length -= cur_len;
+		vec_idx++;
+		offset = 0;
+	}
+
+	if (vec_idx == data->cd_uio->uio_iovcnt && length > 0) {
+		/*
+		 * The end of the specified iovec's was reached but
+		 * the length requested could not be processed, i.e.
+		 * The caller requested to digest more data than it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA2 digest final function for uio data.
+ * digest_len is the length of the desired digest. If digest_len
+ * is smaller than the default SHA2 digest length, the caller
+ * must pass a scratch buffer, digest_scratch, which must
+ * be at least the algorithm's digest length bytes.
+ */
+static int
+sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
+    ulong_t digest_len, uchar_t *digest_scratch)
+{
+	off_t offset = digest->cd_offset;
+	uint_t vec_idx;
+
+	/* we support only kernel buffer */
+	if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Jump to the first iovec containing ptr to the digest to
+	 * be returned.
+	 */
+	for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
+	    vec_idx < digest->cd_uio->uio_iovcnt;
+	    offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len);
+	if (vec_idx == digest->cd_uio->uio_iovcnt) {
+		/*
+		 * The caller specified an offset that is
+		 * larger than the total size of the buffers
+		 * it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	if (offset + digest_len <=
+	    digest->cd_uio->uio_iov[vec_idx].iov_len) {
+		/*
+		 * The computed SHA2 digest will fit in the current
+		 * iovec.
+		 */
+		if (((sha2_ctx->algotype <= SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
+		    (digest_len != SHA256_DIGEST_LENGTH)) ||
+		    ((sha2_ctx->algotype > SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
+			(digest_len != SHA512_DIGEST_LENGTH))) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA2Final(digest_scratch, sha2_ctx);
+
+			bcopy(digest_scratch, (uchar_t *)digest->
+			    cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    digest_len);
+		} else {
+			SHA2Final((uchar_t *)digest->
+			    cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    sha2_ctx);
+
+		}
+	} else {
+		/*
+		 * The computed digest will be crossing one or more iovec's.
+		 * This is bad performance-wise but we need to support it.
+		 * Allocate a small scratch buffer on the stack and
+		 * copy it piece meal to the specified digest iovec's.
+		 */
+		uchar_t digest_tmp[SHA512_DIGEST_LENGTH];
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		SHA2Final(digest_tmp, sha2_ctx);
+
+		while (vec_idx < digest->cd_uio->uio_iovcnt && length > 0) {
+			cur_len =
+			    MIN(digest->cd_uio->uio_iov[vec_idx].iov_len -
+				    offset, length);
+			bcopy(digest_tmp + scratch_offset,
+			    digest->cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    cur_len);
+
+			length -= cur_len;
+			vec_idx++;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+
+		if (vec_idx == digest->cd_uio->uio_iovcnt && length > 0) {
+			/*
+			 * The end of the specified iovec's was reached but
+			 * the length requested could not be processed, i.e.
+			 * The caller requested to digest more data than it
+			 * provided.
+			 */
+			return (CRYPTO_DATA_LEN_RANGE);
+		}
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA2 digest update for mblk's.
+ */
+static int
+sha2_digest_update_mblk(SHA2_CTX *sha2_ctx, crypto_data_t *data)
+{
+	off_t offset = data->cd_offset;
+	size_t length = data->cd_length;
+	mblk_t *mp;
+	size_t cur_len;
+
+	/*
+	 * Jump to the first mblk_t containing data to be digested.
+	 */
+	for (mp = data->cd_mp; mp != NULL && offset >= MBLKL(mp);
+	    offset -= MBLKL(mp), mp = mp->b_cont);
+	if (mp == NULL) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	/*
+	 * Now do the digesting on the mblk chain.
+	 */
+	while (mp != NULL && length > 0) {
+		cur_len = MIN(MBLKL(mp) - offset, length);
+		SHA2Update(sha2_ctx, mp->b_rptr + offset, cur_len);
+		length -= cur_len;
+		offset = 0;
+		mp = mp->b_cont;
+	}
+
+	if (mp == NULL && length > 0) {
+		/*
+		 * The end of the mblk was reached but the length requested
+		 * could not be processed, i.e. The caller requested
+		 * to digest more data than it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/*
+ * Helper SHA2 digest final for mblk's.
+ * digest_len is the length of the desired digest. If digest_len
+ * is smaller than the default SHA2 digest length, the caller
+ * must pass a scratch buffer, digest_scratch, which must
+ * be at least the algorithm's digest length bytes.
+ */
+static int
+sha2_digest_final_mblk(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
+    ulong_t digest_len, uchar_t *digest_scratch)
+{
+	off_t offset = digest->cd_offset;
+	mblk_t *mp;
+
+	/*
+	 * Jump to the first mblk_t that will be used to store the digest.
+	 */
+	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
+	    offset -= MBLKL(mp), mp = mp->b_cont);
+	if (mp == NULL) {
+		/*
+		 * The caller specified an offset that is larger than the
+		 * total size of the buffers it provided.
+		 */
+		return (CRYPTO_DATA_LEN_RANGE);
+	}
+
+	if (offset + digest_len <= MBLKL(mp)) {
+		/*
+		 * The computed SHA2 digest will fit in the current mblk.
+		 * Do the SHA2Final() in-place.
+		 */
+		if (((sha2_ctx->algotype <= SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
+		    (digest_len != SHA256_DIGEST_LENGTH)) ||
+		    ((sha2_ctx->algotype > SHA256_HMAC_GEN_MECH_INFO_TYPE) &&
+			(digest_len != SHA512_DIGEST_LENGTH))) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA2Final(digest_scratch, sha2_ctx);
+			bcopy(digest_scratch, mp->b_rptr + offset, digest_len);
+		} else {
+			SHA2Final(mp->b_rptr + offset, sha2_ctx);
+		}
+	} else {
+		/*
+		 * The computed digest will be crossing one or more mblk's.
+		 * This is bad performance-wise but we need to support it.
+		 * Allocate a small scratch buffer on the stack and
+		 * copy it piece meal to the specified digest iovec's.
+		 */
+		uchar_t digest_tmp[SHA512_DIGEST_LENGTH];
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		SHA2Final(digest_tmp, sha2_ctx);
+
+		while (mp != NULL && length > 0) {
+			cur_len = MIN(MBLKL(mp) - offset, length);
+			bcopy(digest_tmp + scratch_offset,
+			    mp->b_rptr + offset, cur_len);
+
+			length -= cur_len;
+			mp = mp->b_cont;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+
+		if (mp == NULL && length > 0) {
+			/*
+			 * The end of the specified mblk was reached but
+			 * the length requested could not be processed, i.e.
+			 * The caller requested to digest more data than it
+			 * provided.
+			 */
+			return (CRYPTO_DATA_LEN_RANGE);
+		}
+	}
+
+	return (CRYPTO_SUCCESS);
+}
+
+/* ARGSUSED */
+static int
+sha2_digest(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uint_t sha_digest_len;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	switch (PROV_SHA2_CTX(ctx)->sc_mech_type) {
+	case SHA256_MECH_INFO_TYPE:
+		sha_digest_len = SHA256_DIGEST_LENGTH;
+		break;
+	case SHA384_MECH_INFO_TYPE:
+		sha_digest_len = SHA384_DIGEST_LENGTH;
+		break;
+	case SHA512_MECH_INFO_TYPE:
+		sha_digest_len = SHA512_DIGEST_LENGTH;
+		break;
+	default:
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((digest->cd_length == 0) ||
+	    (digest->cd_length < sha_digest_len)) {
+		digest->cd_length = sha_digest_len;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do the SHA2 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Update(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_update_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_update_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		/* the update failed, free context and bail */
+		kmem_free(ctx->cc_provider_private, sizeof (sha2_ctx_t));
+		ctx->cc_provider_private = NULL;
+		digest->cd_length = 0;
+		return (ret);
+	}
+
+	/*
+	 * Do a SHA2 final, must be done separately since the digest
+	 * type can be different than the input data type.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &PROV_SHA2_CTX(ctx)->sc_sha2_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_final_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    digest, sha_digest_len, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_final_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    digest, sha_digest_len, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/* all done, free context and return */
+
+	if (ret == CRYPTO_SUCCESS)
+		digest->cd_length = sha_digest_len;
+	else
+		digest->cd_length = 0;
+
+	kmem_free(ctx->cc_provider_private, sizeof (sha2_ctx_t));
+	ctx->cc_provider_private = NULL;
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha2_digest_update(crypto_ctx_t *ctx, crypto_data_t *data,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * Do the SHA2 update on the specified input data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Update(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_update_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_update_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha2_digest_final(crypto_ctx_t *ctx, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uint_t sha_digest_len;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	switch (PROV_SHA2_CTX(ctx)->sc_mech_type) {
+	case SHA256_MECH_INFO_TYPE:
+		sha_digest_len = SHA256_DIGEST_LENGTH;
+		break;
+	case SHA384_MECH_INFO_TYPE:
+		sha_digest_len = SHA384_DIGEST_LENGTH;
+		break;
+	case SHA512_MECH_INFO_TYPE:
+		sha_digest_len = SHA512_DIGEST_LENGTH;
+		break;
+	default:
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((digest->cd_length == 0) ||
+	    (digest->cd_length < sha_digest_len)) {
+		digest->cd_length = sha_digest_len;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do a SHA2 final.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &PROV_SHA2_CTX(ctx)->sc_sha2_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_final_uio(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    digest, sha_digest_len, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_final_mblk(&PROV_SHA2_CTX(ctx)->sc_sha2_ctx,
+		    digest, sha_digest_len, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/* all done, free context and return */
+
+	if (ret == CRYPTO_SUCCESS)
+		digest->cd_length = sha_digest_len;
+	else
+		digest->cd_length = 0;
+
+	kmem_free(ctx->cc_provider_private, sizeof (sha2_ctx_t));
+	ctx->cc_provider_private = NULL;
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha2_digest_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_data_t *data, crypto_data_t *digest,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	SHA2_CTX sha2_ctx;
+	uint32_t sha_digest_len;
+
+	/*
+	 * Do the SHA inits.
+	 */
+
+	SHA2Init(mechanism->cm_type, &sha2_ctx);
+
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Update(&sha2_ctx, (uint8_t *)data->
+		    cd_raw.iov_base + data->cd_offset, data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_update_uio(&sha2_ctx, data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_update_mblk(&sha2_ctx, data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	/*
+	 * Do the SHA updates on the specified input data.
+	 */
+
+	if (ret != CRYPTO_SUCCESS) {
+		/* the update failed, bail */
+		digest->cd_length = 0;
+		return (ret);
+	}
+
+	if (mechanism->cm_type <= SHA256_HMAC_GEN_MECH_INFO_TYPE)
+		sha_digest_len = SHA256_DIGEST_LENGTH;
+	else
+		sha_digest_len = SHA512_DIGEST_LENGTH;
+
+	/*
+	 * Do a SHA2 final, must be done separately since the digest
+	 * type can be different than the input data type.
+	 */
+	switch (digest->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Final((unsigned char *)digest->cd_raw.iov_base +
+		    digest->cd_offset, &sha2_ctx);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_final_uio(&sha2_ctx, digest,
+		    sha_digest_len, NULL);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_final_mblk(&sha2_ctx, digest,
+		    sha_digest_len, NULL);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS)
+		digest->cd_length = sha_digest_len;
+	else
+		digest->cd_length = 0;
+
+	return (ret);
+}
+
+/*
+ * KCF software provider mac entry points.
+ *
+ * SHA2 HMAC is: SHA2(key XOR opad, SHA2(key XOR ipad, text))
+ *
+ * Init:
+ * The initialization routine initializes what we denote
+ * as the inner and outer contexts by doing
+ * - for inner context: SHA2(key XOR ipad)
+ * - for outer context: SHA2(key XOR opad)
+ *
+ * Update:
+ * Each subsequent SHA2 HMAC update will result in an
+ * update of the inner context with the specified data.
+ *
+ * Final:
+ * The SHA2 HMAC final will do a SHA2 final operation on the
+ * inner context, and the resulting digest will be used
+ * as the data for an update on the outer context. Last
+ * but not least, a SHA2 final on the outer context will
+ * be performed to obtain the SHA2 HMAC digest to return
+ * to the user.
+ */
+
+/*
+ * Initialize a SHA2-HMAC context.
+ */
+static void
+sha2_mac_init_ctx(sha2_hmac_ctx_t *ctx, void *keyval, uint_t length_in_bytes)
+{
+	uint64_t ipad[SHA512_HMAC_BLOCK_SIZE / sizeof (uint64_t)];
+	uint64_t opad[SHA512_HMAC_BLOCK_SIZE / sizeof (uint64_t)];
+	int i, block_size, blocks_per_int64;
+
+	/* Determine the block size */
+	if (ctx->hc_mech_type <= SHA256_HMAC_GEN_MECH_INFO_TYPE) {
+		block_size = SHA256_HMAC_BLOCK_SIZE;
+		blocks_per_int64 = SHA256_HMAC_BLOCK_SIZE / sizeof (uint64_t);
+	} else {
+		block_size = SHA512_HMAC_BLOCK_SIZE;
+		blocks_per_int64 = SHA512_HMAC_BLOCK_SIZE / sizeof (uint64_t);
+	}
+
+	(void) bzero(ipad, block_size);
+	(void) bzero(opad, block_size);
+	(void) bcopy(keyval, ipad, length_in_bytes);
+	(void) bcopy(keyval, opad, length_in_bytes);
+
+	/* XOR key with ipad (0x36) and opad (0x5c) */
+	for (i = 0; i < blocks_per_int64; i ++) {
+		ipad[i] ^= 0x3636363636363636;
+		opad[i] ^= 0x5c5c5c5c5c5c5c5c;
+	}
+
+	/* perform SHA2 on ipad */
+	SHA2Init(ctx->hc_mech_type, &ctx->hc_icontext);
+	SHA2Update(&ctx->hc_icontext, (uint8_t *)ipad, block_size);
+
+	/* perform SHA2 on opad */
+	SHA2Init(ctx->hc_mech_type, &ctx->hc_ocontext);
+	SHA2Update(&ctx->hc_ocontext, (uint8_t *)opad, block_size);
+
+}
+
+/*
+ */
+static int
+sha2_mac_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+	uint_t sha_digest_len, sha_hmac_block_size;
+
+	/*
+	 * Set the digest length and block size to values approriate to the
+	 * mechanism
+	 */
+	switch (mechanism->cm_type) {
+	case SHA256_HMAC_MECH_INFO_TYPE:
+	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = SHA256_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
+		break;
+	case SHA384_HMAC_MECH_INFO_TYPE:
+	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
+	case SHA512_HMAC_MECH_INFO_TYPE:
+	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = SHA512_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
+		break;
+	default:
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	ctx->cc_provider_private = kmem_alloc(sizeof (sha2_hmac_ctx_t),
+	    crypto_kmflag(req));
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, PROV_SHA2_HMAC_CTX(ctx),
+		    sizeof (sha2_hmac_ctx_t));
+	} else {
+		/* no context template, compute context */
+		if (keylen_in_bytes > sha_hmac_block_size) {
+			uchar_t digested_key[SHA512_DIGEST_LENGTH];
+			sha2_hmac_ctx_t *hmac_ctx = ctx->cc_provider_private;
+
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
+			    &hmac_ctx->hc_icontext,
+			    key->ck_data, keylen_in_bytes, digested_key);
+			sha2_mac_init_ctx(PROV_SHA2_HMAC_CTX(ctx),
+			    digested_key, sha_digest_len);
+		} else {
+			sha2_mac_init_ctx(PROV_SHA2_HMAC_CTX(ctx),
+			    key->ck_data, keylen_in_bytes);
+		}
+	}
+
+	/*
+	 * Get the mechanism parameters, if applicable.
+	 */
+	PROV_SHA2_HMAC_CTX(ctx)->hc_mech_type = mechanism->cm_type;
+	if (mechanism->cm_type % 3 == 2) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t))
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+		PROV_SHA2_GET_DIGEST_LEN(mechanism,
+		    PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len);
+		if (PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len > sha_digest_len)
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+	}
+
+	if (ret != CRYPTO_SUCCESS) {
+		bzero(ctx->cc_provider_private, sizeof (sha2_hmac_ctx_t));
+		kmem_free(ctx->cc_provider_private, sizeof (sha2_hmac_ctx_t));
+		ctx->cc_provider_private = NULL;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha2_mac_update(crypto_ctx_t *ctx, crypto_data_t *data,
+    crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/*
+	 * Do a SHA2 update of the inner context using the specified
+	 * data.
+	 */
+	switch (data->cd_format) {
+	case CRYPTO_DATA_RAW:
+		SHA2Update(&PROV_SHA2_HMAC_CTX(ctx)->hc_icontext,
+		    (uint8_t *)data->cd_raw.iov_base + data->cd_offset,
+		    data->cd_length);
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_update_uio(
+		    &PROV_SHA2_HMAC_CTX(ctx)->hc_icontext, data);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_update_mblk(
+		    &PROV_SHA2_HMAC_CTX(ctx)->hc_icontext, data);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha2_mac_final(crypto_ctx_t *ctx, crypto_data_t *mac, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[SHA512_DIGEST_LENGTH];
+	uint32_t digest_len, sha_digest_len;
+
+	ASSERT(ctx->cc_provider_private != NULL);
+
+	/* Set the digest lengths to values approriate to the mechanism */
+	switch (PROV_SHA2_HMAC_CTX(ctx)->hc_mech_type) {
+	case SHA256_HMAC_MECH_INFO_TYPE:
+		sha_digest_len = digest_len = SHA256_DIGEST_LENGTH;
+		break;
+	case SHA384_HMAC_MECH_INFO_TYPE:
+	case SHA512_HMAC_MECH_INFO_TYPE:
+		sha_digest_len = digest_len = SHA512_DIGEST_LENGTH;
+		break;
+	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = SHA256_DIGEST_LENGTH;
+		digest_len = PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len;
+		break;
+	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
+	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = SHA512_DIGEST_LENGTH;
+		digest_len = PROV_SHA2_HMAC_CTX(ctx)->hc_digest_len;
+		break;
+	}
+
+	/*
+	 * We need to just return the length needed to store the output.
+	 * We should not destroy the context for the following cases.
+	 */
+	if ((mac->cd_length == 0) || (mac->cd_length < digest_len)) {
+		mac->cd_length = digest_len;
+		return (CRYPTO_BUFFER_TOO_SMALL);
+	}
+
+	/*
+	 * Do a SHA2 final on the inner context.
+	 */
+	SHA2Final(digest, &PROV_SHA2_HMAC_CTX(ctx)->hc_icontext);
+
+	/*
+	 * Do a SHA2 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	SHA2Update(&PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, digest,
+	    sha_digest_len);
+
+	/*
+	 * Do a SHA2 final on the outer context, storing the computing
+	 * digest in the users buffer.
+	 */
+	switch (mac->cd_format) {
+	case CRYPTO_DATA_RAW:
+		if (digest_len != sha_digest_len) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA2Final(digest,
+			    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext);
+			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, digest_len);
+		} else {
+			SHA2Final((unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset,
+			    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext);
+		}
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_final_uio(
+		    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_final_mblk(
+		    &PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS)
+		mac->cd_length = digest_len;
+	else
+		mac->cd_length = 0;
+
+	bzero(&PROV_SHA2_HMAC_CTX(ctx)->hc_ocontext, sizeof (sha2_hmac_ctx_t));
+	kmem_free(ctx->cc_provider_private, sizeof (sha2_hmac_ctx_t));
+	ctx->cc_provider_private = NULL;
+
+	return (ret);
+}
+
+#define	SHA2_MAC_UPDATE(data, ctx, ret) {				\
+	switch (data->cd_format) {					\
+	case CRYPTO_DATA_RAW:						\
+		SHA2Update(&(ctx).hc_icontext,				\
+		    (uint8_t *)data->cd_raw.iov_base +			\
+		    data->cd_offset, data->cd_length);			\
+		break;							\
+	case CRYPTO_DATA_UIO:						\
+		ret = sha2_digest_update_uio(&(ctx).hc_icontext, data);	\
+		break;							\
+	case CRYPTO_DATA_MBLK:						\
+		ret = sha2_digest_update_mblk(&(ctx).hc_icontext,	\
+		    data);						\
+		break;							\
+	default:							\
+		ret = CRYPTO_ARGUMENTS_BAD;				\
+	}								\
+}
+
+/* ARGSUSED */
+static int
+sha2_mac_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
+    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[SHA512_DIGEST_LENGTH];
+	sha2_hmac_ctx_t sha2_hmac_ctx;
+	uint32_t sha_digest_len, digest_len, sha_hmac_block_size;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	/*
+	 * Set the digest length and block size to values approriate to the
+	 * mechanism
+	 */
+	switch (mechanism->cm_type) {
+	case SHA256_HMAC_MECH_INFO_TYPE:
+	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = digest_len = SHA256_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
+		break;
+	case SHA384_HMAC_MECH_INFO_TYPE:
+	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
+	case SHA512_HMAC_MECH_INFO_TYPE:
+	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = digest_len = SHA512_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
+		break;
+	default:
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, &sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
+	} else {
+		sha2_hmac_ctx.hc_mech_type = mechanism->cm_type;
+		/* no context template, initialize context */
+		if (keylen_in_bytes > sha_hmac_block_size) {
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
+			    &sha2_hmac_ctx.hc_icontext,
+			    key->ck_data, keylen_in_bytes, digest);
+			sha2_mac_init_ctx(&sha2_hmac_ctx, digest,
+			    sha_digest_len);
+		} else {
+			sha2_mac_init_ctx(&sha2_hmac_ctx, key->ck_data,
+			    keylen_in_bytes);
+		}
+	}
+
+	/* get the mechanism parameters, if applicable */
+	if ((mechanism->cm_type % 3) == 2) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t)) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+		PROV_SHA2_GET_DIGEST_LEN(mechanism, digest_len);
+		if (digest_len > sha_digest_len) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+	}
+
+	/* do a SHA2 update of the inner context using the specified data */
+	SHA2_MAC_UPDATE(data, sha2_hmac_ctx, ret);
+	if (ret != CRYPTO_SUCCESS)
+		/* the update failed, free context and bail */
+		goto bail;
+
+	/*
+	 * Do a SHA2 final on the inner context.
+	 */
+	SHA2Final(digest, &sha2_hmac_ctx.hc_icontext);
+
+	/*
+	 * Do an SHA2 update on the outer context, feeding the inner
+	 * digest as data.
+	 *
+	 * Make sure that SHA384 is handled special because
+	 * it cannot feed a 60-byte inner hash to the outer
+	 */
+	if (mechanism->cm_type == SHA384_HMAC_MECH_INFO_TYPE ||
+	    mechanism->cm_type == SHA384_HMAC_GEN_MECH_INFO_TYPE)
+		SHA2Update(&sha2_hmac_ctx.hc_ocontext, digest,
+		    SHA384_DIGEST_LENGTH);
+	else
+		SHA2Update(&sha2_hmac_ctx.hc_ocontext, digest, sha_digest_len);
+
+	/*
+	 * Do a SHA2 final on the outer context, storing the computed
+	 * digest in the users buffer.
+	 */
+	switch (mac->cd_format) {
+	case CRYPTO_DATA_RAW:
+		if (digest_len != sha_digest_len) {
+			/*
+			 * The caller requested a short digest. Digest
+			 * into a scratch buffer and return to
+			 * the user only what was requested.
+			 */
+			SHA2Final(digest, &sha2_hmac_ctx.hc_ocontext);
+			bcopy(digest, (unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, digest_len);
+		} else {
+			SHA2Final((unsigned char *)mac->cd_raw.iov_base +
+			    mac->cd_offset, &sha2_hmac_ctx.hc_ocontext);
+		}
+		break;
+	case CRYPTO_DATA_UIO:
+		ret = sha2_digest_final_uio(&sha2_hmac_ctx.hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	case CRYPTO_DATA_MBLK:
+		ret = sha2_digest_final_mblk(&sha2_hmac_ctx.hc_ocontext, mac,
+		    digest_len, digest);
+		break;
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	if (ret == CRYPTO_SUCCESS) {
+		mac->cd_length = digest_len;
+		return (CRYPTO_SUCCESS);
+	}
+bail:
+	bzero(&sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
+	mac->cd_length = 0;
+	return (ret);
+}
+
+/* ARGSUSED */
+static int
+sha2_mac_verify_atomic(crypto_provider_handle_t provider,
+    crypto_session_id_t session_id, crypto_mechanism_t *mechanism,
+    crypto_key_t *key, crypto_data_t *data, crypto_data_t *mac,
+    crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
+{
+	int ret = CRYPTO_SUCCESS;
+	uchar_t digest[SHA512_DIGEST_LENGTH];
+	sha2_hmac_ctx_t sha2_hmac_ctx;
+	uint32_t sha_digest_len, digest_len, sha_hmac_block_size;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+
+	/*
+	 * Set the digest length and block size to values approriate to the
+	 * mechanism
+	 */
+	switch (mechanism->cm_type) {
+	case SHA256_HMAC_MECH_INFO_TYPE:
+	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = digest_len = SHA256_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
+		break;
+	case SHA384_HMAC_MECH_INFO_TYPE:
+	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
+	case SHA512_HMAC_MECH_INFO_TYPE:
+	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = digest_len = SHA512_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
+		break;
+	default:
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	if (ctx_template != NULL) {
+		/* reuse context template */
+		bcopy(ctx_template, &sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
+	} else {
+		/* no context template, initialize context */
+		if (keylen_in_bytes > sha_hmac_block_size) {
+			/*
+			 * Hash the passed-in key to get a smaller key.
+			 * The inner context is used since it hasn't been
+			 * initialized yet.
+			 */
+			PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
+			    &sha2_hmac_ctx.hc_icontext,
+			    key->ck_data, keylen_in_bytes, digest);
+			sha2_mac_init_ctx(&sha2_hmac_ctx, digest,
+			    sha_digest_len);
+		} else {
+			sha2_mac_init_ctx(&sha2_hmac_ctx, key->ck_data,
+			    keylen_in_bytes);
+		}
+	}
+
+	/* get the mechanism parameters, if applicable */
+	if (mechanism->cm_type % 3 == 2) {
+		if (mechanism->cm_param == NULL ||
+		    mechanism->cm_param_len != sizeof (ulong_t)) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+		PROV_SHA2_GET_DIGEST_LEN(mechanism, digest_len);
+		if (digest_len > sha_digest_len) {
+			ret = CRYPTO_MECHANISM_PARAM_INVALID;
+			goto bail;
+		}
+	}
+
+	if (mac->cd_length != digest_len) {
+		ret = CRYPTO_INVALID_MAC;
+		goto bail;
+	}
+
+	/* do a SHA2 update of the inner context using the specified data */
+	SHA2_MAC_UPDATE(data, sha2_hmac_ctx, ret);
+	if (ret != CRYPTO_SUCCESS)
+		/* the update failed, free context and bail */
+		goto bail;
+
+	/* do a SHA2 final on the inner context */
+	SHA2Final(digest, &sha2_hmac_ctx.hc_icontext);
+
+	/*
+	 * Do an SHA2 update on the outer context, feeding the inner
+	 * digest as data.
+	 */
+	SHA2Update(&sha2_hmac_ctx.hc_ocontext, digest, sha_digest_len);
+
+	/*
+	 * Do a SHA2 final on the outer context, storing the computed
+	 * digest in the users buffer.
+	 */
+	SHA2Final(digest, &sha2_hmac_ctx.hc_ocontext);
+
+	/*
+	 * Compare the computed digest against the expected digest passed
+	 * as argument.
+	 */
+
+	switch (mac->cd_format) {
+
+	case CRYPTO_DATA_RAW:
+		if (bcmp(digest, (unsigned char *)mac->cd_raw.iov_base +
+		    mac->cd_offset, digest_len) != 0)
+			ret = CRYPTO_INVALID_MAC;
+		break;
+
+	case CRYPTO_DATA_UIO: {
+		off_t offset = mac->cd_offset;
+		uint_t vec_idx;
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		/* we support only kernel buffer */
+		if (mac->cd_uio->uio_segflg != UIO_SYSSPACE)
+			return (CRYPTO_ARGUMENTS_BAD);
+
+		/* jump to the first iovec containing the expected digest */
+		for (vec_idx = 0;
+		    offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
+		    vec_idx < mac->cd_uio->uio_iovcnt;
+		    offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len);
+		if (vec_idx == mac->cd_uio->uio_iovcnt) {
+			/*
+			 * The caller specified an offset that is
+			 * larger than the total size of the buffers
+			 * it provided.
+			 */
+			ret = CRYPTO_DATA_LEN_RANGE;
+			break;
+		}
+
+		/* do the comparison of computed digest vs specified one */
+		while (vec_idx < mac->cd_uio->uio_iovcnt && length > 0) {
+			cur_len = MIN(mac->cd_uio->uio_iov[vec_idx].iov_len -
+			    offset, length);
+
+			if (bcmp(digest + scratch_offset,
+			    mac->cd_uio->uio_iov[vec_idx].iov_base + offset,
+			    cur_len) != 0) {
+				ret = CRYPTO_INVALID_MAC;
+				break;
+			}
+
+			length -= cur_len;
+			vec_idx++;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+		break;
+	}
+
+	case CRYPTO_DATA_MBLK: {
+		off_t offset = mac->cd_offset;
+		mblk_t *mp;
+		off_t scratch_offset = 0;
+		size_t length = digest_len;
+		size_t cur_len;
+
+		/* jump to the first mblk_t containing the expected digest */
+		for (mp = mac->cd_mp; mp != NULL && offset >= MBLKL(mp);
+		    offset -= MBLKL(mp), mp = mp->b_cont);
+		if (mp == NULL) {
+			/*
+			 * The caller specified an offset that is larger than
+			 * the total size of the buffers it provided.
+			 */
+			ret = CRYPTO_DATA_LEN_RANGE;
+			break;
+		}
+
+		while (mp != NULL && length > 0) {
+			cur_len = MIN(MBLKL(mp) - offset, length);
+			if (bcmp(digest + scratch_offset,
+			    mp->b_rptr + offset, cur_len) != 0) {
+				ret = CRYPTO_INVALID_MAC;
+				break;
+			}
+
+			length -= cur_len;
+			mp = mp->b_cont;
+			scratch_offset += cur_len;
+			offset = 0;
+		}
+		break;
+	}
+
+	default:
+		ret = CRYPTO_ARGUMENTS_BAD;
+	}
+
+	return (ret);
+bail:
+	bzero(&sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
+	mac->cd_length = 0;
+	return (ret);
+}
+
+/*
+ * KCF software provider context management entry points.
+ */
+
+/* ARGSUSED */
+static int
+sha2_create_ctx_template(crypto_provider_handle_t provider,
+    crypto_mechanism_t *mechanism, crypto_key_t *key,
+    crypto_spi_ctx_template_t *ctx_template, size_t *ctx_template_size,
+    crypto_req_handle_t req)
+{
+	sha2_hmac_ctx_t *sha2_hmac_ctx_tmpl;
+	uint_t keylen_in_bytes = CRYPTO_BITS2BYTES(key->ck_length);
+	uint32_t sha_digest_len, sha_hmac_block_size;
+
+	/*
+	 * Set the digest length and block size to values approriate to the
+	 * mechanism
+	 */
+	switch (mechanism->cm_type) {
+	case SHA256_HMAC_MECH_INFO_TYPE:
+	case SHA256_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = SHA256_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA256_HMAC_BLOCK_SIZE;
+		break;
+	case SHA384_HMAC_MECH_INFO_TYPE:
+	case SHA384_HMAC_GEN_MECH_INFO_TYPE:
+	case SHA512_HMAC_MECH_INFO_TYPE:
+	case SHA512_HMAC_GEN_MECH_INFO_TYPE:
+		sha_digest_len = SHA512_DIGEST_LENGTH;
+		sha_hmac_block_size = SHA512_HMAC_BLOCK_SIZE;
+		break;
+	default:
+		return (CRYPTO_MECHANISM_INVALID);
+	}
+
+	/* Add support for key by attributes (RFE 4706552) */
+	if (key->ck_format != CRYPTO_KEY_RAW)
+		return (CRYPTO_ARGUMENTS_BAD);
+
+	/*
+	 * Allocate and initialize SHA2 context.
+	 */
+	sha2_hmac_ctx_tmpl = kmem_alloc(sizeof (sha2_hmac_ctx_t),
+	    crypto_kmflag(req));
+	if (sha2_hmac_ctx_tmpl == NULL)
+		return (CRYPTO_HOST_MEMORY);
+
+	sha2_hmac_ctx_tmpl->hc_mech_type = mechanism->cm_type;
+
+	if (keylen_in_bytes > sha_hmac_block_size) {
+		uchar_t digested_key[SHA512_DIGEST_LENGTH];
+
+		/*
+		 * Hash the passed-in key to get a smaller key.
+		 * The inner context is used since it hasn't been
+		 * initialized yet.
+		 */
+		PROV_SHA2_DIGEST_KEY(mechanism->cm_type / 3,
+		    &sha2_hmac_ctx_tmpl->hc_icontext,
+		    key->ck_data, keylen_in_bytes, digested_key);
+		sha2_mac_init_ctx(sha2_hmac_ctx_tmpl, digested_key,
+		    sha_digest_len);
+	} else {
+		sha2_mac_init_ctx(sha2_hmac_ctx_tmpl, key->ck_data,
+		    keylen_in_bytes);
+	}
+
+	*ctx_template = (crypto_spi_ctx_template_t)sha2_hmac_ctx_tmpl;
+	*ctx_template_size = sizeof (sha2_hmac_ctx_t);
+
+	return (CRYPTO_SUCCESS);
+}
+
+static int
+sha2_free_context(crypto_ctx_t *ctx)
+{
+	uint_t ctx_len;
+
+	if (ctx->cc_provider_private == NULL)
+		return (CRYPTO_SUCCESS);
+
+	/*
+	 * We have to free either SHA2 or SHA2-HMAC contexts, which
+	 * have different lengths.
+	 *
+	 * Note: Below is dependent on the mechanism ordering.
+	 */
+
+	if (PROV_SHA2_CTX(ctx)->sc_mech_type % 3 == 0)
+		ctx_len = sizeof (sha2_ctx_t);
+	else
+		ctx_len = sizeof (sha2_hmac_ctx_t);
+
+	bzero(ctx->cc_provider_private, ctx_len);
+	kmem_free(ctx->cc_provider_private, ctx_len);
+	ctx->cc_provider_private = NULL;
+
+	return (CRYPTO_SUCCESS);
+}
--- a/usr/src/uts/common/sys/sha1.h	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/uts/common/sys/sha1.h	Tue Mar 28 08:45:30 2006 -0800
@@ -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 1998-2003 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -46,8 +45,8 @@
 } SHA1_CTX;
 
 void SHA1Init(SHA1_CTX *);
-void SHA1Update(SHA1_CTX *, const uint8_t *, uint32_t);
-void SHA1Final(uint8_t *, SHA1_CTX *);
+void SHA1Update(SHA1_CTX *, const void *, size_t);
+void SHA1Final(void *, SHA1_CTX *);
 
 #ifdef	__cplusplus
 }
--- a/usr/src/uts/common/sys/sha2.h	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/uts/common/sys/sha2.h	Tue Mar 28 08:45:30 2006 -0800
@@ -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 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -35,6 +34,16 @@
 extern "C" {
 #endif
 
+#define	SHA2_HMAC_MIN_KEY_LEN	8	/* SHA2-HMAC min key length in bits */
+#define	SHA2_HMAC_MAX_KEY_LEN	INT_MAX /* SHA2-HMAC max key length in bits */
+
+#define	SHA256_DIGEST_LENGTH	32	/* SHA256 digest length in bytes */
+#define	SHA384_DIGEST_LENGTH	48	/* SHA384 digest length in bytes */
+#define	SHA512_DIGEST_LENGTH	64	/* SHA512 digest length in bytes */
+
+#define	SHA256_HMAC_BLOCK_SIZE	64	/* SHA256-HMAC block size */
+#define	SHA512_HMAC_BLOCK_SIZE	128	/* SHA512-HMAC block size */
+
 #define	SHA256			0
 #define	SHA256_HMAC		1
 #define	SHA256_HMAC_GEN		2
@@ -45,18 +54,13 @@
 #define	SHA512_HMAC		7
 #define	SHA512_HMAC_GEN		8
 
-#define	SHA2_HMAC_MIN_KEY_LEN	8	/* SHA2-HMAC min key length in bits */
-#define	SHA2_HMAC_MAX_KEY_LEN	INT_MAX /* SHA2-HMAC max key length in bits */
-
-#define	SHA256_DIGEST_LENGTH	32	/* SHA256 digest length in bytes */
-#define	SHA384_DIGEST_LENGTH	48	/* SHA384 digest length in bytes */
-#define	SHA512_DIGEST_LENGTH	64	/* SHA512 digest length in bytes */
-
-#define	SHA256_HMAC_BLOCK_SIZE	64	/* SHA256-HMAC block size */
-#define	SHA512_HMAC_BLOCK_SIZE	128	/* SHA512-HMAC block size */
-
-
-/* SHA2 context. */
+/*
+ * SHA2 context.
+ * The contents of this structure are a private interface between the
+ * Init/Update/Final calls of the functions defined below.
+ * Callers must never attempt to read or write any of the fields
+ * in this strucutre directly.
+ */
 typedef struct 	{
 	uint32_t algotype;		/* Algorithm Type */
 
@@ -77,11 +81,61 @@
 	} buf_un;
 } SHA2_CTX;
 
+typedef SHA2_CTX SHA256_CTX;
+typedef SHA2_CTX SHA384_CTX;
+typedef SHA2_CTX SHA512_CTX;
+
 extern void SHA2Init(uint64_t mech, SHA2_CTX *);
 
-extern void SHA2Update(SHA2_CTX *, const uint8_t *, uint32_t);
+extern void SHA2Update(SHA2_CTX *, const void *, size_t);
+
+extern void SHA2Final(void *, SHA2_CTX *);
+
+extern void SHA256Init(SHA256_CTX *);
+
+extern void SHA256Update(SHA256_CTX *, const void *, size_t);
+
+extern void SHA256Final(void *, SHA256_CTX *);
+
+extern void SHA384Init(SHA384_CTX *);
+
+extern void SHA384Update(SHA384_CTX *, const void *, size_t);
+
+extern void SHA384Final(void *, SHA384_CTX *);
+
+extern void SHA512Init(SHA512_CTX *);
+
+extern void SHA512Update(SHA512_CTX *, const void *, size_t);
+
+extern void SHA512Final(void *, SHA512_CTX *);
 
-extern void SHA2Final(uint8_t *, SHA2_CTX *);
+#ifdef _SHA2_IMPL
+/*
+ * The following types/functions are all private to the implementation
+ * of the SHA2 functions and must not be used by consumers of the interface
+ */
+
+/*
+ * List of support mechanisms in this module.
+ *
+ * It is important to note that in the module, division or modulus calculations
+ * are used on the enumerated type to determine which mechanism is being used;
+ * therefore, changing the order or additional mechanisms should be done
+ * carefully
+ */
+typedef enum sha2_mech_type {
+	SHA256_MECH_INFO_TYPE,		/* SUN_CKM_SHA256 */
+	SHA256_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA256_HMAC */
+	SHA256_HMAC_GEN_MECH_INFO_TYPE,	/* SUN_CKM_SHA256_HMAC_GENERAL */
+	SHA384_MECH_INFO_TYPE,		/* SUN_CKM_SHA384 */
+	SHA384_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA384_HMAC */
+	SHA384_HMAC_GEN_MECH_INFO_TYPE,	/* SUN_CKM_SHA384_HMAC_GENERAL */
+	SHA512_MECH_INFO_TYPE,		/* SUN_CKM_SHA512 */
+	SHA512_HMAC_MECH_INFO_TYPE,	/* SUN_CKM_SHA512_HMAC */
+	SHA512_HMAC_GEN_MECH_INFO_TYPE	/* SUN_CKM_SHA512_HMAC_GENERAL */
+} sha2_mech_type_t;
+
+#endif /* _SHA2_IMPL */
 
 #ifdef	__cplusplus
 }
--- a/usr/src/uts/sun4v/md5/Makefile	Mon Mar 27 18:01:01 2006 -0800
+++ b/usr/src/uts/sun4v/md5/Makefile	Tue Mar 28 08:45:30 2006 -0800
@@ -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.
@@ -22,7 +21,7 @@
 #
 # uts/sun4v/md5/Makefile
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
@@ -64,11 +63,6 @@
 CFLAGS += $(CCVERBOSE)
 
 #
-# watch for ugly -Dsun4u
-#
-CPPFLAGS	+= -Dsun4u
-
-#
 # Override the default -xspace setting
 #
 sparc_SPACEFLAG	= -W0,-Lt -W2,-Rcond_elim