~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/algorithm/sha1.h

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
#include <stdint.h>
14
14
#include <sys/types.h>
15
 
#include <string.h>
16
 
 
17
 
#include "drizzled/visibility.h"
18
15
 
19
16
namespace drizzled
20
17
{
21
18
 
22
19
/**
23
20
 * @addtogroup sha1 SHA-1 in C
24
 
 * 
25
 
 * This file is based on public domain code.
26
 
 * Initial source code is in the public domain, 
27
 
 * so clarified by Steve Reid <steve@edmweb.com>
28
 
 *
 
21
 * By Steve Reid <steve@edmweb.com>
 
22
 * 100% Public Domain
29
23
 * @{
30
24
 */
31
25
 
33
27
#define SHA1_DIGEST_LENGTH              20
34
28
#define SHA1_DIGEST_STRING_LENGTH       (SHA1_DIGEST_LENGTH * 2 + 1)
35
29
 
36
 
typedef class sha1_ctx{
37
 
public:
 
30
typedef struct {
38
31
    uint32_t state[5];
39
32
    uint64_t count;
40
33
    uint8_t buffer[SHA1_BLOCK_LENGTH];
41
 
 
42
 
    sha1_ctx():
43
 
        count(0)
44
 
    {
45
 
      memset(state, 0, 5);
46
 
      memset(buffer, 0, SHA1_BLOCK_LENGTH);
47
 
    }
48
34
} SHA1_CTX;
49
35
 
50
 
DRIZZLED_API void SHA1Init(SHA1_CTX *);
51
 
DRIZZLED_API void SHA1Pad(SHA1_CTX *);
52
 
DRIZZLED_API void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
53
 
DRIZZLED_API void SHA1Update(SHA1_CTX *, const uint8_t *, size_t);
54
 
DRIZZLED_API void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
 
36
void SHA1Init(SHA1_CTX *);
 
37
void SHA1Pad(SHA1_CTX *);
 
38
void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
 
39
void SHA1Update(SHA1_CTX *, const uint8_t *, size_t);
 
40
void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
55
41
 
56
42
/** @} */
57
43