Пример #1
0
        public KRB_TGS_REP TGS(KRB_TGS_REQ req)
        {
            // Invent key K_AB
            Key k_ab = new Key(7);
            k_ab.CreateRandomKey();

            // Decrypt TGT to get SA
            Key sa = req.Tgt.GetKS_A(this.k_kdc);

            // Decrypt authenticator
            DateTime timestamp = req.Authenticator.GetTimestamp(sa);

            // Verifies timestamp
            DateTime now = DateTime.Now;
            int diffTimestamp = now.Second - timestamp.Second;
            if (diffTimestamp > this.maxTimestamp)
            {
                // Fail in the timestamp
                return null;
            }

            // Finds Bob's master key KB
            Key k_b = GetUserKey(req.ReqUser);

            // Ticket to Bob = K_B[Alice, K_AB]
            Ticket ticket = new Ticket(k_b, req.Tgt.GetUser(this.k_kdc), k_ab);

            return new KRB_TGS_REP(sa, req.ReqUser, k_ab, ticket);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            // I have to check the args
            string userName = args[0];
            string userRemo = args[1];

            Key aliceKey = new Key("ABCDEFGH");

            #region Throw our server

            string confFile = Application.ExecutablePath + "." + userName.ToLower() + ".config";
            Console.WriteLine(confFile);
            RemotingConfiguration.Configure(confFile , false);

            #endregion

            #region Connection with server

            System.Configuration.AppSettingsReader configurationAppSettings =
                new System.Configuration.AppSettingsReader();
            //String url = (string)ConfigurationSettings.AppSettings["RemotingUrl"];
            String url =
            IKdc kdc = (IKdc)Activator.GetObject(typeof(ShareClasses.IKdc), url);

            #endregion

            #region AS_REQ

            User alice = new User(userName);
            KRB_AS_REQ asReq = new KRB_AS_REQ(alice);
            KRB_AS_REP asRep = kdc.AS(asReq);

            #endregion

            #region TGS_REQ

            User bob = new User(userRemo);
            Authenticator auth = new Authenticator(aliceKey);
            KRB_TGS_REQ tgsReq = new KRB_TGS_REQ(asRep.GetTGT(aliceKey), auth, bob);
            KRB_TGS_REP tgsRep = kdc.TGS(tgsReq);

            #endregion

            #region AP_REQ

            Ticket ticket = tgsRep.GetTicket(aliceKey);
            string bobUrl = (string)ConfigurationSettings.AppSettings["RemotingUser"];
            Server bobServer = (Server)Activator.GetObject(typeof(Workstation.Server), bobUrl);
            KRB_AP_REQ apReq = new KRB_AP_REQ(ticket, auth);
            KRB_AP_REP apRep = bobServer.AP(apReq);

            #endregion
        }