Asn1 class

class cryptosyspki.Asn1

Utilities to analyze ASN.1 files.

class Opts

Bitwise flags for text_dump().

ADDLEVELS = 8388608

Show level numbers

NOCOMMENTS = 1048576

Hide the comments

static text_dump(outputfile, asn1file, opts=0)

Dump details of an ASN.1 formatted data file to a text file.

Parameters:
  • outputfile (str) -- Filename of text file to be created

  • asn1file (str) -- Filename of ASN.1 formatted data file to be analyzed (or a string containing its base64 representation)

  • opts (Asn1.Opts) -- Option flags.

Returns:

Zero if successful.

Return type:

int

static text_dump_tostring(asn1file, opts=0)

Dump details of an ASN.1 formatted data file to a string.

Parameters:
  • asn1file (str) -- Filename of ASN.1 formatted data file to be analyzed (or a string containing its base64 or PEM representation)

  • opts (Asn1.Opts) -- Option flags.

Returns:

String containing ASN.1 formatted data.

Return type:

string

static type(asn1file)

Describe the type of ASN.1 data.

Parameters:

asn1file (str) -- Filename of ASN.1 formatted data file to be analyzed (or a string containing its base64 or PEM representation)

Returns:

String containing the name of the type of ASN.1 data or the empty string if not found. Possible return values:

"EC PRIVATE KEY"
"OCSP REQUEST"
"OCSP RESPONSE"
"PKCS1 RSA PRIVATE KEY"
"PKCS1 RSA PUBLIC KEY"
"PKCS10 CERTIFICATE REQUEST"
"PKCS12 PFX"
"PKCS7 CERTIFICATE CHAIN"
"PKCS7/CMS COMPRESSED DATA"
"PKCS7/CMS DATA"
"PKCS7/CMS ENVELOPED DATA"
"CMS AUTH ENVELOPED DATA"
"PKCS7/CMS SIGNED DATA"
"PKCS8 ENCRYPTED PRIVATE KEY"
"PKCS8 PRIVATE KEY INFO"
"PUBLIC KEY INFO"
"X509 CERTIFICATE"
"X509 CRL"

Return type:

string