File: sha256.h

package info (click to toggle)
guymager 0.6.7-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,500 kB
  • sloc: cpp: 13,963; makefile: 50; sh: 17
file content (40 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This file has been copied 1:1 from www.spale.com/download/scrypt/scrypt1.0/sha256.c
// Besides these 2 comment lines and the correction of uint32 (see below) nothing has been changed.

#ifndef __SHA256_H__
#define __SHA256_H__

typedef unsigned int  uint32;
typedef unsigned char uint8;

#define SHA256_DIGEST_SIZE 32

#ifdef SHA256_OLD
   typedef struct
   {
      uint32 total[2];
      uint32 state[8];
      uint8 buffer[64];
   } t_SHA256Context, *t_pSHA256Context;

   void SHA256Init   (t_pSHA256Context pContext);
   void SHA256Append (t_pSHA256Context pContext, uint8 *input, uint32 length );
   void SHA256Finish (t_pSHA256Context pContext, uint8 digest[32] );
#else
   typedef struct
   {
      uint32 state[8];
      uint32 total[2];
      size_t buflen;
      uint32 buffer[32];
   } t_SHA256Context, *t_pSHA256Context;

   // Always make sure that these functions are compiled with O3 optimisation or
   // else, performance is about 5 times worse! See also SHA256ProcessBlock in sha256.cpp.
   void SHA256Init   (t_pSHA256Context pContext)                                 __attribute__((optimize("-O3")));
   void SHA256Append (t_pSHA256Context pContext, const void *buffer, size_t len) __attribute__((optimize("-O3")));
   void SHA256Finish (t_pSHA256Context pContext, void *pDigest)                  __attribute__((optimize("-O3")));
#endif

#endif