reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
MD5Stream.cxx
Go to the documentation of this file.
1#include "rutil/MD5Stream.hxx"
2
3// Remove warning about 'this' use in initiator list - pointer is only stored
4#if defined(WIN32) && !defined(__GNUC__)
5#pragma warning( disable : 4355 ) // using this in base member initializer list
6#endif
7
8using namespace resip;
9
11{
12 MD5Init(&mContext);
13 setp(mBuf, mBuf + sizeof(mBuf));
14 mLen = 0;
15}
16
20
21int
23{
24 size_t len = pptr() - pbase();
25 if (len > 0)
26 {
27 MD5Update(&mContext, reinterpret_cast <unsigned const char*>(pbase()), (unsigned int)len);
28 // reset the put buffer
29 setp(mBuf, mBuf + sizeof(mBuf));
30 mLen += len;
31 }
32 return 0;
33}
34
35int
37{
38 sync();
39 if (c != -1)
40 {
41 mBuf[0] = c;
42 pbump(1);
43 return c;
44 }
45 return 0;
46}
47
48Data
50{
51 MD5Context tmp = mContext;
52 MD5Final((unsigned char*)mBuf, &tmp);
53 Data digest(Data::Share, (const char*)mBuf,16);
54 return digest.hex();
55}
56
57Data
59{
60 MD5Context tmp = mContext;
61 MD5Final((unsigned char*)mBuf, &tmp);
62 Data digest(Data::Share, (const char*)mBuf,16);
63 return digest;
64}
65
66size_t
68{
69 return mLen;
70}
71
73 : std::ostream(this)
74{
75}
76
79
80Data
82{
83 flush();
84 return MD5Buffer::getHex();
85 //return mStreambuf.getHex();
86}
87
88Data
90{
91 flush();
92 return MD5Buffer::getBin();
93}
94
95size_t
100
101/* ====================================================================
102 * The Vovida Software License, Version 1.0
103 *
104 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
105 *
106 * Redistribution and use in source and binary forms, with or without
107 * modification, are permitted provided that the following conditions
108 * are met:
109 *
110 * 1. Redistributions of source code must retain the above copyright
111 * notice, this list of conditions and the following disclaimer.
112 *
113 * 2. Redistributions in binary form must reproduce the above copyright
114 * notice, this list of conditions and the following disclaimer in
115 * the documentation and/or other materials provided with the
116 * distribution.
117 *
118 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
119 * and "Vovida Open Communication Application Library (VOCAL)" must
120 * not be used to endorse or promote products derived from this
121 * software without prior written permission. For written
122 * permission, please contact vocal@vovida.org.
123 *
124 * 4. Products derived from this software may not be called "VOCAL", nor
125 * may "VOCAL" appear in their name, without prior written
126 * permission of Vovida Networks, Inc.
127 *
128 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
129 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
130 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
131 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
132 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
133 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
134 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
135 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
136 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
137 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
138 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
139 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
140 * DAMAGE.
141 *
142 * ====================================================================
143 *
144 * This software consists of voluntary contributions made by Vovida
145 * Networks, Inc. and many individuals on behalf of Vovida Networks,
146 * Inc. For more information on Vovida Networks, Inc., please see
147 * <http://www.vovida.org/>.
148 *
149 */
static Data digest("digest")
DEPRECATED - Use DigestStream.hxx instead.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
@ Share
The Data instance will use the buffer in a read-only mode.
Definition Data.hxx:266
Data hex() const
Returns a hexadecimal representation of the contents of this Data.
Definition Data.cxx:1577
virtual int sync()
Definition MD5Stream.cxx:22
size_t bytesTaken()
Definition MD5Stream.cxx:67
virtual int overflow(int c=-1)
Definition MD5Stream.cxx:36
virtual ~MD5Buffer()
Definition MD5Stream.cxx:17
Data getHex()
Calls flush() on itself and returns the MD5 data in hex format.
Definition MD5Stream.cxx:81
size_t bytesTaken()
Definition MD5Stream.cxx:96
dcm! – add UnusedChecking(_enum) below;
void MD5Final(unsigned char digest[16], struct MD5Context *context)
Definition vmd5.cxx:116
void MD5Init(struct MD5Context *context)
Definition vmd5.cxx:58
void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len)
Definition vmd5.cxx:74