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> DecryptSignature(string signedContent, string signatory) { var decryptedSingature = cryptoService.DecryptSignature(signedContent, signatory); var deserializedContent = JsonConvert.DeserializeObject <T>(decryptedSingature?.Body?.Content); var body = new ContentBody <T>(); if (decryptedSingature?.Body != null) { body.Content = deserializedContent; body.Version = decryptedSingature.Body.Version; body.CreateDateTime = decryptedSingature.Body.CreateDateTime; body.EmailAddress = decryptedSingature.Body.EmailAddress; body.IpAddress = decryptedSingature.Body.IpAddress; body.Signatory = decryptedSingature.Body.Signatory; } var mappedSignature = new SigningEnvelope <T> { Header = decryptedSingature?.Header, Body = body }; return(mappedSignature); }
public SigningOutput SignContent(string serializedRequest) { var salt = Guid.NewGuid().ToString(); var envolope = SigningEnvelope <string> .Create(serializedRequest, Signatory, SignatoryEmail, SignatoryIpAddress); envolope.AddEncryptedHashForBody(HashValue); var serializedSignedContent = JsonConvert.SerializeObject(envolope); return(SigningOutput.Create(serializedSignedContent, Signatory)); }