An Overview of Cryptography

Block Ciphers Modes of Operation

PKCS #12 v1.1: Personal Information Exchange Syntax

ASN.1

ASN.1 introduction

filetype: pem, cer, crt, der, p7b, p7c, p12, pfx

Certificate filename extensions

What are the differences between PEM, DER, P7B/PKCS#7, PFX/PKCS#12 certificates

证书

.pem – 证书 (Privacy-enhanced Electronic Mail) Base64 encoded DER certificate, enclosed between “—–BEGIN CERTIFICATE—–” and “—–END CERTIFICATE—–”

.cer, .crt, .der – binary DER编码的证书,或者Base64 DER编码(pem兼容)

.p7b, .p7c – PKCS#7 SignedData structure without data, just certificate(s) or CRL(s)

信息交换

.p12 – PKCS#12, may contain certificate(s) (public) and private keys (password protected)

.pfx – PFX personal information exchange, predecessor of PKCS#12 (usually contains data in PKCS#12 format, e.g., with PFX files generated in IIS)

openssl

The Most Common OpenSSL Commands

openssl command

How to Convert certificates between PEM, DER, P7B/PKCS#7, PFX/PKCS#12

示例文件见 openssl_cmd

X.509v3

RFC5280 Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile

wiki X.509

Root Certificate, Intermediate certificate, End-entity certificate

Certificate

Certificate  ::=  SEQUENCE  {
        tbsCertificate       TBSCertificate,
        signatureAlgorithm   AlgorithmIdentifier,
        signatureValue       BIT STRING  }

   TBSCertificate  ::=  SEQUENCE  {
        version         [0]  EXPLICIT Version DEFAULT v1,
        serialNumber         CertificateSerialNumber,
        signature            AlgorithmIdentifier,
        issuer               Name,
        validity             Validity,
        subject              Name,
        subjectPublicKeyInfo SubjectPublicKeyInfo,
        issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,
                             -- If present, version MUST be v2 or v3
                              subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,
                             -- If present, version MUST be v2 or v3
        extensions      [3]  EXPLICIT Extensions OPTIONAL
                             -- If present, version MUST be v3
        }

   Version  ::=  INTEGER  {  v1(0), v2(1), v3(2)  }

   CertificateSerialNumber  ::=  INTEGER

   Validity ::= SEQUENCE {
    notBefore      Time,
    notAfter       Time }

   Time ::= CHOICE {
        utcTime        UTCTime,
        generalTime    GeneralizedTime }

   UniqueIdentifier  ::=  BIT STRING

   SubjectPublicKeyInfo  ::=  SEQUENCE  {
        algorithm            AlgorithmIdentifier,
        subjectPublicKey     BIT STRING  }

   Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

   Extension  ::=  SEQUENCE  {
        extnID      OBJECT IDENTIFIER,
        critical    BOOLEAN DEFAULT FALSE,
        extnValue   OCTET STRING
                    -- contains the DER encoding of an ASN.1 value
                    -- corresponding to the extension type identified
                    -- by extnID
        }

CRL

CertificateList  ::=  SEQUENCE  {
        tbsCertList          TBSCertList,
        signatureAlgorithm   AlgorithmIdentifier,
        signatureValue       BIT STRING  }

   TBSCertList  ::=  SEQUENCE  {
        version                 Version OPTIONAL,
                                     -- if present, MUST be v2
        signature               AlgorithmIdentifier,
        issuer                  Name,
        thisUpdate              Time,
        nextUpdate              Time OPTIONAL,
        revokedCertificates     SEQUENCE OF SEQUENCE  {
             userCertificate         CertificateSerialNumber,
             revocationDate          Time,
             crlEntryExtensions      Extensions OPTIONAL
                                      -- if present, version MUST be v2
                                  }  OPTIONAL,
        crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
                                      -- if present, version MUST be v2
                                  }

PKCS #6: Extended-Certificate Syntax

RFC2985 PKCS #9: Selected Object Classes and Attribute Types

PKCS #11: Cryptographic Token Interface

PKCS #13: Elliptic curve cryptography Standard

PKCS #14: Pseudo-random Number Generation

PKCS #15: Cryptographic Token Information Format Standard

RFC5652 Cryptographic Message Syntax (CMS)

RFC5083 Cryptographic Message Syntax (CMS) Authenticated-Enveloped-Data Content Type

RFC5958 Asymmetric Key Packages

ocsp

OCSP Validation with OpenSSL

Specification documentfor OCSP

OpenSSL: Manually verify a certificate against an OCSP

Using OpenSSL to run an OCSP query for an SSL Certificate

x509v3 Extensions

How to generate x509v3 Extensions in the End user certificate