public byte[] Decrypt(Encrypted encrypted) { switch (encrypted.Scheme) { case AesKey.EncryptionScheme: return(GetAes(encrypted.KeyId).Decrypt(encrypted)); case RsaKey.EncryptionScheme: return(GetRsa(encrypted.KeyId).Decrypt(encrypted)); } throw ExceptionFactory.MakeInvalidOperation( string.Format("Keychain: Unsupported encryption scheme '{0}'", encrypted.Scheme)); }
public byte[] Decrypt(Encrypted e) { if (e.KeyId != Id) { throw ExceptionFactory.MakeInvalidOperation("AES key: mismatching key id"); } if (e.Scheme != EncryptionScheme) { throw ExceptionFactory.MakeInvalidOperation( string.Format("AES key: invalid encryption scheme '{0}', expected '{1}'", e.Scheme, EncryptionScheme)); } return(AesGcm.Decrypt(Key, e.Ciphertext, e.Iv, new byte[0])); }
public byte[] Decrypt(Encrypted e) { if (e.KeyId != Id) { throw ExceptionFactory.MakeInvalidOperation("RSA key: mismatching key id"); } if (e.Scheme != EncryptionScheme) { throw ExceptionFactory.MakeInvalidOperation( string.Format("RSA key: invalid encryption scheme '{0}', expected '{1}'", e.Scheme, EncryptionScheme)); } using (var rsa = new RSACryptoServiceProvider()) { rsa.ImportParameters(Parameters); return(rsa.Decrypt(e.Ciphertext, true)); } }
internal static JObject Decrypt(JToken json, Keychain keychain) { return(JObject.Parse(keychain.Decrypt(Encrypted.Parse(json)).ToUtf8())); }
internal static JObject Decrypt(JToken json, AesKey sessionKey) { return(JObject.Parse(sessionKey.Decrypt(Encrypted.Parse(json)).ToUtf8())); }