Example #1
0
        //Ticket::= [APPLICATION 1] SEQUENCE {
        //        tkt-vno[0] INTEGER(5),
        //        realm[1] Realm,
        //        sname[2] PrincipalName,
        //        enc-part[3] EncryptedData -- EncTicketPart
        //}

        public Ticket(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstItem = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    tkt_vno = Convert.ToInt32(firstItem.GetInteger());
                    break;

                case 1:
                    realm = Encoding.ASCII.GetString(firstItem.GetOctetString());
                    break;

                case 2:
                    sname = new PrincipalName(firstItem);
                    break;

                case 3:
                    enc_part = new EncryptedData(firstItem);
                    break;

                default:
                    break;
                }
            }
        }
Example #2
0
        public void Decode(AsnElt body)
        {
            Tickets = new List <Ticket>();
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    pvno = Convert.ToInt32(firstElement.GetInteger());
                    break;

                case 1:
                    MessageType = Convert.ToInt32(firstElement.GetInteger());
                    break;

                case 2:
                    foreach (AsnElt ae in firstElement.FirstElement.EnumerateElements())
                    {
                        Tickets.Add(new Ticket(ae));
                    }
                    break;

                case 3:
                    EncryptedPart = new EncKrbCredPart(firstElement);
                    break;

                default:
                    break;
                }
            }
        }
Example #3
0
        public KRB_ERROR(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    pvno = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 1:
                    msg_type = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 2:
                    ctime = firstElement.GetTime();
                    break;

                case 3:
                    cusec = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 4:
                    stime = firstElement.GetTime();
                    break;

                case 5:
                    susec = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 6:
                    ErrorCode = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 7:
                    crealm = Encoding.ASCII.GetString(firstElement.GetOctetString());
                    break;

                case 8:
                    cname = new PrincipalName(firstElement);
                    break;

                case 9:
                    realm = Encoding.ASCII.GetString(firstElement.GetOctetString());
                    break;

                case 10:
                    sname = new PrincipalName(firstElement);
                    break;

                default:
                    break;
                }
            }
        }
Example #4
0
        public KrbCredInfo(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    key = new EncryptionKey(s);
                    break;

                case 1:
                    prealm = Encoding.ASCII.GetString(firstElement.GetOctetString());
                    break;

                case 2:
                    pname = new PrincipalName(firstElement);
                    break;

                case 3:
                    UInt32 temp      = Convert.ToUInt32(firstElement.GetInteger());
                    byte[] tempBytes = BitConverter.GetBytes(temp);
                    flags = (Interop.TicketFlags)BitConverter.ToInt32(tempBytes, 0);
                    break;

                case 4:
                    authtime = firstElement.GetTime();
                    break;

                case 5:
                    starttime = firstElement.GetTime();
                    break;

                case 6:
                    endtime = firstElement.GetTime();
                    break;

                case 7:
                    renew_till = firstElement.GetTime();
                    break;

                case 8:
                    srealm = Encoding.ASCII.GetString(firstElement.GetOctetString());
                    break;

                case 9:
                    sname = new PrincipalName(firstElement);
                    break;

                default:
                    break;
                }
            }
        }
Example #5
0
        public AS_REQ(byte[] data)
        {
            // decode the supplied bytes to an AsnElt object
            data = AsnIO.FindBER(data);
            AsnElt asn_AS_REQ = AsnElt.Decode(data);

            padata = new List <PA_DATA>();

            // AS-REQ::= [APPLICATION 10] KDC-REQ
            //  tag class == 1
            //  tag class == 10
            //  SEQUENCE
            if (asn_AS_REQ.TagValue != 10)
            {
                throw new System.Exception("AS-REQ tag value should be 10");
            }
            if ((asn_AS_REQ.Count != 1) || (asn_AS_REQ.FirstElement.TagValue != 16))
            {
                throw new System.Exception("First AS-REQ sub should be a sequence");
            }

            // extract the KDC-REP out
            foreach (AsnElt s in asn_AS_REQ.FirstElement.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 1:
                    pvno = firstElement.GetInteger();
                    break;

                case 2:
                    msg_type = firstElement.GetInteger();
                    break;

                case 3:
                    // sequence of pa-data
                    foreach (AsnElt pa in firstElement.EnumerateElements())
                    {
                        padata.Add(new PA_DATA(pa));
                    }
                    break;

                case 4:
                    // KDC-REQ-BODY
                    req_body = new KDCReqBody(firstElement);
                    break;

                default:
                    throw new System.Exception(String.Format("Invalid tag AS-REQ value : {0}", s.TagValue));
                }
            }
        }
