public SigningOutput SignContent(string serializedRequest) { var hashManager = new HashManager(); var privateKey = KeyStoreAdapter.GetPrivateKeyForUser(SignatoryReference); var envolope = SigningEnvelope <string> .Create(serializedRequest, SignatoryReference, SignatoryEmail, SignatoryIpAddress); var hashSigningContent = hashManager.HashContent(envolope.Body); var rsaEncryptor = new Chilkat.Rsa { EncodingMode = EncodingMode }; rsaEncryptor.ImportPrivateKey(privateKey); var encryptedSignContentHash = rsaEncryptor.EncryptStringENC(hashSigningContent, true); envolope.AddEncryptedHashForBody(encryptedSignContentHash); var symmetricKey = KeyStoreAdapter.GetSymmetricKeyForUser(SignatoryReference); var serializedSignedContent = JsonConvert.SerializeObject(envolope); var encryptedSignedString = Encrypt(serializedSignedContent, symmetricKey); return(SigningOutput.Create(encryptedSignedString, SignatoryReference)); }
public SigningEnvelope <T> DecryptSignedContent <T>(string encryptedSignedContent, string signatory) { var symmetricKey = KeyStoreAdapter.GetSymmetricKeyForUser(signatory); var decryptedEnvolope = Decrypt(encryptedSignedContent, symmetricKey); var decryptedContent = JsonConvert.DeserializeObject <SigningEnvelope <T> >(decryptedEnvolope); return(decryptedContent); }