summaryrefslogtreecommitdiffstats
path: root/common/rfb/Security.h
blob: 7b9fd407dfb16fac24ee325d93e9ce086c7a45e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
 * 
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 * USA.
 */
//
// secTypes.h - constants for the various security types.
//

#ifndef __RFB_SECTYPES_H__
#define __RFB_SECTYPES_H__

#include <rdr/types.h>
#include <rfb/Configuration.h>
#include <rfb/CSecurity.h>
#include <rfb/SSecurity.h>

#include <list>

namespace rfb {
  const rdr::U8 secTypeInvalid = 0;
  const rdr::U8 secTypeNone    = 1;
  const rdr::U8 secTypeVncAuth = 2;

  const rdr::U8 secTypeRA2     = 5;
  const rdr::U8 secTypeRA2ne   = 6;

  const rdr::U8 secTypeSSPI    = 7;
  const rdr::U8 secTypeSSPIne  = 8;

  const rdr::U8 secTypeTight   = 16;
  const rdr::U8 secTypeUltra   = 17;
  const rdr::U8 secTypeTLS     = 18;
  const rdr::U8 secTypeVeNCrypt= 19;

  /* VeNCrypt subtypes */
  const int secTypePlain       = 256;
  const int secTypeTLSNone     = 257;
  const int secTypeTLSVnc      = 258;
  const int secTypeTLSPlain    = 259;
  const int secTypeX509None    = 260;
  const int secTypeX509Vnc     = 261;
  const int secTypeX509Plain   = 262;

  // result types

  const rdr::U32 secResultOK = 0;
  const rdr::U32 secResultFailed = 1;
  const rdr::U32 secResultTooMany = 2; // deprecated

  enum SecurityClassType { SecurityViewer, SecurityServer };

  class Security {
  public:
    /*
     * Create Security instance.
     */
    Security(SecurityClassType secClassType);

    /*
     * 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::U32 secType);
    void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); }

    /* Check if certain type is supported */
    bool IsSupported(rdr::U32 secType);

    /* 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::U32 secType);

    /* Create client side CSecurity class instance */
    CSecurity* GetCSecurity(rdr::U32 secType);

    static StringParameter secTypesViewer;
    static StringParameter secTypesServer;

  private:
    std::list<rdr::U32> enabledSecTypes;
  };

  const char* secTypeName(rdr::U32 num);
  rdr::U32 secTypeNum(const char* name);
  std::list<rdr::U32> parseSecTypes(const char* types);
}

#endif