As VP of Software Development at Keyfactor, it’s my job to speak with candidates and newly hired engineers as they join the ranks of our growing team (Quick plug: you can always check out our site for open positions). But I’m not here to sell you on Keyfactor, I’m here to talk about the most difficult part of the job – and it’s not the software development. The biggest challenge is getting an understanding the basic concepts of public key infrastructure (PKI).
Cryptography, and particularly PKI, are broad and incredibly complex in nature. Some technologists spend their entire career focused on it. As such, it is not expected (or even feasible) for any software engineer to be well-versed in these concepts, but a basic understanding can go a long way.
Whether you work directly with PKI or you don’t, every software engineer relies on cryptography throughout the build and release process. If you’re involved in working with PKI or developing cryptographic solutions, it’s especially important to understand not just the tools and applications you use to build and run software, but also the technologies you’re less likely familiar with.
I’ve created the following primer to give software engineers an idea of the important topics commonly encountered in the development process. This list and its descriptions are brief, and intentionally so. It’s intended as a “quick start” guide to help you navigate your way into the complex, yet exciting and rapidly growing world of PKI and cryptography.
What are the primary goals of cryptography?
- Confidentiality: protects the confidentiality (or secrecy) of data
- Integrity: ensures that data or code has not been tampered
- Authentication: verifies the identity/authenticity of a user, device or application
What are the different types of cryptography?
- Symmetric encryption: uses the same cryptographic key to encrypt and decrypt data. The advantage is that processes can encrypt and decrypt vast amounts of data efficiently, since it uses a single key and relatively simple algorithms (e.g. DES, 3DES, AES). The problem is that all parties involved need to exchange the key used to encrypt and decrypt data, which can lead to obvious insecurities.
- Asymmetric encryption: uses not one key, but a pair of different, yet mathematically related keys: a private one and a public one. The public key used to encrypt data is made available to anyone, while the private key is kept only by the user or machine that generated the key pair, and is used for decryption. This means that you do not have to worry about sharing public keys over the Internet.
Asymmetric algorithms are much more complex, and therefore more secure (e.g. RSA, ECC, Diffie-Hellman). However, this also means that it is slower than symmetric encryption and requires more processing processing power.
How are symmetric and asymmetric cryptography used together?
A common scenario is with TLS, a protocol used to encrypt communications over a network. During a TLS handshake, asymmetric keys first authenticate the connection between the client (public key) and the server (private key). At this point, symmetric keys, called “session keys,” are used to encrypt communications. Each new session starts with a new TLS handshake and session keys.
What is a hash?
A hash is a one-way algorithm that converts one value into another, masking the original data with a mathematical output – called a “digest.” Hashing is commonly used to ensure that data has not been tampered with since the hash was created. Common algorithms include MD5, SHA-1 and SHA-2.
What is a digital signature?
A digital signature verifies the authenticity of a message, file or executable with a unique digital ID (and signing key). For instance, a user’s private key can be used to digitally sign a document and verify the sender’s identity. The user cannot then deny that they signed the document, which is referred to as non-repudiation.
Public Key Infrastructure
What is public key infrastructure (PKI)?
Public key infrastructure (PKI) is a set of people, systems, policies and procedures that support the distribution and use of public keys and digital certificates. Organizations implement a PKI to enable the use of encryption, authentication and digital signatures for various applications.
What is a digital certificate?
A digital certificate, also known as a public key certificate, is an electronic document used to bind a public key to its owner. A certificate is a unique ID for users, devices, applications and services, which includes information about its owner’s identity and permissions, such as:
- Certificate serial number
- Name of the certificate issuer
- Public key
- Supported algorithms
- Certificate validity period
What are the properties of a digital certificate?
Important/Commonly Used Properties
- Thumbprint: A hash of the certificate – the thumbprint is used as a unique identifier for the certificate.
- Subject: Distinguished Name (DN) of the certificate (contains fields like CN, O, OU, etc.)
- Issuer: The entity from which the certificate was issued.
- Subject Alternative Name (SAN): Extension with additional information about the subject (now required for by Google Chrome).
- Key Usage: Defines what the certificate can be used for, including digital signature, key encipherment, certificate signing, CRL signing and non-repudiation.
- Enhanced Key Usage: Additional extension for further definition of key usages, including IPSec, TLS web server authentication, TLS web client authentication, and digital signature.
- Version: The X.509 certificate version (there are currently 3 versions)
- Valid From/To: Date range in which the certificate is considered valid
- CRL Distribution Points: The location of the certificate revocation list (CRL) associated with the certificate
Other Common Properties
- Serial Number: Integer assigned to the certificate by the CA
- Signature Algorithm: The cryptographic algorithm used by the CA to sign the certificate
- Public Key: Public key used by the certificate for its intended purpose
- Subject Key Identifier: Provides a means of identifying certificates that contain a particular public key (from the CSR)
What is a certificate authority (CA)?
A Certificate Authority (CA) is a trusted entity that issues digital certificates.
What is a root certificate?
At the core of PKI is a root certificate and its associated private key. It is used to sign all certificates issued by the highest-level (root) certificate authority. A trusted root certificate is one that is implicitly trusted.
What is an end-entity certificate?
Any certificate that cannot be used to sign other certificates. For instance, SSL/TLS server and client certificates, code signing certificates, and qualified certificates are all end-entity certificates.
What is a certificate revocation list (CRL)?
A Certificate Revocation List (CRL) is a list of digital certificates that have been revoked by the issuing certificate authority before their schedule expiration date. It’s essentially a blacklist that allows users, devices or apps to verify if a certificate is valid and trustworthy. The CRL is published to a location, known as the CRL Distribution Point (CDP), available to all entities that need to check revocation status.
What is the online certificate status protocol (OCSP)?
The problem is that CRL requires the overhead of downloading a list of all certificates and checking for revocation status. The OCSP is an alternative to using CRLs. Instead of having to download the complete list of revoked certificates, it simply submits a request to the CA server to obtain the current status of the certificate.
How does OCSP differ from CRL?
An OCSP response contains less data than a typical CRL, putting less burden on network and client resources. It also has less data to parse, so client-side libraries can be less complex.
What are some shortcomings of OCSP?
One of the issues with OCSP is that it is resource intensive for a CA in higher volume environments.It can also compromise user privacy and reduce performance in browsing. It’s also problematic if the OCSP responder cannot communicate with the associated CA for any reason.
What is OCSP Stapling?
OCSP Stapling solves some of these issues. The HTTPS server regularly queries the OCSP server for revocation status of its certificate(s) and sends the response with the certificate to the client during the TLS handshake. Responses cannot be forged, since they must be signed by the associated CA.
What is a Cryptographic Service Provider (CSP)?
A CSP is a CryptoAPI used to create, store and access cryptographic keys, which can be either symmetric or asymmetric. CSPs are central to secure implementation of cryptographic functionality for many applications, including Active Directory Certificate Services (ADCS) and the Certificate Enrollment API.
What is a Key Storage Provider (KSP)?
A KSP is the next generation of CSP, based on Cryptography API: Next Generation (CNG). It can be used to create, delete, export and store keys for use cases such as asymmetric encryption and signing.
What are Public Key Cryptography Standards (PKCS)?
In cryptography, PKCS is a set of widely accepted standards, defined and published by RSA Security LLC to promote the use of standard cryptography techniques. Some of these standards include:
- PKCS 7: Cryptographic Message Syntax (CMS) is the specific standard used for the generation of digital certificates by a PKI. It also serves as the basis for the S/MIME standard.
- PKCS 10: the Cryptographic Signing Request (CSR) standard is the format of messages sent to the certificate authority (CA) to request a digital certificate.
- PKCS 11: the Cryptographic Token Interface, also known as Cryptoki, is an API used to create and manipulate cryptographic tokens, hardware security modules (HSMs) and smartcards.
- PKCS 12: defines a file format used to store private keys together with their public key certificates. PFX is Microsoft’s implementation of this standard.
Learn more about how PKI fits into DevOps in our latest eBook: How to Enable DevSecOps with Certificate Lifecycle Automation.