Ejemplo n.º 1
0
        public FtpTicketResponse RequstSessionKeyForFtpConnection(FtpKeyRequst ftpKeyRequst)
        {
            if (!users_list.ContainsKey(ftpKeyRequst.UserName))
            {
                return(null);
            }

            // get users from the data base
            KdcFtpKey retKeyFromDB = m_FtpDBservice.getKdcFtpKey("KDC");

            // check validity
            if (retKeyFromDB == null)
            {
                Console.Write("no key exist in DB");
                return(null);
            }

            // genrate new session key for CLIENT - FTP
            byte[] sessiomKey = CAes.NewKey();

            FtpTicketResponse ftpTicketResponse = new FtpTicketResponse();

            ftpTicketResponse.SessionKeyClientFTPEncryptedForFTP    = CAes.SimpleEncryptWithPassword(sessiomKey, retKeyFromDB.PassWord);
            ftpTicketResponse.UserNameencryptedForFtpWithFtpKey     = CAes.SimpleEncryptWithPassword(ftpKeyRequst.UserName, retKeyFromDB.PassWord);
            ftpTicketResponse.SessionKeyClientFTPEncryptedForClient = CAes.SimpleEncrypt(sessiomKey, users_list[ftpKeyRequst.UserName].SessionKey, users_list[ftpKeyRequst.UserName].SessionKey);

            return(ftpTicketResponse);
        }
Ejemplo n.º 2
0
        // requst to connect to Ftp service
        private void getSessionKeyForFtpWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            clientPrivateData clientData = ClientAllData.Instance.getMyClient();

            //send requst for Auth
            FtpKeyRequst ftpKeyRequst = new FtpKeyRequst(clientData.username);

            FtpTicketResponse ftpTicketResponse = kdcProxy.RequstSessionKeyForFtpConnection(ftpKeyRequst); // blocking

            if (ftpTicketResponse == null)
            {
                return;
            }

            byte[] sessionKey = CAes.SimpleDecrypt(ftpTicketResponse.SessionKeyClientFTPEncryptedForClient, clientData.m_kdcAsSessionKey, clientData.m_kdcAsSessionKey);

            ClientAllData.Instance.getMyClient().m_ftpSessionKey = sessionKey;

            FtpTicketRequst ftpTicketRequst = new FtpTicketRequst();

            ftpTicketRequst.UserNameencryptedForFtpWithFtpKey  = ftpTicketResponse.UserNameencryptedForFtpWithFtpKey;
            ftpTicketRequst.SessionKeyClientFTPEncryptedForFTP = ftpTicketResponse.SessionKeyClientFTPEncryptedForFTP;

            ftpTicketRequst.UserNameencryptedForFtpWithSessionKey = CAes.SimpleEncrypt(clientData.username, sessionKey, sessionKey);
            ftpProxy.requstForConnectionWithSessionKey(ftpTicketRequst); // non blocking

            //TODO: should set timer for time out
        }