What Is PKCS#8?

This section describes what is PKCS#8 - One of the PKCS (Public Key Cryptography Standards) used to store a single private key. A PKCS#8 file can be encrypted with a password to protect the private key.

PKCS#8 is one of the PKCS (Public Key Cryptography Standards) devised and published by RSA Security. PKCS#8 is designed as the Private-Key Information Syntax Standard. It is used to store private keys.

PKCS#8 standard actually has two versions: non-encrypted and encrypted.

The non-encrypted PKCS#8 version defines the following syntax for a private key:

PrivateKeyInfo ::= SEQUENCE {
  version Version,

  privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
  privateKey PrivateKey,
  attributes [0] IMPLICIT Attributes OPTIONAL }

Version ::= INTEGER

PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier

PrivateKey ::= OCTET STRING

Attributes ::= SET OF Attribute

The encrypted PKCS#8 version defines the following syntax:

EncryptedPrivateKeyInfo ::= SEQUENCE {
  encryptionAlgorithm EncryptionAlgorithmIdentifier,
  encryptedData EncryptedData }

EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier

EncryptedData ::= OCTET STRING

Java SE "keytool" does not support exporting private keys in PKCS#8 format directly. But you can use my "DumpKey.java" to do this as described in another chapter of this book.

"OpenSSL" does not support exporting private keys in PKCS#8 format directly. It writes private keys in its own format referred as a private key traditional format. But it offers the "openssl pkcs8" command to convert private keys files from traditional format to pkcs#8 back and forth.

When writing a private key in PKCS#8 format in a file, it needs to stored in either DER encoding or PEM encoding. DER and PEM encodings are describes in other chapters in this book.

Visit PKCS page at rsa.comto read more about PKCS#8.

Last update: 2013.

Table of Contents

 About This Book

 Cryptography Terminology

 Cryptography Basic Concepts

 Introduction to AES (Advanced Encryption Standard)

 Introduction to DES Algorithm

 DES Algorithm - Illustrated with Java Programs

 DES Algorithm Java Implementation

 DES Algorithm - Java Implementation in JDK JCE

 DES Encryption Operation Modes

 DES in Stream Cipher Modes

 PHP Implementation of DES - mcrypt

 Blowfish - 8-Byte Block Cipher

 Secret Key Generation and Management

 Cipher - Secret Key Encryption and Decryption

 Introduction of RSA Algorithm

 RSA Implementation using java.math.BigInteger Class

 Introduction of DSA (Digital Signature Algorithm)

 Java Default Implementation of DSA

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Cipher - Public Key Encryption and Decryption

 MD5 Mesasge Digest Algorithm

 SHA1 Mesasge Digest Algorithm

 OpenSSL Introduction and Installation

 OpenSSL Generating and Managing RSA Keys

 OpenSSL Managing Certificates

 OpenSSL Generating and Signing CSR

 OpenSSL Validating Certificate Path

 "keytool" and "keystore" from JDK

 "OpenSSL" Signing CSR Generated by "keytool"

 Migrating Keys from "keystore" to "OpenSSL" Key Files

 Certificate X.509 Standard and DER/PEM Formats

Migrating Keys from "OpenSSL" Key Files to "keystore"

What Is PKCS#8?

 What Is PKCS#12?

 "openssl genrsa" Generating Private Key

 "openssl pkcs8" Converting Keys to PKCS#8 Format

 "openssl pkcs12" Merging Key with Certificate

 "keytool -list" Verifying PKCS#12 Files

 "keytool -importkeystore" Importing PKCS#12 Files

 Summary - Migrating "OpenSSL" Keys to "keystore"

 Summary - Migrating "keystore" Keys to "OpenSSL"

 Using Certificates in IE (Internet Explorer)

 Using Certificates in Firefox

 Using Certificates in Google Chrome

 Outdated Tutorials

 References

 PDF Printing Version