CryptoSys PKI Pro Manual

Asn1.Type Method

Describe the type of ASN.1 data.

Syntax

[C#]
public static string Type(
   string fileOrPEMString 
)
[VB]
Public Shared Function Type (
   fileOrPEMString As String 
) As String

Parameters

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

Return Value

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

Remarks

The output is a string describing the most likely type of the ASN.1-formatted data, or an empty string ("") if the type cannot be determined. The following types are detected:

Output string valueASN.1 object typeReference
EC PRIVATE KEYECPrivateKey[RFC5915]
OCSP REQUESTOCSPRequest[RFC6960]
OCSP RESPONSEOCSPResponse[RFC6960]
PKCS1 RSA PRIVATE KEYRSAPrivateKey[RFC3447]
PKCS1 RSA PUBLIC KEYRSAPublicKey[RFC3447]
PKCS10 CERTIFICATE REQUESTCertificationRequest[RFC2986]
PKCS12 PFXPFX[RFC7292]
PKCS7 CERTIFICATE CHAINContentInfo[RFC5652]
PKCS7/CMS COMPRESSED DATAContentInfo[RFC3274]
PKCS7/CMS DATAContentInfo[RFC5652]
PKCS7/CMS ENVELOPED DATAContentInfo[RFC5652]
CMS AUTH ENVELOPED DATAContentInfo[RFC5083]
PKCS7/CMS SIGNED DATAContentInfo[RFC5652]
PKCS8 ENCRYPTED PRIVATE KEYEncryptedPrivateKeyInfo[RFC5208][RFC5958]
PKCS8 PRIVATE KEY INFOPrivateKeyInfo[RFC5208][RFC5958]
PKCS8 ONE ASYMMETRIC KEYOneAsymmetricKey[RFC5958]
PUBLIC KEY INFOSubjectPublicKeyInfo[RFC3279][RFC5480]
X509 CERTIFICATECertificate[RFC5280]
X509 CRLCertificateList[RFC5280]

Note that these descriptions are not necessarily those used as labels for PEM formatted files defined in [RFC7468].

Example

Console.WriteLine("Print type names of various ASN.1 data files...");
string fname, s;
fname = "smallca.cer";
s = Asn1.Type(fname);
Console.WriteLine("Asn1.Type('" + fname + "')=" + s);
// Asn1.Type('smallca.cer')=X509 CERTIFICATE
fname = "AlicePrivRSASign.p8e";
s = Asn1.Type(fname);
Console.WriteLine("Asn1.Type('" + fname + "')=" + s);
// Asn1.Type('AlicePrivRSASign.p8e')=PKCS8 ENCRYPTED PRIVATE KEY

See Also

VB6/C equivalent: ASN1_Type

[Contents] [Index]

[PREV: Asn1.TextDumpToString Method...]   [Contents]   [Index]   
   [NEXT: Cipher.BlockBytes Method...]

Copyright © 2004-26 D.I. Management Services Pty Ltd t/a CryptoSys. All rights reserved. Generated 2026-09-21T05:59:39Z.