func (auth *ServerAuthVNC) Auth(c common.Conn) error {
   buf := make([]byte, 8+len([]byte(AUTH_FAIL)))
   rand.Read(buf[:16]) // Random 16 bytes in buf
   sndsz, err := c.Write(buf[:16])
   if err != nil {
      log.Printf("Error sending challenge to client: %s\n", err.Error())
      return errors.New("Error sending challenge to client:" + err.Error())
   }
   if sndsz != 16 {
      log.Printf("The full 16 byte challenge was not sent!\n")
      return errors.New("The full 16 byte challenge was not sent")
   }
   c.Flush()
   buf2 := make([]byte, 16)
   _, err = c.Read(buf2)
   if err != nil {
      log.Printf("The authentication result was not read: %s\n", err.Error())
      return errors.New("The authentication result was not read" + err.Error())
   }
   AuthText := "asdasedfv213sedf"
   bk, err := des.NewCipher([]byte(fixDesKey(AuthText)))
   if err != nil {
      log.Printf("Error generating authentication cipher: %s\n", err.Error())
      return errors.New("Error generating authentication cipher")
   }
   buf3 := make([]byte, 16)
   bk.Encrypt(buf3, buf)               //Encrypt first 8 bytes
   bk.Encrypt(buf3[8:], buf[8:])       // Encrypt second 8 bytes
   if bytes.Compare(buf2, buf3) != 0 { // If the result does not decrypt 
correctly to what we sent then a problem
      SetUint32(buf, 0, 1)
      SetUint32(buf, 4, uint32(len([]byte(AUTH_FAIL))))
      copy(buf[8:], []byte(AUTH_FAIL))
      c.Write(buf)
      c.Flush()
      return errors.New("Authentication failed")
   }
   return nil
}


On Monday, August 5, 2013 at 3:57:01 PM UTC+3, Vasiliy Tolstov wrote:
>
> Hello. 
> I'm need to implement RFB proxy providing single auth point and proxy 
> to needed host based on user/password. 
> As i see many VNC clients have user and passowrd input, but i can't 
> find RFB proto spec that contains login fileds... 
>
> Second question - i can find Brad rfb golang package that contains 
> needed thing (VNC auth easy implement) But i can't fully understand - 
> how can i determine destination point to proxy after auth? 
>
> As i see i need generate 16 bit challenge and send to cleint, client 
> doing des on this challenge using password as key (truncated to 8 
> characters). 
> On server side i can doing des on my challenge and stored user 
> password create corresponding pair to check. 
>
> But this is mean that i need store challenge for each password or use 
> single challenge for all passwords to able to find in db destionation 
> point for proxy. 
>
> Is that possible to do that i need in another way? 
> Thanks 
>
> -- 
> Vasiliy Tolstov, 
> e-mail: v.to...@selfip.ru <javascript:> 
> jabber: va...@selfip.ru <javascript:> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to