"Fossies" - the Fresh Open Source Software Archive 
Member "zsync-0.6.2/libzsync/sha1.h" (16 Sep 2010, 2220 Bytes) of package /linux/privat/old/zsync-0.6.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "sha1.h" see the
Fossies "Dox" file reference documentation.
1 /* $OpenBSD: sha1.h,v 1.23 2004/06/22 01:57:30 jfb Exp $ */
2
3 /*
4 * SHA-1 in C
5 * By Steve Reid <steve@edmweb.com>
6 * 100% Public Domain
7 */
8
9 #ifndef _SHA1_H
10 #define _SHA1_H
11
12 #include "config.h"
13
14 #ifdef HAVE_INTTYPES_H
15 #include <inttypes.h>
16 #else
17 #include <sys/types.h>
18 #endif
19
20 #define SHA1_BLOCK_LENGTH 64
21 #define SHA1_DIGEST_LENGTH 20
22 #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
23
24 typedef struct {
25 uint32_t state[5];
26 uint64_t count;
27 uint8_t buffer[SHA1_BLOCK_LENGTH];
28 } SHA1_CTX;
29
30 void SHA1Init(SHA1_CTX *);
31 void SHA1Pad(SHA1_CTX *);
32 void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH])
33 ZS_DECL_BOUNDED(__minbytes__,1,5)
34 ZS_DECL_BOUNDED(__minbytes__,2,SHA1_BLOCK_LENGTH);
35 void SHA1Update(SHA1_CTX *, const uint8_t *, size_t)
36 ZS_DECL_BOUNDED(__string__,2,3);
37 void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
38 ZS_DECL_BOUNDED(__minbytes__,1,SHA1_DIGEST_LENGTH);
39 char *SHA1End(SHA1_CTX *, char *)
40 ZS_DECL_BOUNDED(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH);
41 char *SHA1File(const char *, char *)
42 ZS_DECL_BOUNDED(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH);
43 char *SHA1FileChunk(const char *, char *, off_t, off_t)
44 ZS_DECL_BOUNDED(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH);
45 char *SHA1Data(const uint8_t *, size_t, char *)
46 ZS_DECL_BOUNDED(__string__,1,2)
47 ZS_DECL_BOUNDED(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH);
48
49 #define HTONDIGEST(x) do { \
50 x[0] = htonl(x[0]); \
51 x[1] = htonl(x[1]); \
52 x[2] = htonl(x[2]); \
53 x[3] = htonl(x[3]); \
54 x[4] = htonl(x[4]); } while (0)
55
56 #define NTOHDIGEST(x) do { \
57 x[0] = ntohl(x[0]); \
58 x[1] = ntohl(x[1]); \
59 x[2] = ntohl(x[2]); \
60 x[3] = ntohl(x[3]); \
61 x[4] = ntohl(x[4]); } while (0)
62
63 #endif /* _SHA1_H */