public void Decrypt(byte[] armorKey) { ArmorKey = armorKey; var decrypted = KerberosUtility.Decrypt( (Cryptographic.EncryptionType)EncFastRep.etype.Value, armorKey, EncFastRep.cipher.ByteArrayValue, (int)KeyUsageNumber.FAST_ENC); KrbFastResponse krbFastRep = new KrbFastResponse(); krbFastRep.BerDecode(new Asn1DecodingBuffer(decrypted)); FastRep = new KerberosFastResponse(krbFastRep); }
private void UpdateContext(KerberosAsResponse response) { KerberosFastResponse kerbFastRep = null; if (response.Response.padata != null && response.Response.padata.Elements != null) { foreach (PA_DATA paData in response.Response.padata.Elements) { var parsedPaData = PaDataParser.ParseRepPaData(paData); if (parsedPaData is PaETypeInfo2) { Asn1DecodingBuffer buffer = new Asn1DecodingBuffer(paData.padata_value.ByteArrayValue); ETYPE_INFO2 eTypeInfo2 = new ETYPE_INFO2(); eTypeInfo2.BerDecode(buffer); if (eTypeInfo2.Elements != null && eTypeInfo2.Elements.Length > 0) { // the salt is received from KDC if (eTypeInfo2.Elements[0].salt != null) { Context.CName.Salt = eTypeInfo2.Elements[0].salt.Value; } continue; } } if (parsedPaData is PaFxFastRep) { var armoredRep = ((PaFxFastRep)parsedPaData).GetArmoredRep(); kerbFastRep = ((PaFxFastRep)parsedPaData).GetKerberosFastRep(Context.FastArmorkey); var strKey = kerbFastRep.FastResponse.strengthen_key; Context.ReplyKey = KerberosUtility.KrbFxCf2( strKey, //Fix me: should be Context.ReplyKey KerberosUtility.MakeKey(Context.SelectedEType, Context.CName.Password, Context.CName.Salt), "strengthenkey", "replykey"); } } } if (Context.ReplyKey != null) { response.Decrypt(Context.ReplyKey.keyvalue.ByteArrayValue); } else { var encryptType = (EncryptionType)response.Response.enc_part.etype.Value; var key = KeyGenerator.MakeKey(encryptType, Context.CName.Password, Context.CName.Salt); Context.ReplyKey = new EncryptionKey(new KerbInt32((long)encryptType), new Asn1OctetString(key)); response.Decrypt(key); } if (response.EncPart != null) { Context.SessionKey = response.EncPart.key; } if (response.Response != null) { //Response.Response.cname is not the real CName of the ticket when hide-client-names=1 if (kerbFastRep != null && kerbFastRep.FastResponse != null && kerbFastRep.FastResponse.finished != null) { // Windows DC is case insensitive. It may change the cname in the response, e.g. administrator -> Administrator Context.CName.Name = kerbFastRep.FastResponse.finished.cname; Context.Ticket = new KerberosTicket(response.Response.ticket, kerbFastRep.FastResponse.finished.cname, response.EncPart.key); } else { // Windows DC is case insensitive. It may change the cname in the response, e.g. administrator -> Administrator Context.CName.Name = response.Response.cname; Context.Ticket = new KerberosTicket(response.Response.ticket, response.Response.cname, response.EncPart.key); } Context.SelectedEType = (EncryptionType)Context.Ticket.SessionKey.keytype.Value; if (Context.Ticket != null && Context.Ticket.Ticket.sname != null && Context.Ticket.Ticket.sname.name_string != null && Context.Ticket.Ticket.sname.name_string.Elements != null && Context.Ticket.Ticket.sname.name_string.Elements.Length > 1) { int count = Context.Ticket.Ticket.sname.name_string.Elements.Length; Context.Realm = new Realm(Context.Ticket.Ticket.sname.name_string.Elements[count - 1].Value); } } }
public void Decrypt(byte[] armorKey) { ArmorKey = armorKey; var decrypted = KerberosUtility.Decrypt( (Cryptographic.EncryptionType)EncFastRep.etype.Value, armorKey, EncFastRep.cipher.ByteArrayValue, (int)KeyUsageNumber.FAST_ENC); KrbFastResponse krbFastRep = new KrbFastResponse(); krbFastRep.BerDecode(new Asn1DecodingBuffer(decrypted)); FastRep = new KerberosFastResponse(krbFastRep); }
public KerberosArmoredResponse(byte[] armorKey, long eType, KerberosFastResponse fastRep) { ArmorKey = armorKey; EType = eType; FastRep = fastRep; }
public KerberosArmoredResponse(byte[] armorKey, long eType, KerberosFastResponse fastRep) { ArmorKey = armorKey; EType = eType; FastRep = fastRep; }