Back to index

courier  0.68.2
sha1.h
Go to the documentation of this file.
00001 #ifndef       sha1_h
00002 #define       sha1_h
00003 
00004 /*
00005 ** Copyright 2001-2008 Double Precision, Inc.
00006 ** See COPYING for distribution information.
00007 */
00008 
00009 
00010 #if    HAVE_CONFIG_H
00011 #include      "sha1/config.h"
00012 #endif
00013 
00014 #if    HAVE_SYS_TYPES_H
00015 #include      <sys/types.h>
00016 #endif
00017 
00018 #define       SHA1_DIGEST_SIZE     20
00019 #define       SHA1_BLOCK_SIZE             64
00020 
00021 #define SHA256_DIGEST_SIZE  32
00022 #define SHA256_BLOCK_SIZE   64
00023 
00024 #define SHA512_DIGEST_SIZE  64
00025 #define SHA512_BLOCK_SIZE   128
00026 
00027 typedef SHA1_WORD SHA256_WORD;
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 typedef       unsigned char SHA1_DIGEST[20];
00034 typedef unsigned char SHA256_DIGEST[32];
00035 typedef unsigned char SHA512_DIGEST[64];
00036 
00037 #ifdef SHA1_INTERNAL
00038 
00039 struct SHA1_CONTEXT {
00040 
00041        SHA1_WORD     H[5];
00042 
00043        unsigned char blk[SHA1_BLOCK_SIZE];
00044        unsigned blk_ptr;
00045        } ;
00046 
00047 struct SHA256_CONTEXT {
00048 
00049        SHA256_WORD   H[8];
00050 
00051        unsigned char blk[SHA256_BLOCK_SIZE];
00052        unsigned blk_ptr;
00053        } ;
00054 
00055 struct SHA512_CONTEXT {
00056 
00057        SHA512_WORD   H[8];
00058 
00059        unsigned char blk[SHA512_BLOCK_SIZE];
00060        unsigned blk_ptr;
00061        } ;
00062 
00063 void sha1_context_init(struct SHA1_CONTEXT *);
00064 void sha1_context_hash(struct SHA1_CONTEXT *,
00065                      const unsigned char[SHA1_BLOCK_SIZE]);
00066 void sha1_context_hashstream(struct SHA1_CONTEXT *, const void *, unsigned);
00067 void sha1_context_endstream(struct SHA1_CONTEXT *, unsigned long);
00068 void sha1_context_digest(struct SHA1_CONTEXT *, SHA1_DIGEST);
00069 void sha1_context_restore(struct SHA1_CONTEXT *, const SHA1_DIGEST);
00070 
00071 void sha256_context_init(struct SHA256_CONTEXT *);
00072 void sha256_context_hash(struct SHA256_CONTEXT *,
00073                       const unsigned char[SHA256_BLOCK_SIZE]);
00074 void sha256_context_hashstream(struct SHA256_CONTEXT *,
00075                             const void *, unsigned);
00076 void sha256_context_endstream(struct SHA256_CONTEXT *, unsigned long);
00077 void sha256_context_digest(struct SHA256_CONTEXT *, SHA256_DIGEST);
00078 void sha256_context_restore(struct SHA256_CONTEXT *, const SHA256_DIGEST);
00079 
00080 void sha512_context_init(struct SHA512_CONTEXT *);
00081 void sha512_context_hash(struct SHA512_CONTEXT *,
00082                       const unsigned char[SHA512_BLOCK_SIZE]);
00083 void sha512_context_hashstream(struct SHA512_CONTEXT *,
00084                             const void *, unsigned);
00085 void sha512_context_endstream(struct SHA512_CONTEXT *, SHA512_WORD);
00086 void sha512_context_digest(struct SHA512_CONTEXT *, SHA512_DIGEST);
00087 void sha512_context_restore(struct SHA512_CONTEXT *, const SHA512_DIGEST);
00088 
00089 #endif
00090 
00091 void sha1_digest(const void *, unsigned, SHA1_DIGEST);
00092 const char *sha1_hash(const char *);
00093 
00094 typedef unsigned char SSHA_RAND[4];
00095 
00096 const char *ssha_hash(const char *, SSHA_RAND);
00097 
00098 void sha256_digest(const void *, unsigned, SHA256_DIGEST);
00099 
00100 const char *sha256_hash(const char *);
00101 
00102 void sha512_digest(const void *, unsigned, SHA512_DIGEST);
00103 
00104 const char *sha512_hash(const char *);
00105 
00106 #ifdef __cplusplus
00107  } ;
00108 #endif
00109 
00110 #endif