~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSSha1.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
 
2
 *
 
3
 * PrimeBase S3Daemon
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
18
 *
 
19
 *  Modified by Barry Leslie on 10/21/08.
 
20
 *      I have put a C++ wrapper around the data and functions to create an sha1 class.
 
21
 *
 
22
 */
 
23
/*
 
24
  Original Source from: http://www.faqs.org/rfcs/rfc3174.html
 
25
  and MySQL mysys/sha1.c build 5.1.24.
 
26
 
 
27
 DESCRIPTION
 
28
   This file implements the Secure Hashing Algorithm 1 as
 
29
   defined in FIPS PUB 180-1 published April 17, 1995.
 
30
 
 
31
   The SHA-1, produces a 160-bit message digest for a given data
 
32
   stream.  It should take about 2**n steps to find a message with the
 
33
   same digest as a given message and 2**(n/2) to find any two
 
34
   messages with the same digest, when n is the digest size in bits.
 
35
   Therefore, this algorithm can serve as a means of providing a
 
36
   "fingerprint" for a message.
 
37
 
 
38
 PORTABILITY ISSUES
 
39
   SHA-1 is defined in terms of 32-bit "words".  This code uses
 
40
   <stdint.h> (included via "sha1.h" to define 32 and 8 bit unsigned
 
41
   integer types.  If your C compiler does not support 32 bit unsigned
 
42
   integers, this code is not appropriate.
 
43
 
 
44
 CAVEATS
 
45
   SHA-1 is designed to work with messages less than 2^64 bits long.
 
46
   Although SHA-1 allows a message digest to be generated for messages
 
47
   of any number of bits less than 2^64, this implementation only
 
48
   works with messages with a length that is a multiple of the size of
 
49
   an 8-bit character.
 
50
 
 
51
*/
 
52
 
 
53
#ifndef __CSSHA1_H__
 
54
#define __CSSHA1_H__
 
55
#include <string.h>
 
56
 
 
57
#define SHA1_HASH_SIZE 20
 
58
 
 
59
typedef struct {
 
60
        uint8_t val[SHA1_HASH_SIZE];
 
61
} Sha1Digest;
 
62
 
 
63
class CSSha1 : public CSObject {
 
64
        private:
 
65
        
 
66
        uint64_t  Length;                                                               // Message length in bits   
 
67
        uint32_t Intermediate_Hash[SHA1_HASH_SIZE/4];   // Message Digest  
 
68
        bool Computed;                                                                  // Is the digest computed?
 
69
        int16_t Message_Block_Index;                                    // Index into message block array  
 
70
        uint8_t Message_Block[64];                                              // 512-bit message blocks      
 
71
 
 
72
        void sha1_pad();
 
73
        void sha1_process();
 
74
 
 
75
        public:
 
76
        CSSha1() {sha1_reset();}
 
77
        
 
78
        void sha1_reset();
 
79
        void sha1_input(const void *data, size_t len);
 
80
        void sha1_digest(Sha1Digest *digest);
 
81
        
 
82
};
 
83
 
 
84
#endif // __CSSHA1_H__
 
85