/// <summary> /// Construct a JWE encryption object and encrypt the specified data /// using the specified encryption provider. /// </summary> /// <param name="Encryptor">Encryption provider to use.</param> /// <param name="Data">The data to be encrypted.</param> public JoseWebEncryption(byte[] Data, CryptoProviderEncryption Encryptor) { Encrypt(Data, Encryptor); }
/// <summary> /// Create a new encryption context and encrypt the data under the /// generated content key and IV. /// </summary> /// <param name="Data">The data to encrypt</param> /// <param name="Encryptor">The encryption provider to use.</param> public void Encrypt(byte[] Data, CryptoProviderEncryption Encryptor) { //Trace.WriteHex("Encryption Key", Encryptor.Key); CryptoData = Encryptor.Encrypt(Data); var Preheader = new Header(Encryptor); Protected = Preheader.GetBytes(false); // get the data bytes untagged IV = CryptoData.IV; JTag = CryptoData.Integrity; CipherText = CryptoData.Data; }
/// <summary> /// Initialize the alg parameter to match the specified provider. /// </summary> /// <param name="Provider"></param> public Header(CryptoProviderEncryption Provider) { alg = Provider.JSONName; }