Example #6
0
        public Checksum(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    cksumtype = Convert.ToInt32(firstElement.GetInteger());
                    break;

                case 2:
                    checksum = firstElement.GetOctetString();
                    break;

                default:
                    break;
                }
            }
        }
Example #7
0
        public EncryptedData(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    etype = Convert.ToInt32(firstElement.GetInteger());
                    break;

                case 1:
                    kvno = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 2:
                    cipher = firstElement.GetOctetString();
                    break;

                default:
                    break;
                }
            }
        }
Example #8
0
        //EncKDCRepPart::= SEQUENCE {
        //        key[0] EncryptionKey,
        //        last-req[1] LastReq,
        //        nonce[2] UInt32,
        //        key-expiration[3] KerberosTime OPTIONAL,
        //        flags[4] TicketFlags,
        //        authtime[5] KerberosTime,
        //        starttime[6] KerberosTime OPTIONAL,
        //        endtime[7] KerberosTime,
        //        renew-till[8] KerberosTime OPTIONAL,
        //        srealm[9] Realm,
        //        sname[10] PrincipalName,
        //        caddr[11] HostAddresses OPTIONAL,
        //  encrypted-pa-data[12] SEQUENCE OF PA-DATA OPTIONAL
        //}

        public EncKDCRepPart(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    key = new EncryptionKey(s);
                    break;

                case 1:
                    lastReq = new LastReq(firstElement);
                    break;

                case 2:
                    nonce = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 3:
                    key_expiration = firstElement.GetTime();
                    break;

                case 4:
                    UInt32 temp      = Convert.ToUInt32(firstElement.GetInteger());
                    byte[] tempBytes = BitConverter.GetBytes(temp);
                    flags = (Interop.TicketFlags)BitConverter.ToInt32(tempBytes, 0);
                    break;

                case 5:
                    authtime = firstElement.GetTime();
                    break;

                case 6:
                    starttime = firstElement.GetTime();
                    break;

                case 7:
                    endtime = firstElement.GetTime();
                    break;

                case 8:
                    renew_till = firstElement.GetTime();
                    break;

                case 9:
                    realm = Encoding.ASCII.GetString(firstElement.GetOctetString());
                    break;

                case 10:
                    // sname (optional)
                    sname = new PrincipalName(firstElement);
                    break;

                case 11:
                    // HostAddresses, skipped for now
                    break;

                case 12:
                    // encrypted-pa-data, skipped for now
                    break;

                default:
                    break;
                }
            }
        }
Example #9
0
        public KDCReqBody(AsnElt body)
        {
            foreach (AsnElt s in body.EnumerateElements())
            {
                AsnElt firstElement = s.FirstElement;
                switch (s.TagValue)
                {
                case 0:
                    UInt32 temp      = Convert.ToUInt32(firstElement.GetInteger());
                    byte[] tempBytes = BitConverter.GetBytes(temp);
                    kdcOptions = (Interop.KdcOptions)BitConverter.ToInt32(tempBytes, 0);
                    break;

                case 1:
                    // optional
                    cname = new PrincipalName(firstElement);
                    break;

                case 2:
                    realm = Encoding.ASCII.GetString(firstElement.GetOctetString());
                    break;

                case 3:
                    // optional
                    sname = new PrincipalName(firstElement);
                    break;

                case 4:
                    // optional
                    from = firstElement.GetTime();
                    break;

                case 5:
                    till = firstElement.GetTime();
                    break;

                case 6:
                    // optional
                    rtime = firstElement.GetTime();
                    break;

                case 7:
                    nonce = Convert.ToUInt32(firstElement.GetInteger());
                    break;

                case 8:
                    //etypes = new Enums.KERB_ETYPE[s.Sub[0].Sub.Length];
                    etypes = new List <Interop.KERB_ETYPE>();
                    foreach (AsnElt item in firstElement.EnumerateElements())
                    {
                        //etypes[i] = (Enums.KERB_ETYPE)Convert.ToUInt32(item.GetInteger());
                        etypes.Add((Interop.KERB_ETYPE)Convert.ToUInt32(item.GetInteger()));
                    }
                    break;

                case 9:
                    // addresses (optional)
                    break;

                case 10:
                    // enc authorization-data (optional)
                    break;

                case 11:
                    // additional-tickets (optional)
                    break;

                default:
                    break;
                }
            }
        }