reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Sha1.hxx
Go to the documentation of this file.
1/*
2 Original Source code contained this header:
3
4 sha1.h - header of
5
6 ============
7 SHA-1 in C++
8 ============
9
10 100% Public Domain.
11
12 Original C Code
13 -- Steve Reid <steve@edmweb.com>
14 Small changes to fit into bglibs
15 -- Bruce Guenter <bruce@untroubled.org>
16 Translation to simpler C++ Code
17 -- Volker Grabsch <vog@notjusthosting.com>
18*/
19
20/* Note: This class was brought in to facilitate simple SHA1 hashing for those that don't want to include
21 OpenSSL in their project. It is assumed that the OpenSSL implementaiton is more efficient and should be
22 used in favor of this class whenever possible */
23
24#ifndef RESIP_SHA1_HXX
25#define RESIP_SHA1_HXX
26
27
28#include <iostream>
29#include <string>
30
31#include <stdint.h>
32
33#include "Data.hxx"
34
35namespace resip
36{
37
38class Sha1 // Produces a 160bit hash (20 hexidecimal digits, 40 characters when converted to a hex string)
39{
40public:
41 Sha1();
42 void update(const std::string &s);
43 void update(std::istream &is);
44 std::string final();
46 static std::string from_file(const std::string &filename);
47
48private:
49 static const unsigned int DIGEST_INTS = 5; /* number of 32bit integers per SHA1 digest */
50 static const unsigned int BLOCK_INTS = 16; /* number of 32bit integers per SHA1 block */
51 static const unsigned int BLOCK_BYTES = BLOCK_INTS * 4;
52
53 uint32_t digest[DIGEST_INTS];
54 std::string buffer;
55 uint64_t transforms;
56
57 void reset();
58 void createDigest();
59 void transform(uint32_t block[BLOCK_BYTES]);
60
61 static void buffer_to_block(const std::string &buffer, uint32_t block[BLOCK_BYTES]);
62 static void read(std::istream &is, std::string &s, int max);
63};
64
65}
66
67#endif /* SHA1_HPP */
68
69/* ====================================================================
70 * The Vovida Software License, Version 1.0
71 *
72 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
73 *
74 * Redistribution and use in source and binary forms, with or without
75 * modification, are permitted provided that the following conditions
76 * are met:
77 *
78 * 1. Redistributions of source code must retain the above copyright
79 * notice, this list of conditions and the following disclaimer.
80 *
81 * 2. Redistributions in binary form must reproduce the above copyright
82 * notice, this list of conditions and the following disclaimer in
83 * the documentation and/or other materials provided with the
84 * distribution.
85 *
86 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
87 * and "Vovida Open Communication Application Library (VOCAL)" must
88 * not be used to endorse or promote products derived from this
89 * software without prior written permission. For written
90 * permission, please contact vocal@vovida.org.
91 *
92 * 4. Products derived from this software may not be called "VOCAL", nor
93 * may "VOCAL" appear in their name, without prior written
94 * permission of Vovida Networks, Inc.
95 *
96 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
97 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
98 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
99 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
100 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
101 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
102 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
103 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
104 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
105 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
106 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
107 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
108 * DAMAGE.
109 *
110 * ====================================================================
111 *
112 * This software consists of voluntary contributions made by Vovida
113 * Networks, Inc. and many individuals on behalf of Vovida Networks,
114 * Inc. For more information on Vovida Networks, Inc., please see
115 * <http://www.vovida.org/>.
116 *
117 */
#define max(x, y)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
resip::Data finalBin()
Definition Sha1.cxx:79
void update(const std::string &s)
Definition Sha1.cxx:33
static std::string from_file(const std::string &filename)
Definition Sha1.cxx:128
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t
Definition Stun.hxx:39
unsigned int uint32_t
Definition Stun.hxx:34