source: trunk/libtransmission/sha1.h @ 1125

Last change on this file since 1125 was 261, checked in by titer, 16 years ago

Updated svn:keywords

  • Property svn:keywords set to Date Rev Author Id
File size: 2.2 KB
Line 
1/*
2 sha1.h: Implementation of SHA-1 Secure Hash Algorithm-1
3
4 Based upon: NIST FIPS180-1 Secure Hash Algorithm-1
5   http://www.itl.nist.gov/fipspubs/fip180-1.htm
6
7 Non-official Japanese Translation by HIRATA Yasuyuki:
8   http://yasu.asuka.net/translations/SHA-1.html
9
10 Copyright (C) 2002 vi@nwr.jp. All rights reserved.
11
12 This software is provided 'as-is', without any express or implied
13 warranty. In no event will the authors be held liable for any damages
14 arising from the use of this software.
15
16 Permission is granted to anyone to use this software for any purpose,
17 including commercial applications, and to alter it and redistribute it
18 freely, subject to the following restrictions:
19
20 1. The origin of this software must not be misrepresented; you must not
21    claim that you wrote the original software. If you use this software
22    in a product, an acknowledgement in the product documentation would be
23    appreciated but is not required.
24 2. Altered source versions must be plainly marked as such, and must not be
25    misrepresented as beging the original software.
26 3. This notice may not be removed or altered from any source distribution.
27
28 Note:
29   The copyright notice above is copied from md5.h by L. Petet Deutsch
30   <ghost@aladdin.com>. Thank him since I'm not a good speaker of English. :)
31 */
32#ifndef SHA1_H
33#define SHA1_H
34
35typedef unsigned int    sha1_word_t;    /* 32bits unsigned integer */
36typedef unsigned char   sha1_byte_t;    /* 8bits unsigned integer */
37#define BITS            8
38
39/* Define the state of SHA-1 algorithm */
40typedef struct {
41  sha1_byte_t   sha1_buf[64];   /* 512 bits */
42  int           sha1_count;     /* How many bytes are used */
43  sha1_word_t   sha1_size1;             /* Length counter Lower Word */
44  sha1_word_t   sha1_size2;             /* Length counter Upper Word */
45  sha1_word_t   sha1_h[5];              /* Hash output */
46} sha1_state_s;
47#define SHA1_OUTPUT_SIZE        20      /* in bytes */
48
49/* External Functions */
50
51#ifdef  __cplusplus
52extern "C" {
53#endif
54
55/* Initialize SHA-1 algorithm */
56void    sha1_init(sha1_state_s *pms);
57
58/* Append a string to SHA-1 algorithm */
59void    sha1_update(sha1_state_s *pms, sha1_byte_t *input_buffer, int length);
60
61/* Finish the SHA-1 algorithm and return the hash */
62void    sha1_finish(sha1_state_s *pms, sha1_byte_t output[SHA1_OUTPUT_SIZE]);
63
64#ifdef  __cplusplus
65}
66#endif
67
68#endif
Note: See TracBrowser for help on using the repository browser.