Exemple #1
0
        public byte[] WrapKey(byte[] cek, object key, IDictionary <string, object> header)
        {
            byte[] sharedKey = byteKey(key);

            Ensure.BitSize(sharedKey, kekLengthBits, string.Format("AesKeyWrap management algorithm expected key of size {0} bits, but was given {1} bits", kekLengthBits, sharedKey.Length * 8L));

            return(AesKeyWrap.Wrap(cek, sharedKey));
        }
 public byte[][] WrapNewKey(int cekSizeBits, object key, IDictionary <string, object> header)
 {
     byte[] numArray = Ensure.Type <byte[]>(key, "AesKeyWrap management algorithm expectes key to be byte[] array.", new object[0]);
     Ensure.BitSize(numArray, this.kekLengthBits, string.Format("AesKeyWrap management algorithm expected key of size {0} bits, but was given {1} bits", this.kekLengthBits, (int)numArray.Length * 8), new object[0]);
     byte[] numArray1 = Arrays.Random(cekSizeBits);
     byte[] numArray2 = AesKeyWrap.Wrap(numArray1, numArray);
     return(new byte[][] { numArray1, numArray2 });
 }
        public byte[] WrapKey(byte[] cek, object key, IDictionary <string, object> header)
        {
            var sharedKey = Ensure.Type <byte[]>(key, "AesKeyWrap management algorithm expectes key to be byte[] array.");

            Ensure.BitSize(sharedKey, kekLengthBits, string.Format("AesKeyWrap management algorithm expected key of size {0} bits, but was given {1} bits", kekLengthBits, sharedKey.Length * 8L));

            var encryptedCek = AesKeyWrap.Wrap(cek, sharedKey);

            return(encryptedCek);
        }
Exemple #4
0
        public byte[][] WrapNewKey(int cekSizeBits, object key, IDictionary <string, object> header)
        {
            var sharedKey = Ensure.Type <byte[]>(key, "AesKeyWrap management algorithm expectes key to be byte[] array.");

            Ensure.BitSize(sharedKey, kekLengthBits, string.Format("AesKeyWrap management algorithm expected key of size {0} bits, but was given {1} bits", kekLengthBits, sharedKey.Length * 8));

            var cek          = Arrays.Random(cekSizeBits);
            var encryptedCek = AesKeyWrap.Wrap(cek, sharedKey);

            return(new[] { cek, encryptedCek });
        }