Wrap a CMS object in an S/MIME entity.
Public Declare Function SMIME_Wrap Lib "diCrPKI.dll" (ByVal strFileOut As String, ByVal strFileIn As String, ByVal strFeatures As String, ByVal nOptions As Long) As Long
nRet = SMIME_Wrap(strFileOut, strFileIn, strFeatures, nOptions)
long __stdcall SMIME_Wrap(const char *szFileOut, const char *szFileIn, const char *szFeatures, long nOptions);
""
or NULL
for defaults.A positive number giving the size of the output file in bytes; or a negative error code.
static int dipki::Smime::Wrap (const std::string &outputFile, const std::string &inputFile, Encoding encoding=Encoding::Default, AdvOpts advopts=AdvOpts::Default)
static Smime.wrap(outputfile, inputfile, opts=0)
This forms an S/MIME entity with a Content-Type of application/pkcs7-mime
from a binary CMS object.
It works in file-to-file mode only.
The input file is expected to be a binary CMS object of type enveloped-data, signed-data or compressed-data;
otherwise it is an error.
The type of input file is detected automatically.
The output is a text file with the correct S/MIME headers according to [SMIME-MSG].
By default the body is encoded in base64.
Use the PKI_SMIME_ENCODE_BINARY option to encode the body in "binary" instead.
Use the PKI_SMIME_ADDX option to change the Content-Type to
application/x-pkcs7-mime
for compatibility with legacy applications.
S/MIME signed messages with the multipart/signed
format are currently not supported.
nRet = SMIME_Wrap("cmsalice2bob-smime-env.txt", "cmsalice2bob.p7m", "", 0)
In this example, the binary file cmsalice2bob.p7m
was created using
CMS_MakeEnvData
.
The output file should look like the following.
Content-Type: application/pkcs7-mime; smime-type=enveloped-data; id="smime.p7m" Content-Transfer-Encoding: base64 Content-Disposition: attachment; fileid="smime.p7m" MIAGCSqGSIb3DQEHA6CAMIACAQAxgcAwgb0CAQAwJjASMRAwDgYDVQQDEwdDYXJs UlNBAhBGNGvHgABWvBHTbi7NXXHQMA0GCSqGSIb3DQEBAQUABIGAFx80IYQbAX8+ 7PIXJzUInDUydJv9tgogwzQY8KHwneD1Wcihc/Thi3QtSIQu4bnoPlSbGdF76SuE Cajdnq5PDU34SnMywq8fyBxDM0ayUfYfMozZOhnM4mr9F4lF3zqtAhnukQF8b+Hv cTgt4XHHrk2P5vHhdtaA4spSM9kDtpwwgAYJKoZIhvcNAQcBMBQGCCqGSIb3DQMH BAh7TZ7TVakVU6CABCCNGoP9xsyKSFr1lFrffFky8Ym+efPbS4jx1ODxWzHa3wAA AAAAAAAAAAA=