CryptoSys PKI  23.0.0
Public Types | Static Public Member Functions | List of all members
dipki::Smime Class Reference

S/MIME utilities. More...

Public Types

enum  AdvOpts : unsigned int
 Advanced options for S/MIME output. More...
 
enum class  Encoding
 Encodings for output. More...
 

Static Public Member Functions

static int Extract (const std::string &outputFile, const std::string &inputFile, Encoding encoding=Encoding::Default)
 Extract the body from an S/MIME entity. More...
 
static std::string Query (const std::string &inputFile, const std::string &query)
 Query an S/MIME entity for selected information. More...
 
static int Wrap (const std::string &outputFile, const std::string &inputFile, Encoding encoding=Encoding::Default, AdvOpts advopts=AdvOpts::Default)
 Wrap a CMS object in an S/MIME entity. More...
 

Detailed Description

S/MIME utilities.

Member Enumeration Documentation

◆ AdvOpts

enum dipki::Smime::AdvOpts : unsigned int

Advanced options for S/MIME output.

Enumerator
Default 

Default options.

Default 

Default encoding.

AddX 

Add an "x-" to the content subtype (for compatibility with legacy applications)

◆ Encoding

Encodings for output.

Enumerator
Default 

Default encoding.

Base64 

Encode body in base64

Binary 

Encode body in binary.

Member Function Documentation

◆ Extract()

static int dipki::Smime::Extract ( const std::string &  outputFile,
const std::string &  inputFile,
Encoding  encoding = Encoding::Default 
)
static

Extract the body from an S/MIME entity.

Parameters
outputFileName of output file to be created
inputFileName of input file containing S/MIME entity
encodingOutput encoding (default = binary)
Returns
A positive number giving the size of the output file in bytes, or a negative error code.
Remarks
This is designed to extract the body from an S/MIME entity with a content type of application/pkcs7-mime with base64 or binary transfer encoding. In practice, it will extract the body from almost any type of S/MIME (or MIME) file, except one with quoted-printable transfer encoding. By default the output is encoded in binary.

◆ Query()

static std::string dipki::Smime::Query ( const std::string &  inputFile,
const std::string &  query 
)
static

Query an S/MIME entity for selected information.

Parameters
inputFileName of file containing S/MIME entity
queryQuery string (case insensitive)
Returns
String containing the result or an empty string if not found or error.
Remarks
Valid queries are:
Query String Returns
content-type Value of Content-Type, e.g. "application/pkcs7-mime".
smime-type Value of smime-type parameter of Content-Type, e.g. "enveloped-data".
encoding Value of Content-Transfer-Encoding, e.g. "base64".
name Value of name parameter of Content-Type, e.g. "smime.p7m"
filename Value of filename parameter of Content-Disposition, e.g. "smime.p7m".

◆ Wrap()

static int dipki::Smime::Wrap ( const std::string &  outputFile,
const std::string &  inputFile,
Encoding  encoding = Encoding::Default,
AdvOpts  advopts = AdvOpts::Default 
)
static

Wrap a CMS object in an S/MIME entity.

Parameters
outputFileOutput file to be created
inputFileInput file containing CMS object
encodingOutput encoding (default = binary)
advoptsAdvanced options. Use AdvOpts::AddX to add an "x-" to the content subtype, e.g. application/x-pkcs7-mime for compatibilty with legacy applications.
Returns
A positive number giving the size of the output file in bytes, or a negative error code.
Remarks
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. By default the body in the output is encoded in base64 encoding.
Copyright © 2004-24 D.I. Management Services Pty Limited t/a CryptoSys ABN 78 083 210 584 Australia. All rights reserved. <www.di-mgt.com.au> <www.cryptosys.net>. Generated on Mon Sep 23 2024 15:37:33 by Doxygen 1.9.1.