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

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

1.15    ! avsm        1: /*     $OpenBSD: sha1.h,v 1.14 2003/08/01 17:38:33 avsm 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.1       millert    12: typedef struct {
1.5       millert    13:     u_int32_t state[5];
1.11      millert    14:     u_int32_t count[2];
1.5       millert    15:     u_char buffer[64];
                     16: } SHA1_CTX;
1.11      millert    17:
                     18: #include <sys/cdefs.h>
                     19:
                     20: __BEGIN_DECLS
1.15    ! avsm       21: void SHA1Transform(u_int32_t state[5], const u_char buffer[64])
        !            22:                __attribute__((__bounded__(__minbytes__,1,5)))
        !            23:                __attribute__((__bounded__(__minbytes__,2,64)));
1.10      millert    24: void SHA1Init(SHA1_CTX *context);
1.15    ! avsm       25: void SHA1Update(SHA1_CTX *context, const u_char *data, u_int len)
        !            26:                __attribute__((__bounded__(__string__,2,3)));
        !            27: void SHA1Final(u_char digest[20], SHA1_CTX *context)
        !            28:                __attribute__((__bounded__(__minbytes__,1,20)));
        !            29: char *SHA1End(SHA1_CTX *, char *)
        !            30:                __attribute__((__bounded__(__minbytes__,2,41)));
        !            31: char *SHA1File(char *, char *)
        !            32:                __attribute__((__bounded__(__minbytes__,2,41)));
1.14      avsm       33: char *SHA1Data(const u_char *, size_t, char *)
1.15    ! avsm       34:                __attribute__((__bounded__(__string__,1,2)))
        !            35:                __attribute__((__bounded__(__minbytes__,3,41)));
1.11      millert    36: __END_DECLS
1.9       angelos    37:
                     38: #define SHA1_DIGESTSIZE       20
                     39: #define SHA1_BLOCKSIZE        64
1.11      millert    40: #define HTONDIGEST(x) do {                                              \
                     41:         x[0] = htonl(x[0]);                                             \
                     42:         x[1] = htonl(x[1]);                                             \
                     43:         x[2] = htonl(x[2]);                                             \
                     44:         x[3] = htonl(x[3]);                                             \
                     45:         x[4] = htonl(x[4]); } while (0)
                     46:
                     47: #define NTOHDIGEST(x) do {                                              \
                     48:         x[0] = ntohl(x[0]);                                             \
                     49:         x[1] = ntohl(x[1]);                                             \
                     50:         x[2] = ntohl(x[2]);                                             \
                     51:         x[3] = ntohl(x[3]);                                             \
                     52:         x[4] = ntohl(x[4]); } while (0)
1.2       millert    53:
                     54: #endif /* _SHA1_H */