Smime class¶
- class cryptosyspki.Smime¶
S/MIME entity utilities.
- class Opts¶
Options for S/MIME methods.
- ADDX = 1048576¶
Add an "x-" to the content subtype (for compatibility with legacy applications)
- ENCODE_BASE64 = 65536¶
Encode output in base64
- ENCODE_BINARY = 131072¶
Encode body in binary encoding
- static extract(outputfile, inputfile, opts=0)¶
Extract the body from an S/MIME entity.
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.- Parameters:
outputfile (str) -- Name of output file to be created
inputfile (str) -- Name of input file containing S/MIME entity
opts (Smime.Opts) -- Options. By default, the output is encoded in binary. Use Opts.ENCODE_BASE64 to encode the output in base64.
- Returns:
A positive number giving the size of the output file in bytes.
- Return type:
int
- static query(filename, query)¶
Query an S/MIME entity for selected information.
- Parameters:
filename (str) -- Name of file containing S/MIME entity.
query (str) --
Query string (case-insensitive). Valid queries are:
"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".
- Returns:
Result of query if found or an empty string if not found.
- static wrap(outputfile, inputfile, opts=0)¶
Wrap a CMS object in an S/MIME entity.
- Parameters:
outputfile (str) -- Output file to be created
inputfile (str) -- Input file containing CMS object. 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.
opts (Smime.Opts) -- Options.
- Returns:
A positive number giving the size of the output file in bytes.
- Return type:
int