I have a code written in C# to sign and envelop a string to be sent to a web service, this code receives a certificate in the format .pfx and the certificate password.
string myString = "Hello World";
X509Certificate2 cert = new X509Certificate2(@"<MY PFX FILE>", "<MY PASS>");
CmsSigner signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, cert);
signer.DigestAlgorithm = new Oid("<MY OID>");
ContentInfo content = new ContentInfo(new Oid("<MY OID>"), new System.Text.UTF8Encoding().GetBytes(myString));
SignedCms signedCms = new SignedCms(content, false);
signedCms.ComputeSignature(signer, false);
var asig = signedCms.Encode();
Now I need to write a code that does exactly the same thing, but in C, after performing several searches on google, I found some libs. that work with this type of information, and in this search I found OpenSSL.
But I did not find how I could sign and envelop the message, just like I am doing in C#. Thanks in advance if anyone can help me, how can I do the same thing I do in C# in C.
What I have tried:
I did some tests with lib "ChilKat",
C RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature[
^], when I encrypted the same information with my C# program and with this C++ program, the output is complete different, and, I did not managed how to use the OID digest algorithm...
With OpenSSL, I didn't find how I can sign a message use PKCS#7 certification.