public void TestEncryption() { var aes128KeyWrap = new Aes128KeyWrap(); byte[] cek = { (byte) 4, (byte) 211, (byte) 31, (byte) 197, (byte) 84, (byte) 157, (byte) 252, (byte) 254, (byte) 11, (byte) 100, (byte) 157, (byte) 250, (byte) 63, (byte) 170, (byte) 106, (byte) 206, (byte) 107, (byte) 124, (byte) 212, (byte) 45, (byte) 111, (byte) 107, (byte) 9, (byte) 219, (byte) 200, (byte) 177, (byte) 0, (byte) 240, (byte) 143, (byte) 156, (byte) 44, (byte) 207 }; byte[] key = Base64.base64urldecode("GawgguFyGrWKav7AX4VKUg"); ContentEncryptKeyGenerator cekGenerator = new ContentEncryptKeyGenerator(32); cekGenerator.UserEncryptionKey = cek; JwaAlgResult jwaAlgResult = aes128KeyWrap.Encryption(key, cekGenerator); byte[] b = jwaAlgResult.encryptedCek; Assert.AreEqual("6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ", Base64.base64urlencode(b)); }
public void TestEncryption() { var aes256KeyWrap = new Aes256KeyWrap(); byte[] cek = { (byte) 4, (byte) 211, (byte) 31, (byte) 197, (byte) 84, (byte) 157, (byte) 252, (byte) 254, (byte) 11, (byte) 100, (byte) 157, (byte) 250, (byte) 63, (byte) 170, (byte) 106, (byte) 206, (byte) 107, (byte) 124, (byte) 212, (byte) 45, (byte) 111, (byte) 107, (byte) 9, (byte) 219, (byte) 200, (byte) 177, (byte) 0, (byte) 240, (byte) 143, (byte) 156, (byte) 44, (byte) 207 }; byte[] key = StringUtils.StringToByte("12345678901234567890123456789012"); ContentEncryptKeyGenerator cekGenerator = new ContentEncryptKeyGenerator(32); cekGenerator.UserEncryptionKey = cek; JwaAlgResult jwaAlgResult = aes256KeyWrap.Encryption(key, cekGenerator); byte[] b = jwaAlgResult.encryptedCek; Assert.AreEqual("UVf1x6nVsOmpxjlUFSiQdzbsOMYuAh3FQlH0nY3yhDWVJFh9HLtHIQ", Base64.base64urlencode(b)); }
public abstract JwaAlgResult Encryption(byte[] key, ContentEncryptKeyGenerator cekGenerator);
public override JwaAlgResult Encryption(byte[] key, ContentEncryptKeyGenerator cekGenerator) { IsValidKeyLength(key); byte[] src = cekGenerator.GenerateRandomKey(); return Wrap(key, src); }