Print this page
3364 dboot should check boot archive integrity
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Garrett D'Amore <garrett@damore.org>


  15  *
  16  * License is also granted to make and use derivative works provided
  17  * that such works are identified as "derived from the RSA Data
  18  * Security, Inc. MD5 Message-Digest Algorithm" in all material
  19  * mentioning or referencing the derived work.
  20  *
  21  * RSA Data Security, Inc. makes no representations concerning either
  22  * the merchantability of this software or the suitability of this
  23  * software for any particular purpose. It is provided "as is"
  24  * without express or implied warranty of any kind.
  25  *
  26  * These notices must be retained in any copies of any part of this
  27  * documentation and/or software.
  28  *
  29  * NOTE: Cleaned-up and optimized, version of SHA1, based on the FIPS 180-1
  30  * standard, available at http://www.itl.nist.gov/fipspubs/fip180-1.htm
  31  * Not as fast as one would like -- further optimizations are encouraged
  32  * and appreciated.
  33  */
  34 
  35 #ifndef _KERNEL
  36 #include <stdint.h>
  37 #include <strings.h>
  38 #include <stdlib.h>
  39 #include <errno.h>
  40 #include <sys/systeminfo.h>
  41 #endif  /* !_KERNEL */
  42 
  43 #include <sys/types.h>
  44 #include <sys/param.h>
  45 #include <sys/systm.h>
  46 #include <sys/sysmacros.h>
  47 #include <sys/sha1.h>
  48 #include <sys/sha1_consts.h>
  49 
  50 #ifdef _LITTLE_ENDIAN
  51 #include <sys/byteorder.h>
  52 #define HAVE_HTONL
  53 #endif
  54 





  55 static void Encode(uint8_t *, const uint32_t *, size_t);
  56 
  57 #if     defined(__sparc)
  58 
  59 #define SHA1_TRANSFORM(ctx, in) \
  60         SHA1Transform((ctx)->state[0], (ctx)->state[1], (ctx)->state[2], \
  61                 (ctx)->state[3], (ctx)->state[4], (ctx), (in))
  62 
  63 static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
  64     SHA1_CTX *, const uint8_t *);
  65 
  66 #elif   defined(__amd64)
  67 
  68 #define SHA1_TRANSFORM(ctx, in) sha1_block_data_order((ctx), (in), 1)
  69 #define SHA1_TRANSFORM_BLOCKS(ctx, in, num) sha1_block_data_order((ctx), \
  70                 (in), (num))
  71 
  72 void sha1_block_data_order(SHA1_CTX *ctx, const void *inpp, size_t num_blocks);
  73 
  74 #else




  15  *
  16  * License is also granted to make and use derivative works provided
  17  * that such works are identified as "derived from the RSA Data
  18  * Security, Inc. MD5 Message-Digest Algorithm" in all material
  19  * mentioning or referencing the derived work.
  20  *
  21  * RSA Data Security, Inc. makes no representations concerning either
  22  * the merchantability of this software or the suitability of this
  23  * software for any particular purpose. It is provided "as is"
  24  * without express or implied warranty of any kind.
  25  *
  26  * These notices must be retained in any copies of any part of this
  27  * documentation and/or software.
  28  *
  29  * NOTE: Cleaned-up and optimized, version of SHA1, based on the FIPS 180-1
  30  * standard, available at http://www.itl.nist.gov/fipspubs/fip180-1.htm
  31  * Not as fast as one would like -- further optimizations are encouraged
  32  * and appreciated.
  33  */
  34 
  35 #if !defined(_KERNEL) && !defined(_BOOT)
  36 #include <stdint.h>
  37 #include <strings.h>
  38 #include <stdlib.h>
  39 #include <errno.h>
  40 #include <sys/systeminfo.h>
  41 #endif  /* !_KERNEL && !_BOOT */
  42 
  43 #include <sys/types.h>
  44 #include <sys/param.h>
  45 #include <sys/systm.h>
  46 #include <sys/sysmacros.h>
  47 #include <sys/sha1.h>
  48 #include <sys/sha1_consts.h>
  49 
  50 #ifdef _LITTLE_ENDIAN
  51 #include <sys/byteorder.h>
  52 #define HAVE_HTONL
  53 #endif
  54 
  55 #ifdef  _BOOT
  56 #define bcopy(_s, _d, _l)       ((void) memcpy((_d), (_s), (_l)))
  57 #define bzero(_m, _l)           ((void) memset((_m), 0, (_l)))
  58 #endif
  59 
  60 static void Encode(uint8_t *, const uint32_t *, size_t);
  61 
  62 #if     defined(__sparc)
  63 
  64 #define SHA1_TRANSFORM(ctx, in) \
  65         SHA1Transform((ctx)->state[0], (ctx)->state[1], (ctx)->state[2], \
  66                 (ctx)->state[3], (ctx)->state[4], (ctx), (in))
  67 
  68 static void SHA1Transform(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
  69     SHA1_CTX *, const uint8_t *);
  70 
  71 #elif   defined(__amd64)
  72 
  73 #define SHA1_TRANSFORM(ctx, in) sha1_block_data_order((ctx), (in), 1)
  74 #define SHA1_TRANSFORM_BLOCKS(ctx, in, num) sha1_block_data_order((ctx), \
  75                 (in), (num))
  76 
  77 void sha1_block_data_order(SHA1_CTX *ctx, const void *inpp, size_t num_blocks);
  78 
  79 #else