Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/libbb/sha1.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 16  Line 16 
16   *  stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor   *  stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor
17   */   */
18    
 #include <fcntl.h>  
 #include <limits.h>  
 #include <stdio.h>  
 #include <stdint.h>  
 #include <stdlib.h>  
 #include <string.h>  
 #include <unistd.h>  
   
19  #include "libbb.h"  #include "libbb.h"
20    
21  #define SHA1_BLOCK_SIZE  64  #define SHA1_BLOCK_SIZE  64
# Line 91  static void sha1_compile(sha1_ctx_t *ctx Line 83  static void sha1_compile(sha1_ctx_t *ctx
83   ctx->hash[4] += e;   ctx->hash[4] += e;
84  }  }
85    
86  void sha1_begin(sha1_ctx_t *ctx)  void FAST_FUNC sha1_begin(sha1_ctx_t *ctx)
87  {  {
88   ctx->count[0] = ctx->count[1] = 0;   ctx->count[0] = ctx->count[1] = 0;
89   ctx->hash[0] = 0x67452301;   ctx->hash[0] = 0x67452301;
# Line 103  void sha1_begin(sha1_ctx_t *ctx) Line 95  void sha1_begin(sha1_ctx_t *ctx)
95    
96  /* SHA1 hash data in an array of bytes into hash buffer and call the        */  /* SHA1 hash data in an array of bytes into hash buffer and call the        */
97  /* hash_compile function as required.                                       */  /* hash_compile function as required.                                       */
98  void sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx)  void FAST_FUNC sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx)
99  {  {
100   uint32_t pos = (uint32_t) (ctx->count[0] & SHA1_MASK);   uint32_t pos = (uint32_t) (ctx->count[0] & SHA1_MASK);
101   uint32_t freeb = SHA1_BLOCK_SIZE - pos;   uint32_t freeb = SHA1_BLOCK_SIZE - pos;
# Line 124  void sha1_hash(const void *data, size_t Line 116  void sha1_hash(const void *data, size_t
116   memcpy(((unsigned char *) ctx->wbuf) + pos, sp, length);   memcpy(((unsigned char *) ctx->wbuf) + pos, sp, length);
117  }  }
118    
119  void *sha1_end(void *resbuf, sha1_ctx_t *ctx)  void* FAST_FUNC sha1_end(void *resbuf, sha1_ctx_t *ctx)
120  {  {
121   /* SHA1 Final padding and digest calculation  */   /* SHA1 Final padding and digest calculation  */
122  #if BB_BIG_ENDIAN  #if BB_BIG_ENDIAN

Legend:
Removed from v.532  
changed lines
  Added in v.816