public PaEncTimeStamp(string timeStamp, int usec, EncryptionType eType, string password, string salt) { this.TimeStamp = timeStamp; this.Usec = usec; byte[] key = KeyGenerator.MakeKey(eType, password, salt); this.Key = new EncryptionKey(new KerbInt32((long)eType), new Asn1OctetString(key)); // create a timestamp PA_ENC_TS_ENC paEncTsEnc = new PA_ENC_TS_ENC(new KerberosTime(this.TimeStamp), new Microseconds(this.Usec)); Asn1BerEncodingBuffer currTimeStampBuffer = new Asn1BerEncodingBuffer(); paEncTsEnc.BerEncode(currTimeStampBuffer); var rawData = currTimeStampBuffer.Data; KerberosUtility.OnDumpMessage("KRB5:PA-ENC-TS-ENC", "Encrypted Timestamp Pre-authentication", KerberosUtility.DumpLevel.PartialMessage, rawData); // encrypt the timestamp byte[] encTimeStamp = KerberosUtility.Encrypt((EncryptionType)this.Key.keytype.Value, this.Key.keyvalue.ByteArrayValue, rawData, (int)KeyUsageNumber.PA_ENC_TIMESTAMP); // create an encrypted timestamp PA_ENC_TIMESTAMP paEncTimeStamp = new PA_ENC_TIMESTAMP(new KerbInt32(this.Key.keytype.Value), null, new Asn1OctetString(encTimeStamp)); Asn1BerEncodingBuffer paEncTimestampBuffer = new Asn1BerEncodingBuffer(); paEncTimeStamp.BerEncode(paEncTimestampBuffer, true); Data = new PA_DATA(new KerbInt32((long)PaDataType.PA_ENC_TIMESTAMP), new Asn1OctetString(paEncTimestampBuffer.Data)); }
public PaEncryptedChallenge(EncryptionType type, string timeStamp, int usec, EncryptionKey armorKey, EncryptionKey userLongTermKey) { this.TimeStamp = timeStamp; this.Usec = usec; var keyvalue = KeyGenerator.KrbFxCf2( (EncryptionType)armorKey.keytype.Value, armorKey.keyvalue.ByteArrayValue, userLongTermKey.keyvalue.ByteArrayValue, "clientchallengearmor", "challengelongterm"); switch (type) { case EncryptionType.AES256_CTS_HMAC_SHA1_96: { var key = new EncryptionKey(new KerbInt32((long)EncryptionType.AES256_CTS_HMAC_SHA1_96), new Asn1OctetString(keyvalue)); this.Key = key; break; } case EncryptionType.RC4_HMAC: { var key = new EncryptionKey(new KerbInt32((long)EncryptionType.RC4_HMAC), new Asn1OctetString(keyvalue)); this.Key = key; break; } default: throw new ArgumentException("Unsupported encryption type."); } // create a timestamp PA_ENC_TS_ENC paEncTsEnc = new PA_ENC_TS_ENC(new KerberosTime(this.TimeStamp), new Microseconds(this.Usec)); Asn1BerEncodingBuffer currTimeStampBuffer = new Asn1BerEncodingBuffer(); paEncTsEnc.BerEncode(currTimeStampBuffer); var rawData = currTimeStampBuffer.Data; KerberosUtility.OnDumpMessage("KRB5:PA-ENC-TS-ENC", "Encrypted Timestamp Pre-authentication", KerberosUtility.DumpLevel.PartialMessage, rawData); // encrypt the timestamp byte[] encTimeStamp = KerberosUtility.Encrypt((EncryptionType)this.Key.keytype.Value, this.Key.keyvalue.ByteArrayValue, rawData, (int)KeyUsageNumber.ENC_CHALLENGE_CLIENT); EncryptedChallenge encryptedChallenge = new EncryptedChallenge(new KerbInt32((long)this.Key.keytype.Value), null, new Asn1OctetString(encTimeStamp)); Asn1BerEncodingBuffer paEncTimestampBuffer = new Asn1BerEncodingBuffer(); encryptedChallenge.BerEncode(paEncTimestampBuffer, true); Data = new PA_DATA(new KerbInt32((long)PaDataType.PA_ENCRYPTED_CHALLENGE), new Asn1OctetString(paEncTimestampBuffer.Data)); }
public PaEncryptedChallenge(EncryptionType type, string timeStamp, int usec, EncryptionKey armorKey, EncryptionKey userLongTermKey) { this.TimeStamp = timeStamp; this.Usec = usec; var keyvalue = KeyGenerator.KrbFxCf2( (EncryptionType)armorKey.keytype.Value, armorKey.keyvalue.ByteArrayValue, userLongTermKey.keyvalue.ByteArrayValue, "clientchallengearmor", "challengelongterm"); switch (type) { case EncryptionType.AES256_CTS_HMAC_SHA1_96: { var key = new EncryptionKey(new KerbInt32((long)EncryptionType.AES256_CTS_HMAC_SHA1_96), new Asn1OctetString(keyvalue)); this.Key = key; break; } case EncryptionType.RC4_HMAC: { var key = new EncryptionKey(new KerbInt32((long)EncryptionType.RC4_HMAC), new Asn1OctetString(keyvalue)); this.Key = key; break; } default: throw new ArgumentException("Unsupported encryption type."); } // create a timestamp PA_ENC_TS_ENC paEncTsEnc = new PA_ENC_TS_ENC(new KerberosTime(this.TimeStamp), new Microseconds(this.Usec)); Asn1BerEncodingBuffer currTimeStampBuffer = new Asn1BerEncodingBuffer(); paEncTsEnc.BerEncode(currTimeStampBuffer); var rawData = currTimeStampBuffer.Data; KerberosUtility.OnDumpMessage("KRB5:PA-ENC-TS-ENC", "Encrypted Timestamp Pre-authentication", KerberosUtility.DumpLevel.PartialMessage, rawData); // encrypt the timestamp byte[] encTimeStamp = KerberosUtility.Encrypt((EncryptionType)this.Key.keytype.Value, this.Key.keyvalue.ByteArrayValue, rawData, (int)KeyUsageNumber.ENC_CHALLENGE_CLIENT); EncryptedChallenge encryptedChallenge = new EncryptedChallenge(new KerbInt32((long)this.Key.keytype.Value), null, new Asn1OctetString(encTimeStamp)); Asn1BerEncodingBuffer paEncTimestampBuffer = new Asn1BerEncodingBuffer(); encryptedChallenge.BerEncode(paEncTimestampBuffer, true); Data = new PA_DATA(new KerbInt32((long)PaDataType.PA_ENCRYPTED_CHALLENGE), new Asn1OctetString(paEncTimestampBuffer.Data)); }
public PaEncTimeStamp(string timeStamp, int usec, EncryptionType eType, string password, string salt) { this.TimeStamp = timeStamp; this.Usec = usec; byte[] key = KeyGenerator.MakeKey(eType, password, salt); this.Key = new EncryptionKey(new KerbInt32((long)eType), new Asn1OctetString(key)); // create a timestamp PA_ENC_TS_ENC paEncTsEnc = new PA_ENC_TS_ENC(new KerberosTime(this.TimeStamp), new Microseconds(this.Usec)); Asn1BerEncodingBuffer currTimeStampBuffer = new Asn1BerEncodingBuffer(); paEncTsEnc.BerEncode(currTimeStampBuffer); var rawData = currTimeStampBuffer.Data; KerberosUtility.OnDumpMessage("KRB5:PA-ENC-TS-ENC", "Encrypted Timestamp Pre-authentication", KerberosUtility.DumpLevel.PartialMessage, rawData); // encrypt the timestamp byte[] encTimeStamp = KerberosUtility.Encrypt((EncryptionType)this.Key.keytype.Value, this.Key.keyvalue.ByteArrayValue, rawData, (int)KeyUsageNumber.PA_ENC_TIMESTAMP); // create an encrypted timestamp PA_ENC_TIMESTAMP paEncTimeStamp = new PA_ENC_TIMESTAMP(new KerbInt32(this.Key.keytype.Value), null, new Asn1OctetString(encTimeStamp)); Asn1BerEncodingBuffer paEncTimestampBuffer = new Asn1BerEncodingBuffer(); paEncTimeStamp.BerEncode(paEncTimestampBuffer, true); Data = new PA_DATA(new KerbInt32((long)PaDataType.PA_ENC_TIMESTAMP), new Asn1OctetString(paEncTimestampBuffer.Data)); }