summaryrefslogtreecommitdiff
path: root/nova/console/rfb/auth.py
blob: f4032bed39d9905fb31e9a6aae087733af8f063a (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
# Copyright (c) 2014-2017 Red Hat, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import abc
import enum

VERSION_LENGTH = 12
SUBTYPE_LENGTH = 4

AUTH_STATUS_FAIL = b"\x00"
AUTH_STATUS_PASS = b"\x01"


@enum.unique
class AuthType(enum.IntEnum):

    INVALID = 0
    NONE = 1
    VNC = 2
    RA2 = 5
    RA2NE = 6
    TIGHT = 16
    ULTRA = 17
    TLS = 18  # Used by VINO
    VENCRYPT = 19  # Used by VeNCrypt and QEMU
    SASL = 20  # SASL type used by VINO and QEMU
    ARD = 30  # Apple remote desktop (screen sharing)
    MSLOGON = 0xfffffffa  # Used by UltraVNC


class RFBAuthScheme(metaclass=abc.ABCMeta):

    @abc.abstractmethod
    def security_type(self):
        """Return the security type supported by this scheme

        Returns the nova.console.rfb.auth.AuthType.XX
        constant representing the scheme implemented.
        """
        pass

    @abc.abstractmethod
    def security_handshake(self, compute_sock):
        """Perform security-type-specific functionality.

        This method is expected to return the socket-like
        object used to communicate with the server securely.

        Should raise exception.RFBAuthHandshakeFailed if
        an error occurs

        :param compute_sock: socket connected to the compute node instance
        """
        pass