Пример #1
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
        }
Пример #2
0
        public KRB_AS_REP AS(KRB_AS_REQ req)
        {
            // Invent key SA
            Key sa = new Key(7);

            sa.CreateRandomKey();

            // Finds User's master key Ka
            Key ka = GetUserKey(req.User);

            // TGT = K_KDC[User, SA]
            Tgt tgt = new Tgt(this.k_kdc, req.User, sa);

            // Return KA(SA, TGT)
            KRB_AS_REP krb_as_rep = new KRB_AS_REP(ka, sa, tgt);

            return(krb_as_rep);
        }