diff --git a/security.go b/security.go index e2cced6..0b846d4 100644 --- a/security.go +++ b/security.go @@ -5,12 +5,12 @@ type SecurityType uint8 //go:generate stringer -type=SecurityType const ( - SecTypeUnknown = SecurityType(0) - SecTypeNone = SecurityType(1) - SecTypeVNC = SecurityType(2) - SecTypeTight = SecurityType(16) - SecTypeATEN = SecurityType(16) - SecTypeVeNCrypt = SecurityType(19) + SecTypeUnknown SecurityType = SecurityType(0) + SecTypeNone SecurityType = SecurityType(1) + SecTypeVNC SecurityType = SecurityType(2) + SecTypeTight SecurityType = SecurityType(16) + SecTypeATEN SecurityType = SecurityType(16) + SecTypeVeNCrypt SecurityType = SecurityType(19) ) type SecuritySubType uint32 @@ -18,29 +18,29 @@ type SecuritySubType uint32 //go:generate stringer -type=SecuritySubType const ( - SecSubTypeUnknown = SecuritySubType(0) + SecSubTypeUnknown SecuritySubType = SecuritySubType(0) ) const ( - SecSubTypeVeNCrypt01Unknown = SecuritySubType(0) - SecSubTypeVeNCrypt01Plain = SecuritySubType(19) - SecSubTypeVeNCrypt01TLSNone = SecuritySubType(20) - SecSubTypeVeNCrypt01TLSVNC = SecuritySubType(21) - SecSubTypeVeNCrypt01TLSPlain = SecuritySubType(22) - SecSubTypeVeNCrypt01X509None = SecuritySubType(23) - SecSubTypeVeNCrypt01X509VNC = SecuritySubType(24) - SecSubTypeVeNCrypt01X509Plain = SecuritySubType(25) + SecSubTypeVeNCrypt01Unknown SecuritySubType = SecuritySubType(0) + SecSubTypeVeNCrypt01Plain SecuritySubType = SecuritySubType(19) + SecSubTypeVeNCrypt01TLSNone SecuritySubType = SecuritySubType(20) + SecSubTypeVeNCrypt01TLSVNC SecuritySubType = SecuritySubType(21) + SecSubTypeVeNCrypt01TLSPlain SecuritySubType = SecuritySubType(22) + SecSubTypeVeNCrypt01X509None SecuritySubType = SecuritySubType(23) + SecSubTypeVeNCrypt01X509VNC SecuritySubType = SecuritySubType(24) + SecSubTypeVeNCrypt01X509Plain SecuritySubType = SecuritySubType(25) ) const ( - SecSubTypeVeNCrypt02Unknown = SecuritySubType(0) - SecSubTypeVeNCrypt02Plain = SecuritySubType(256) - SecSubTypeVeNCrypt02TLSNone = SecuritySubType(257) - SecSubTypeVeNCrypt02TLSVNC = SecuritySubType(258) - SecSubTypeVeNCrypt02TLSPlain = SecuritySubType(259) - SecSubTypeVeNCrypt02X509None = SecuritySubType(260) - SecSubTypeVeNCrypt02X509VNC = SecuritySubType(261) - SecSubTypeVeNCrypt02X509Plain = SecuritySubType(262) + SecSubTypeVeNCrypt02Unknown SecuritySubType = SecuritySubType(0) + SecSubTypeVeNCrypt02Plain SecuritySubType = SecuritySubType(256) + SecSubTypeVeNCrypt02TLSNone SecuritySubType = SecuritySubType(257) + SecSubTypeVeNCrypt02TLSVNC SecuritySubType = SecuritySubType(258) + SecSubTypeVeNCrypt02TLSPlain SecuritySubType = SecuritySubType(259) + SecSubTypeVeNCrypt02X509None SecuritySubType = SecuritySubType(260) + SecSubTypeVeNCrypt02X509VNC SecuritySubType = SecuritySubType(261) + SecSubTypeVeNCrypt02X509Plain SecuritySubType = SecuritySubType(262) ) type SecurityHandler interface { diff --git a/security_vnc.go b/security_vnc.go index 10e4745..ed0cc60 100644 --- a/security_vnc.go +++ b/security_vnc.go @@ -73,18 +73,19 @@ func (auth *ClientAuthVNC) Auth(c Conn) error { if len(auth.Password) == 0 { return fmt.Errorf("Security Handshake failed; no password provided for VNCAuth.") } + var challenge [16]byte if err := binary.Read(c, binary.BigEndian, &challenge); err != nil { return err } - crypted, err := AuthVNCEncode(auth.Password, challenge[:]) + encrypted, err := AuthVNCEncode(auth.Password, challenge[:]) if err != nil { return err } - + fmt.Printf("rrrr\n") // Send the encrypted challenge back to server - if err := binary.Write(c, binary.BigEndian, crypted); err != nil { + if err := binary.Write(c, binary.BigEndian, encrypted); err != nil { return err } @@ -92,9 +93,6 @@ func (auth *ClientAuthVNC) Auth(c Conn) error { } func AuthVNCEncode(password []byte, challenge []byte) ([]byte, error) { - if len(password) > 8 { - return nil, fmt.Errorf("password too long") - } if len(challenge) != 16 { return nil, fmt.Errorf("challenge size not 16 byte long") } diff --git a/securitysubtype_string.go b/securitysubtype_string.go new file mode 100644 index 0000000..2c9c35b --- /dev/null +++ b/securitysubtype_string.go @@ -0,0 +1,32 @@ +// Code generated by "stringer -type=SecuritySubType"; DO NOT EDIT. + +package vnc + +import "fmt" + +const ( + _SecuritySubType_name_0 = "SecSubTypeUnknown" + _SecuritySubType_name_1 = "SecSubTypeVeNCrypt01PlainSecSubTypeVeNCrypt01TLSNoneSecSubTypeVeNCrypt01TLSVNCSecSubTypeVeNCrypt01TLSPlainSecSubTypeVeNCrypt01X509NoneSecSubTypeVeNCrypt01X509VNCSecSubTypeVeNCrypt01X509Plain" + _SecuritySubType_name_2 = "SecSubTypeVeNCrypt02PlainSecSubTypeVeNCrypt02TLSNoneSecSubTypeVeNCrypt02TLSVNCSecSubTypeVeNCrypt02TLSPlainSecSubTypeVeNCrypt02X509NoneSecSubTypeVeNCrypt02X509VNCSecSubTypeVeNCrypt02X509Plain" +) + +var ( + _SecuritySubType_index_0 = [...]uint8{0, 17} + _SecuritySubType_index_1 = [...]uint8{0, 25, 52, 78, 106, 134, 161, 190} + _SecuritySubType_index_2 = [...]uint8{0, 25, 52, 78, 106, 134, 161, 190} +) + +func (i SecuritySubType) String() string { + switch { + case i == 0: + return _SecuritySubType_name_0 + case 19 <= i && i <= 25: + i -= 19 + return _SecuritySubType_name_1[_SecuritySubType_index_1[i]:_SecuritySubType_index_1[i+1]] + case 256 <= i && i <= 262: + i -= 256 + return _SecuritySubType_name_2[_SecuritySubType_index_2[i]:_SecuritySubType_index_2[i+1]] + default: + return fmt.Sprintf("SecuritySubType(%d)", i) + } +} diff --git a/securitytype_string.go b/securitytype_string.go new file mode 100644 index 0000000..48795b3 --- /dev/null +++ b/securitytype_string.go @@ -0,0 +1,30 @@ +// Code generated by "stringer -type=SecurityType"; DO NOT EDIT. + +package vnc + +import "fmt" + +const ( + _SecurityType_name_0 = "SecTypeUnknownSecTypeNoneSecTypeVNC" + _SecurityType_name_1 = "SecTypeTight" + _SecurityType_name_2 = "SecTypeVeNCrypt" +) + +var ( + _SecurityType_index_0 = [...]uint8{0, 14, 25, 35} + _SecurityType_index_1 = [...]uint8{0, 12} + _SecurityType_index_2 = [...]uint8{0, 15} +) + +func (i SecurityType) String() string { + switch { + case 0 <= i && i <= 2: + return _SecurityType_name_0[_SecurityType_index_0[i]:_SecurityType_index_0[i+1]] + case i == 16: + return _SecurityType_name_1 + case i == 19: + return _SecurityType_name_2 + default: + return fmt.Sprintf("SecurityType(%d)", i) + } +}