public ProcessSecretMessageResponse ProcessSecretMessage(ProcessSecretMessageRequest processSecretMessageRequest) { ProcessSecretMessageResponse response = new ProcessSecretMessageResponse(); try { AsymmetricKeyPairGenerationResult asymmetricKeyInStore = _asymmetricKeyRepositoryFactory.Create().FindBy(processSecretMessageRequest.MessageId); _asymmetricKeyRepositoryFactory.Create().Remove(processSecretMessageRequest.MessageId); String decryptedPublicKey = _asymmetricCryptoService.DecryptCipherText(processSecretMessageRequest.EncryptedPublicKey , asymmetricKeyInStore); String decryptedMessage = _symmetricCryptoService.Decrypt(processSecretMessageRequest.SymmetricEncryptionArgs.InitialisationVector , decryptedPublicKey, processSecretMessageRequest.SymmetricEncryptionArgs.CipherText); response.SecretMessageProcessResult = string.Concat("Message received and deciphered: ", decryptedMessage); } catch (Exception ex) { response.SecretMessageProcessResult = string.Concat("Exception during the message decryption process: ", ex.Message); response.Exception = ex; } return(response); }
public HttpResponseMessage Post(ProcessSecretMessageRequest secretMessageRequest) { ServiceResponseBase response = _secretMessageProcessingService.ProcessSecretMessage(secretMessageRequest); return(Request.BuildResponse(response)); }