예제 #1
0
        public byte[] Decrypt(EncryptionResult encrypted)
        {
            var key         = _keyring.GetOrThrow(encrypted.Kid);
            var cipherBytes = Convert.FromBase64String(encrypted.Ciphertext);
            var plainBytes  = _cipher.Decrypt(key.Bytes, cipherBytes, encrypted.Iv);

            return(plainBytes);
        }
        public EncryptionResult Encrypt(byte[] plaintext)
        {
            var key = _keyring.GetOrThrow(_signingKeyName);

            return(new EncryptionResult
            {
                Alg = _cipher.Algorithm,
                Ciphertext = Convert.ToBase64String(_cipher.Encrypt(key.Bytes, plaintext, Array.Empty <byte>())),
                Kid = _signingKeyName
            });
        }