/[winpt]/trunk/Gnupg/md.h
ViewVC logotype

Diff of /trunk/Gnupg/md.h

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

revision 45 by twoaday, Mon Jan 31 11:02:21 2005 UTC revision 46 by werner, Fri Oct 28 12:57:05 2005 UTC
# Line 1  Line 1 
 /*  SHA256, SHA384, SHA512 Copyright 2001 by Jari Ruusu.  
  *  Redistribution of this file is permitted under the GNU Public License.  
  */  
 #ifndef GPGLIB_MD_H  
 #define GPGLIB_MD_H  
   
 /****************  
  * Rotate a 32 bit integer by n bytes  
  */  
 #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )  
   
 #include <sys/types.h>  
   
 typedef unsigned __int64 u_int64_t;  
 typedef unsigned __int32 u_int32_t;  
   
 typedef struct {  
     unsigned char   sha_out[64];    /* results are here, bytes 0...31 */  
     u_int32_t       sha_H[8];  
     u_int64_t       sha_blocks;  
     int             sha_bufCnt;  
 } sha256_context;  
   
 typedef struct {  
     unsigned char   sha_out[128];   /* results are here, bytes 0...63 */  
     u_int64_t       sha_H[8];  
     u_int64_t       sha_blocks;  
     u_int64_t       sha_blocksMSB;  
     int             sha_bufCnt;  
 } sha512_context;  
   
 typedef struct {  
     unsigned long  h0,h1,h2,h3,h4;  
     unsigned long  nblocks;  
     unsigned char buf[64];  
     int  count;  
 } RMD160_CONTEXT;  
   
 typedef struct {  
     unsigned long  h0,h1,h2,h3,h4;  
     unsigned long  nblocks;  
     unsigned char buf[64];  
     int  count;  
 } SHA1_CONTEXT;  
   
 typedef struct {  
     unsigned long A,B,C,D;        /* chaining variables */  
     unsigned long  nblocks;  
     unsigned char buf[64];  
     int  count;  
 } MD5_CONTEXT;  
   
   
 unsigned char * sha1_read( SHA1_CONTEXT *hd );  
 void sha1_final( SHA1_CONTEXT *hd );  
 void sha1_write( SHA1_CONTEXT *hd, unsigned char *inbuf, size_t inlen );  
 void sha1_init( SHA1_CONTEXT *hd );  
   
 unsigned char * md5_read( MD5_CONTEXT * hd );  
 void md5_final( MD5_CONTEXT * hd );  
 void md5_write( MD5_CONTEXT * hd, unsigned char *inbuf, size_t inlen );  
 void md5_init( MD5_CONTEXT * hd );  
   
 unsigned char * rmd160_read( RMD160_CONTEXT *hd );  
 void rmd160_init( RMD160_CONTEXT *hd );  
 void rmd160_write( RMD160_CONTEXT *hd, unsigned char *inbuf, size_t inlen);  
 void rmd160_final( RMD160_CONTEXT *hd );  
 void rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer );  
   
 void sha256_init(sha256_context *);  
 void sha256_write(sha256_context *, unsigned char *, size_t);  
 void sha256_final(sha256_context *);  
 unsigned char * sha256_read (sha256_context *);  
   
 void sha512_init(sha512_context *);  
 void sha512_write(sha512_context *, unsigned char *, size_t);  
 void sha512_final(sha512_context *);  
 unsigned char * sha512_read (sha512_context *);  
   
 void sha384_init(sha512_context *);  
   
   
   
 #endif /* GPGLIB_MD_H */  
1    /*  SHA256, SHA384, SHA512 Copyright 2001 by Jari Ruusu.
2     *  Redistribution of this file is permitted under the GNU Public License.
3     */
4    #ifndef GPGLIB_MD_H
5    #define GPGLIB_MD_H
6    
7    /****************
8     * Rotate a 32 bit integer by n bytes
9     */
10    #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
11    
12    #include <sys/types.h>
13    
14    typedef unsigned __int64 u_int64_t;
15    typedef unsigned __int32 u_int32_t;
16    
17    typedef struct {
18        unsigned char   sha_out[64];    /* results are here, bytes 0...31 */
19        u_int32_t       sha_H[8];
20        u_int64_t       sha_blocks;
21        int             sha_bufCnt;
22    } sha256_context;
23    
24    typedef struct {
25        unsigned char   sha_out[128];   /* results are here, bytes 0...63 */
26        u_int64_t       sha_H[8];
27        u_int64_t       sha_blocks;
28        u_int64_t       sha_blocksMSB;
29        int             sha_bufCnt;
30    } sha512_context;
31    
32    typedef struct {
33        unsigned long  h0,h1,h2,h3,h4;
34        unsigned long  nblocks;
35        unsigned char buf[64];
36        int  count;
37    } RMD160_CONTEXT;
38    
39    typedef struct {
40        unsigned long  h0,h1,h2,h3,h4;
41        unsigned long  nblocks;
42        unsigned char buf[64];
43        int  count;
44    } SHA1_CONTEXT;
45    
46    typedef struct {
47        unsigned long A,B,C,D;        /* chaining variables */
48        unsigned long  nblocks;
49        unsigned char buf[64];
50        int  count;
51    } MD5_CONTEXT;
52    
53    
54    unsigned char * sha1_read( SHA1_CONTEXT *hd );
55    void sha1_final( SHA1_CONTEXT *hd );
56    void sha1_write( SHA1_CONTEXT *hd, unsigned char *inbuf, size_t inlen );
57    void sha1_init( SHA1_CONTEXT *hd );
58    
59    unsigned char * md5_read( MD5_CONTEXT * hd );
60    void md5_final( MD5_CONTEXT * hd );
61    void md5_write( MD5_CONTEXT * hd, unsigned char *inbuf, size_t inlen );
62    void md5_init( MD5_CONTEXT * hd );
63    
64    unsigned char * rmd160_read( RMD160_CONTEXT *hd );
65    void rmd160_init( RMD160_CONTEXT *hd );
66    void rmd160_write( RMD160_CONTEXT *hd, unsigned char *inbuf, size_t inlen);
67    void rmd160_final( RMD160_CONTEXT *hd );
68    void rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer );
69    
70    void sha256_init(sha256_context *);
71    void sha256_write(sha256_context *, unsigned char *, size_t);
72    void sha256_final(sha256_context *);
73    unsigned char * sha256_read (sha256_context *);
74    
75    void sha512_init(sha512_context *);
76    void sha512_write(sha512_context *, unsigned char *, size_t);
77    void sha512_final(sha512_context *);
78    unsigned char * sha512_read (sha512_context *);
79    
80    void sha384_init(sha512_context *);
81    
82    
83    
84    #endif /* GPGLIB_MD_H */

Legend:
Removed from v.45  
changed lines
  Added in v.46

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26