/// <summary> /// Generate a new key, the key type and key length are based on the input key /// </summary> /// <param name="baseKey">Base key for generation</param> /// <returns></returns> public static EncryptionKey GenerateKey(EncryptionKey baseKey) { if (baseKey == null || baseKey.keytype == null || baseKey.keyvalue == null || baseKey.keyvalue.Value == null) { return(null); } byte[] keyBuffer = KerberosUtility.GenerateRandomBytes((uint)baseKey.keyvalue.ByteArrayValue.Length); EncryptionKey newKey = new EncryptionKey(new KerbInt32(baseKey.keytype.Value), new Asn1OctetString(keyBuffer)); return(newKey); }