reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
SHA1Stream.hxx
Go to the documentation of this file.
1#if !defined(RESIP_SHA1STREAM_HXX)
2#define RESIP_SHA1STREAM_HXX
3
4#if defined(HAVE_CONFIG_H)
5 #include "config.h"
6#endif
7
8#include <iostream>
9#include <memory>
10#include "rutil/compat.hxx"
11#include "rutil/Data.hxx"
13
14#pragma warning(1: 4996) // Move deprecated warnings back to level 1
15
41// This will not be compiled or installed if USE_SSL isn't set. If you are
42// including this file from a source tree, and you are getting link errors, you
43// are probably trying to link against libs that were built without SSL support.
44// Either stop trying to use this file, or re-build the libs with SSL support
45// enabled.
46
47namespace resip
48{
49
53class SHA1Buffer : public std::streambuf
54{
55 public:
56 SHA1Buffer();
57 virtual ~SHA1Buffer();
60 Data getHex();
66 Data getBin(unsigned int bits);
67
68 protected:
69 virtual int sync();
70 virtual int overflow(int c = -1);
71 private:
72 std::unique_ptr<EVP_MD_CTX, OpenSSLDeleter> mContext;
73 char mBuf[64];
74 bool mBlown;
75};
76
81class SHA1Stream : private SHA1Buffer, public std::ostream
82{
83 public:
89 Data getHex();
95 Data getBin(unsigned int bits=160);
96
99};
100
101}
102
103#endif
104/* ====================================================================
105 * The Vovida Software License, Version 1.0
106 *
107 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
108 *
109 * Redistribution and use in source and binary forms, with or without
110 * modification, are permitted provided that the following conditions
111 * are met:
112 *
113 * 1. Redistributions of source code must retain the above copyright
114 * notice, this list of conditions and the following disclaimer.
115 *
116 * 2. Redistributions in binary form must reproduce the above copyright
117 * notice, this list of conditions and the following disclaimer in
118 * the documentation and/or other materials provided with the
119 * distribution.
120 *
121 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
122 * and "Vovida Open Communication Application Library (VOCAL)" must
123 * not be used to endorse or promote products derived from this
124 * software without prior written permission. For written
125 * permission, please contact vocal@vovida.org.
126 *
127 * 4. Products derived from this software may not be called "VOCAL", nor
128 * may "VOCAL" appear in their name, without prior written
129 * permission of Vovida Networks, Inc.
130 *
131 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
132 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
133 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
134 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
135 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
136 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
137 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
138 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
139 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
140 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
141 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
142 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
143 * DAMAGE.
144 *
145 * ====================================================================
146 *
147 * This software consists of voluntary contributions made by Vovida
148 * Networks, Inc. and many individuals on behalf of Vovida Networks,
149 * Inc. For more information on Vovida Networks, Inc., please see
150 * <http://www.vovida.org/>.
151 *
152 */
Data bits(size_t v)
Definition Data.cxx:2342
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
An implementation of std::streambuf used to back the SHA1Stream.
virtual ~SHA1Buffer()
virtual int overflow(int c=-1)
Data getBin(unsigned int bits)
virtual int sync()
Used to accumlate data written to the stream in a SHA1Buffer and convert the data to SHA1.
Data getBin(unsigned int bits=160)
Calls flush() on itself and returns the SHA1 data in binary format.
Data getHex()
Calls flush() on itself and returns the SHA1 data in hex format.
uint32_t getUInt32()
Calls getBin(32) and converts to a UInt32.
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
#define RESIP_DEPRECATED(x)
Definition compat.hxx:334
dcm! – add UnusedChecking(_enum) below;
unsigned int uint32_t
Definition Stun.hxx:34