[BACK]Return to sha1.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/sha1.h, Revision 1.18

1.18    ! millert     1: /*     $OpenBSD: sha1.h,v 1.17 2004/04/26 19:38:12 millert Exp $       */
1.5       millert     2:
                      3: /*
                      4:  * SHA-1 in C
                      5:  * By Steve Reid <steve@edmweb.com>
                      6:  * 100% Public Domain
                      7:  */
1.1       millert     8:
1.2       millert     9: #ifndef _SHA1_H
                     10: #define _SHA1_H
                     11:
1.17      millert    12: #define        SHA1_BLOCK_LENGTH               64
                     13: #define        SHA1_DIGEST_LENGTH              20
                     14: #define        SHA1_DIGEST_STRING_LENGTH       (SHA1_DIGEST_LENGTH * 2 + 1)
                     15:
1.1       millert    16: typedef struct {
1.5       millert    17:     u_int32_t state[5];
1.18    ! millert    18:     u_int64_t count;
1.17      millert    19:     u_int8_t buffer[SHA1_BLOCK_LENGTH];
1.5       millert    20: } SHA1_CTX;
1.11      millert    21:
                     22: #include <sys/cdefs.h>
                     23:
                     24: __BEGIN_DECLS
1.18    ! millert    25: void SHA1Init(SHA1_CTX *);
1.17      millert    26: void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH])
1.15      avsm       27:                __attribute__((__bounded__(__minbytes__,1,5)))
1.17      millert    28:                __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
                     29: void SHA1Update(SHA1_CTX *, const u_int8_t *, unsigned int)
1.15      avsm       30:                __attribute__((__bounded__(__string__,2,3)));
1.17      millert    31: void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
                     32:                __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
                     33: char *SHA1End(SHA1_CTX *, char [SHA1_DIGEST_STRING_LENGTH])
                     34:                __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
                     35: char *SHA1File(char *, char [SHA1_DIGEST_STRING_LENGTH])
                     36:                __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
                     37: char *SHA1Data(const u_int8_t *, size_t, char [SHA1_DIGEST_STRING_LENGTH])
1.15      avsm       38:                __attribute__((__bounded__(__string__,1,2)))
1.17      millert    39:                __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
1.11      millert    40: __END_DECLS
1.9       angelos    41:
1.11      millert    42: #define HTONDIGEST(x) do {                                              \
                     43:         x[0] = htonl(x[0]);                                             \
                     44:         x[1] = htonl(x[1]);                                             \
                     45:         x[2] = htonl(x[2]);                                             \
                     46:         x[3] = htonl(x[3]);                                             \
                     47:         x[4] = htonl(x[4]); } while (0)
                     48:
                     49: #define NTOHDIGEST(x) do {                                              \
                     50:         x[0] = ntohl(x[0]);                                             \
                     51:         x[1] = ntohl(x[1]);                                             \
                     52:         x[2] = ntohl(x[2]);                                             \
                     53:         x[3] = ntohl(x[3]);                                             \
                     54:         x[4] = ntohl(x[4]); } while (0)
1.2       millert    55:
                     56: #endif /* _SHA1_H */