Coverage Report

Created: 2025-06-13 06:12

/src/resiprocate/resip/stack/SecurityAttributes.hxx
Line
Count
Source (jump to first uncovered line)
1
#ifndef RESIP_SecurityAttributes_hxx
2
#define RESIP_SecurityAttributes_hxx
3
4
#include <iostream>
5
6
#include "rutil/Data.hxx"
7
8
namespace resip
9
{
10
11
enum SignatureStatus
12
{
13
   SignatureNone, // there is no signature
14
   SignatureIsBad,
15
   SignatureTrusted, // It is signed with trusted signature
16
   SignatureCATrusted, // signature is new and is signed by a root we trust
17
   SignatureNotTrusted, // signature is new and is not signed by a CA we
18
   SignatureSelfSigned
19
};
20
21
class SecurityAttributes
22
{
23
   public:
24
      SecurityAttributes();
25
      ~SecurityAttributes();      
26
27
      typedef enum {None, Sign, Encrypt, SignAndEncrypt} OutgoingEncryptionLevel;
28
29
      typedef enum {From, FailedIdentity, Identity} IdentityStrength;
30
31
      SignatureStatus getSignatureStatus() const
32
0
      {
33
0
         return mSigStatus;
34
0
      }
35
36
      bool isEncrypted() const
37
0
      {
38
0
         return mIsEncrypted;
39
0
      }
40
      void setEncrypted()
41
0
      {
42
0
         mIsEncrypted = true;
43
0
      }
44
      
45
      void setSignatureStatus(SignatureStatus status)
46
0
      {
47
0
         mSigStatus = status;
48
0
      }
49
50
      void setIdentity(const Data& identity)
51
0
      {
52
0
         mIdentity = identity;
53
0
      }
54
55
      const Data& getIdentity() const
56
0
      {
57
0
         return mIdentity;
58
0
      }
59
60
      void setIdentityStrength(IdentityStrength strength)
61
0
      {
62
0
         mStrength = strength;         
63
0
      }      
64
65
      IdentityStrength getIdentityStrength() const
66
0
      {
67
0
         return mStrength;
68
0
      }
69
      
70
      void setSigner(const Data& signer)
71
0
      {
72
0
         mSigner = signer;
73
0
      }
74
75
      const Data& getSigner() const
76
0
      {
77
0
         return mSigner;
78
0
      }
79
80
      OutgoingEncryptionLevel getOutgoingEncryptionLevel() const
81
0
      {
82
0
         return mLevel;
83
0
      }
84
85
      void setOutgoingEncryptionLevel(OutgoingEncryptionLevel level)
86
0
      {
87
0
         mLevel = level;
88
0
      }
89
90
      bool encryptionPerformed() const
91
0
      {
92
0
         return mEncryptionPerformed;
93
0
      }
94
95
      void setEncryptionPerformed(bool performed)
96
0
      {
97
0
         mEncryptionPerformed = performed;
98
0
      }
99
100
   friend EncodeStream& operator<<(EncodeStream& strm, const SecurityAttributes& sa);
101
102
   private:
103
      bool mIsEncrypted;
104
      SignatureStatus mSigStatus;
105
      Data mSigner;
106
      Data mIdentity;
107
      IdentityStrength mStrength;
108
      OutgoingEncryptionLevel mLevel; // for outgoing messages.
109
      bool mEncryptionPerformed;
110
};
111
112
   EncodeStream& operator<<(EncodeStream& strm, const SecurityAttributes& sa);
113
}
114
115
#endif
116
117
/* ====================================================================
118
 * The Vovida Software License, Version 1.0 
119
 * 
120
 * Copyright (c) 2000-2005 Vovida Networks, Inc.  All rights reserved.
121
 * 
122
 * Redistribution and use in source and binary forms, with or without
123
 * modification, are permitted provided that the following conditions
124
 * are met:
125
 * 
126
 * 1. Redistributions of source code must retain the above copyright
127
 *    notice, this list of conditions and the following disclaimer.
128
 * 
129
 * 2. Redistributions in binary form must reproduce the above copyright
130
 *    notice, this list of conditions and the following disclaimer in
131
 *    the documentation and/or other materials provided with the
132
 *    distribution.
133
 * 
134
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
135
 *    and "Vovida Open Communication Application Library (VOCAL)" must
136
 *    not be used to endorse or promote products derived from this
137
 *    software without prior written permission. For written
138
 *    permission, please contact vocal@vovida.org.
139
 *
140
 * 4. Products derived from this software may not be called "VOCAL", nor
141
 *    may "VOCAL" appear in their name, without prior written
142
 *    permission of Vovida Networks, Inc.
143
 * 
144
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
145
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
146
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
147
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
148
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
149
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
150
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
151
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
152
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
153
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
154
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
155
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
156
 * DAMAGE.
157
 * 
158
 * ====================================================================
159
 * 
160
 * This software consists of voluntary contributions made by Vovida
161
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
162
 * Inc.  For more information on Vovida Networks, Inc., please see
163
 * <http://www.vovida.org/>.
164
 *
165
 */