private Jwk TryWrapKey_Success(SymmetricJwk keyToWrap, EncryptionAlgorithm enc, KeyManagementAlgorithm alg) { var keyEncryptionKey = SymmetricJwk.GenerateKey(alg.RequiredKeySizeInBits); var wrapper = new DirectKeyWrapper(keyEncryptionKey, enc, alg); var cek = WrapKey(wrapper, keyToWrap, out var header); Assert.Equal(0, header.Count); Assert.True(keyEncryptionKey.K.SequenceEqual(((SymmetricJwk)cek).K)); return(cek); }
public void Wrap() { var staticKey = new byte[] { 111, 27, 25, 52, 66, 29, 20, 78, 92, 176, 56, 240, 65, 208, 82, 112, 161, 131, 36, 55, 202, 236, 185, 172, 129, 23, 153, 194, 195, 48, 253, 182 }; var kwp = new DirectKeyWrapper(SymmetricJwk.FromByteArray(staticKey), EncryptionAlgorithm.A128CbcHS256, KeyManagementAlgorithm.Dir); var header = new JwtHeader(); var destination = new byte[kwp.GetKeyWrapSize()]; var cek = kwp.WrapKey(null, header, destination); Assert.Equal(staticKey, cek.K.ToArray()); }