aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2010-07-20 15:10:16 +0000
committerAdam Tkac <atkac@redhat.com>2010-07-20 15:10:16 +0000
commit0c77e51de8f78a7e50e443ee8a1890a6a2834a67 (patch)
tree62925663cc80404121a685c2062ea94219186339 /common
parent00b395a4101fba5c35708fc8071d82962cb1866d (diff)
downloadtigervnc-0c77e51de8f78a7e50e443ee8a1890a6a2834a67.tar.gz
tigervnc-0c77e51de8f78a7e50e443ee8a1890a6a2834a67.zip
[Development] Use U32 as internal SecurityType type.
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4097 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common')
-rw-r--r--common/rfb/Security.cxx46
-rw-r--r--common/rfb/Security.h34
2 files changed, 57 insertions, 23 deletions
diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx
index 7049439d..063e5dd1 100644
--- a/common/rfb/Security.cxx
+++ b/common/rfb/Security.cxx
@@ -62,9 +62,33 @@ Security::Security(void)
delete secTypesStr;
}
-void Security::EnableSecType(U8 secType)
+const std::list<rdr::U8> Security::GetEnabledSecTypes(void)
{
- list<U8>::iterator i;
+ list<rdr::U8> result;
+ list<U32>::iterator i;
+
+ for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
+ if (*i < 0x100)
+ result.push_back(*i);
+
+ return result;
+}
+
+const std::list<rdr::U32> Security::GetEnabledExtSecTypes(void)
+{
+ list<rdr::U32> result;
+ list<U32>::iterator i;
+
+ for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
+ if (*i >= 0x100)
+ result.push_back(*i);
+
+ return result;
+}
+
+void Security::EnableSecType(U32 secType)
+{
+ list<U32>::iterator i;
for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
if (*i == secType)
@@ -73,9 +97,9 @@ void Security::EnableSecType(U8 secType)
enabledSecTypes.push_back(secType);
}
-bool Security::IsSupported(U8 secType)
+bool Security::IsSupported(U32 secType)
{
- list<U8>::iterator i;
+ list<U32>::iterator i;
for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
if (*i == secType)
@@ -84,7 +108,7 @@ bool Security::IsSupported(U8 secType)
return false;
}
-SSecurity* Security::GetSSecurity(U8 secType)
+SSecurity* Security::GetSSecurity(U32 secType)
{
if (!IsSupported(secType))
goto bail;
@@ -101,7 +125,7 @@ bail:
throw Exception("Security type not supported");
}
-CSecurity* Security::GetCSecurity(U8 secType)
+CSecurity* Security::GetCSecurity(U32 secType)
{
assert (CSecurity::upg != NULL); /* (upg == NULL) means bug in the viewer */
@@ -120,7 +144,7 @@ bail:
throw Exception("Security type not supported");
}
-rdr::U8 rfb::secTypeNum(const char* name)
+rdr::U32 rfb::secTypeNum(const char* name)
{
if (strcasecmp(name, "None") == 0) return secTypeNone;
if (strcasecmp(name, "VncAuth") == 0) return secTypeVncAuth;
@@ -133,7 +157,7 @@ rdr::U8 rfb::secTypeNum(const char* name)
return secTypeInvalid;
}
-const char* rfb::secTypeName(rdr::U8 num)
+const char* rfb::secTypeName(rdr::U32 num)
{
switch (num) {
case secTypeNone: return "None";
@@ -148,13 +172,13 @@ const char* rfb::secTypeName(rdr::U8 num)
}
}
-std::list<rdr::U8> rfb::parseSecTypes(const char* types_)
+std::list<rdr::U32> rfb::parseSecTypes(const char* types_)
{
- std::list<rdr::U8> result;
+ std::list<rdr::U32> result;
CharArray types(strDup(types_)), type;
while (types.buf) {
strSplit(types.buf, ',', &type.buf, &types.buf);
- rdr::U8 typeNum = secTypeNum(type.buf);
+ rdr::U32 typeNum = secTypeNum(type.buf);
if (typeNum != secTypeInvalid)
result.push_back(typeNum);
}
diff --git a/common/rfb/Security.h b/common/rfb/Security.h
index 19019353..54cdb80e 100644
--- a/common/rfb/Security.h
+++ b/common/rfb/Security.h
@@ -67,22 +67,32 @@ namespace rfb {
*/
Security(void);
+ /*
+ * Note about security types.
+ *
+ * Although RFB protocol specifies security types as U8 values,
+ * we map VeNCrypt subtypes (U32) into the standard security types
+ * to simplify user configuration. With this mapping user can configure
+ * both VeNCrypt subtypes and security types with only one option.
+ */
+
/* Enable/Disable certain security type */
- void EnableSecType(rdr::U8 secType);
- void DisableSecType(rdr::U8 secType) { enabledSecTypes.remove(secType); }
+ void EnableSecType(rdr::U32 secType);
+ void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); }
/* Check if certain type is supported */
- bool IsSupported(rdr::U8 secType);
+ bool IsSupported(rdr::U32 secType);
- /* Get list of enabled security types */
- const std::list<rdr::U8>& GetEnabledSecTypes(void)
- { return enabledSecTypes; }
+ /* Get list of enabled security types without VeNCrypt subtypes */
+ const std::list<rdr::U8> GetEnabledSecTypes(void);
+ /* Get list of enabled VeNCrypt subtypes */
+ const std::list<rdr::U32> GetEnabledExtSecTypes(void);
/* Create server side SSecurity class instance */
- SSecurity* GetSSecurity(rdr::U8 secType);
+ SSecurity* GetSSecurity(rdr::U32 secType);
/* Create client side CSecurity class instance */
- CSecurity* GetCSecurity(rdr::U8 secType);
+ CSecurity* GetCSecurity(rdr::U32 secType);
static StringParameter secTypes;
@@ -91,12 +101,12 @@ namespace rfb {
* only in viewer-side code and MUST be set by viewer.
*/
private:
- std::list<rdr::U8> enabledSecTypes;
+ std::list<rdr::U32> enabledSecTypes;
};
- const char* secTypeName(rdr::U8 num);
- rdr::U8 secTypeNum(const char* name);
- std::list<rdr::U8> parseSecTypes(const char* types);
+ const char* secTypeName(rdr::U32 num);
+ rdr::U32 secTypeNum(const char* name);
+ std::list<rdr::U32> parseSecTypes(const char* types);
}
#endif