Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
sha1.c File Reference
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/bitops.h>
#include <linux/cryptohash.h>
#include <asm/unaligned.h>

Go to the source code of this file.

Macros

#define setW(x, val)   (W(x) = (val))
 
#define W(x)   (array[(x)&15])
 
#define SHA_SRC(t)   get_unaligned_be32((__u32 *)data + t)
 
#define SHA_MIX(t)   rol32(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1)
 
#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E)
 
#define T_0_15(t, A, B, C, D, E)   SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
 
#define T_16_19(t, A, B, C, D, E)   SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
 
#define T_20_39(t, A, B, C, D, E)   SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E )
 
#define T_40_59(t, A, B, C, D, E)   SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )
 
#define T_60_79(t, A, B, C, D, E)   SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )
 

Functions

void sha_transform (__u32 *digest, const char *data, __u32 *array)
 
 EXPORT_SYMBOL (sha_transform)
 
void sha_init (__u32 *buf)
 

Macro Definition Documentation

#define setW (   x,
  val 
)    (W(x) = (val))

Definition at line 41 of file sha1.c.

#define SHA_MIX (   t)    rol32(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1)

Definition at line 52 of file sha1.c.

#define SHA_ROUND (   t,
  input,
  fn,
  constant,
  A,
  B,
  C,
  D,
  E 
)
Value:
do { \
__u32 TEMP = input(t); setW(t, TEMP); \
E += TEMP + rol32(A,5) + (fn) + (constant); \
B = ror32(B, 2); } while (0)

Definition at line 54 of file sha1.c.

#define SHA_SRC (   t)    get_unaligned_be32((__u32 *)data + t)

Definition at line 51 of file sha1.c.

#define T_0_15 (   t,
  A,
  B,
  C,
  D,
  E 
)    SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )

Definition at line 59 of file sha1.c.

#define T_16_19 (   t,
  A,
  B,
  C,
  D,
  E 
)    SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )

Definition at line 60 of file sha1.c.

#define T_20_39 (   t,
  A,
  B,
  C,
  D,
  E 
)    SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E )

Definition at line 61 of file sha1.c.

#define T_40_59 (   t,
  A,
  B,
  C,
  D,
  E 
)    SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )

Definition at line 62 of file sha1.c.

#define T_60_79 (   t,
  A,
  B,
  C,
  D,
  E 
)    SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )

Definition at line 63 of file sha1.c.

#define W (   x)    (array[(x)&15])

Definition at line 45 of file sha1.c.

Function Documentation

EXPORT_SYMBOL ( sha_transform  )
void sha_init ( __u32 buf)

sha_init - initialize the vectors for a SHA1 digest : vector to initialize

Definition at line 193 of file sha1.c.

void sha_transform ( __u32 digest,
const char data,
__u32 array 
)

sha_transform - single block SHA1 transform

: 160 bit digest to update : 512 bits of data to hash : 16 words of workspace (see note)

This function generates a SHA1 digest for a single 512-bit block. Be warned, it does not handle padding and message digest, do not confuse it with the full FIPS 180-1 digest algorithm for variable length messages.

Note: If the hash is security sensitive, the caller should be sure to clear the workspace. This is left to the caller to avoid unnecessary clears between chained hashing operations.

Definition at line 81 of file sha1.c.