Coverage Report

Created: 2023-06-07 06:03

/src/resiprocate/rutil/MD5Stream.cxx
Line
Count
Source (jump to first uncovered line)
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
8
using namespace resip;
9
10
MD5Buffer::MD5Buffer()
11
2
{
12
2
   MD5Init(&mContext);
13
2
   setp(mBuf, mBuf + sizeof(mBuf));
14
2
   mLen = 0;
15
2
}
16
17
MD5Buffer::~MD5Buffer()
18
2
{
19
2
}
20
21
int
22
MD5Buffer::sync()
23
2
{
24
2
   size_t len = pptr() - pbase();
25
2
   if (len > 0) 
26
0
   {
27
0
      MD5Update(&mContext, reinterpret_cast <unsigned const char*>(pbase()), (unsigned int)len);
28
      // reset the put buffer
29
0
      setp(mBuf, mBuf + sizeof(mBuf));
30
0
      mLen += len;
31
0
   }
32
2
   return 0;
33
2
}
34
35
int
36
MD5Buffer::overflow(int c)
37
0
{
38
0
   sync();
39
0
   if (c != -1) 
40
0
   {
41
0
      mBuf[0] = c;
42
0
      pbump(1);
43
0
      return c;
44
0
   }
45
0
   return 0;
46
0
}
47
48
Data 
49
MD5Buffer::getHex()
50
2
{
51
2
   MD5Context tmp = mContext;
52
2
   MD5Final((unsigned char*)mBuf, &tmp);
53
2
   Data digest(Data::Share, (const char*)mBuf,16);
54
2
   return digest.hex();   
55
2
}
56
57
Data
58
MD5Buffer::getBin()
59
0
{
60
0
   MD5Context tmp = mContext;
61
0
   MD5Final((unsigned char*)mBuf, &tmp);
62
0
   Data digest(Data::Share, (const char*)mBuf,16);
63
0
   return digest;
64
0
}
65
66
size_t
67
MD5Buffer::bytesTaken()
68
0
{
69
0
   return mLen;
70
0
}
71
72
MD5Stream::MD5Stream()
73
   : std::ostream(this)
74
2
{
75
2
}
Unexecuted instantiation: resip::MD5Stream::MD5Stream()
resip::MD5Stream::MD5Stream()
Line
Count
Source
74
2
{
75
2
}
76
77
MD5Stream::~MD5Stream()
78
2
{}
79
80
Data 
81
MD5Stream::getHex()
82
2
{
83
2
   flush();
84
2
   return MD5Buffer::getHex();
85
   //return mStreambuf.getHex();
86
2
}
87
88
Data
89
MD5Stream::getBin()
90
0
{
91
0
   flush();
92
0
   return MD5Buffer::getBin();
93
0
}
94
95
size_t
96
MD5Stream::bytesTaken()
97
0
{
98
0
   return MD5Buffer::bytesTaken();
99
0
}
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
 */