Cryptography
Confidentiality
- Data Confidentiality: Achieved through encryption, both symmetric and asymmetric.
- Symmetric: Uses a pre-shared key.
- Asymmetric: Uses public and private keys.
Symmetric Encryption
- Uses the same pre-shared key for encryption and decryption.
- Commonly used with VPN traffic due to lower CPU resource usage.
- Key length:
- Should be a minimum of 128 bits for safety. Most encryption keys are between 112 and 256 bits.
- Classified as either:
- Block ciphers: Transform fixed-length blocks of plaintext (64 or 128 bits).
- Stream ciphers: Encrypt one byte or one bit at a time; typically faster.
- Examples:
- Data Encryption Standard (DES): A legacy algorithm with a short key length, making it insecure.
- 3DES (Triple DES): Replaced DES, repeating the algorithm three times. Scheduled to be retired; avoid if possible. If implemented use very short key lifetimes.
- Advanced Encryption Standard (AES): Popular and recommended; offers 128-, 192-, or 256-bit keys.
- Software-Optimized Encryption Algorithm (SEAL): Faster alternative to AES; uses a 160-bit key and has lower CPU impact.
- Rivest ciphers (RC) series (RC4): A stream cipher used to secure web traffic; has multiple vulnerabilities and should not be used.
Asymmetric Encryption
- Uses different keys for encryption and decryption.
- The decryption key cannot be easily calculated from the encryption key.
- Uses a public key and a private key.
- Process: Data encrypted with the public key requires the private key to decrypt and vice versa.
- Key lengths: between 512 to 4,096 bits. Key lengths >= 2,048 bits are trusted, while key lengths of 1,024 or shorter are considered insufficient.
- Protocols:
- Internet Key Exchange (IKE) - A fundamental component of IPsec VPNs.
- Secure Socket Layer (SSL) - Implemented now as IETF standard Transport Layer Security (TLS).
- Secure Shell (SSH) - Provides secure remote access.
- Pretty Good Privacy (PGP) - Provides cryptographic privacy and authentication.
- Slower than symmetric algorithms.
- Key management is simpler because one key can be public.
Asymmetric Encryption Algorithms
- Diffie-Hellman (DH):
- Key lengths: 512, 1024, 2048, 3072, 4096
- Allows two parties to agree on a key without prior communication.
- Security depends on the difficulty of computing discrete logarithms.
- Digital Signature Standard (DSS) and Digital Signature Algorithm (DSA):
- Key lengths: 512 - 1024
- DSA is the algorithm specified by DSS for digital signatures based on the ElGamal signature scheme.
- Signature creation speed is like RSA, but slower for verification.
- Rivest, Shamir, and Adleman (RSA):
- Key lengths: 512 to 2048
- Based on the difficulty of factoring large numbers.
- ElGamal:
- Key lengths: 512 - 1024
- Based on DH key agreement; encrypted messages are twice the original size, so it is only used for small messages such as secret keys.
- Elliptic curve techniques:
- Key lengths: 224 or higher
- Can be used to adapt many cryptographic algorithms like DH or ElGamal.
Asymmetric Encryption - Confidentiality
- Achieves confidentiality without pre-shared passwords.
- Formula:
- Only the host with the private key can decrypt the data.
- Compromised private key requires the generation of a new key pair.
- Example: Alice encrypts a message to Bob using Bob's public key; Bob decrypts with his private key.
Asymmetric Encryption - Authentication
- Authentication is achieved by encrypting with the private key and decrypted with the public key.
- Formula:
- Verifies the sender.
- Example: Alice encrypts a message using her private key; Bob decrypts with Alice’s public key to authenticate that the message came from Alice.
Asymmetric Encryption - Integrity
- Combining confidentiality and authentication.
- Example: Alice ciphers a message using Bob's public key, then ciphers a hash of the message using her private key. Bob uses Alice’s public key to verify message integrity and uses his private key to decipher the message.
Diffie-Hellman (DH)
- Allows two computers to generate a shared secret without prior communication.
- The shared key is never exchanged.
- Commonly used in IPsec VPNs and SSH data exchange.
- Process (simplified using colors).
- Alice and Bob agree on a common color (yellow).
- They each choose a secret color (Alice-red, Bob-blue).
- Alice mixes yellow with red to produce orange; Bob mixes yellow with blue to produce green.
- Alice sends orange to Bob; Bob sends green to Alice.
- Each mixes the received color with their original secret color, resulting in an identical brown color mixture as their partner.
- The brown color represents the shared secret key.
- DH uses very large numbers for security.
DH Groups
- Used to determine the strength of the key.
- Higher group numbers are more secure but require more computation time.
- Examples (Cisco IOS Software):
- DH Group 1: 768 bits
- DH Group 2: 1024 bits
- DH Group 5: 1536 bits
- DH Group 14: 2048 bits
- DH Group 15: 3072 bits
- DH Group 16: 4096 bits
Obscuring Data
Data Masking Techniques
- Replaces sensitive information with non-sensitive versions.
- Limits the propagation of sensitive data.
- Can be dynamically masked.
- Used in non-production environments.
- Methods:
- Substitution: Replaces data with authentic-looking values.
- Shuffling: Derives a substitution set from the same data column.
- Nulling out: Applies a null value making the particular field invisible.
Steganography
- Conceals data in another file (graphic, audio, video).
- The secret message does not attract attention.
- Components:
- Embedded data (secret message).
- Cover-text (cover-image, cover-audio) hides the embedded data, producing stego-text (stego-image, stego-audio).
- Stego key controls the hiding process.
- Techniques:
- Least Significant Bits (LSB): Embeds data in the least significant bits of each pixel in an image. Each pixel can store three bits (one bit per color: red, green, blue).
- Social steganography: Hides information in plain sight by creating output that can be read a certain way by some to get the secret message, based on previously set rules and/or definitions. As a result, those who view it in a normal way will not see the message.
- Detection: Steganalysis follows the discovery that hidden information exists. The goal of steganalysis is to discover this hidden information. Patterns in the stego image create suspicion.
Integrity and Authenticity
Securing Communications
- Elements:
- Data Integrity: Ensures that the message was not altered.
- Ensured by SHA-2 or SHA-3. MD5 is insecure and should be avoided.
- Origin Authentication: Guarantees the message is not a forgery.
- Ensured by HMAC (hash-based message authentication code).
- Data Confidentiality: Only authorized users can read the message.
- Implemented using symmetric and asymmetric encryption.
- Data Non-Repudiation: Sender cannot refute the validity of the message.
- Data Integrity: Ensures that the message was not altered.
Cryptographic Hash Functions
- Used to verify data integrity based on a one-way mathematical function.
- Can also be used to verify authentication.
- A hash function takes a variable block of binary data (message) and produces a fixed-length, condensed representation (hash).
- It is computationally infeasible for two different sets of data to produce the same hash output.
- Every time the data is changed or altered, the hash value also changes.
- Mathematically, the equation describes it. A hash function H takes an input x and returns a fixed-size string hash value h.
- Properties:
- Input can be any length.
- Output has a fixed length.
- H(x) is easy to compute.
- H(x) is one way and not reversible.
- H(x) is collision free.
- Hard to invert (one-way hash) means that given a hash value of h, it is computationally infeasible to find an input for x such that .
MD5 and SHA
- Used to ensure message integrity.
- Hashing can be used to detect accidental changes but cannot be used to guard against deliberate changes that are made by a threat actor.
- Vulnerable to MiTM attacks.
- Hash functions:
- MD5: 128-bit digest. Legacy algorithm; avoid if possible.
- SHA-1: 160-bit hashed message. Slower than MD5. Legacy algorithm with known flaws.
- SHA-2: Includes SHA-224 (224 bit), SHA-256 (256 bit), SHA-384 (384 bit), and SHA-512 (512 bit). SHA-256, SHA-384, and SHA-512 algorithms should be used whenever possible.
- SHA-3: Includes SHA3-224 (224 bit), SHA3-256 (256 bit), SHA3-384 (384 bit), and SHA3-512 (512 bit). Next-generation algorithm; use whenever possible.
Origin Authentication
- Use a keyed-hash message authentication code (HMAC) to add origin authentication and integrity assurance.
- HMAC uses an additional secret key as input to the hash function.
- Only the sender and the receiver know the secret key, and the output of the hash function now depends on the input data and the secret key.
- If two parties share a secret key and use HMAC functions for authentication, a properly constructed HMAC digest of a message that a party has received indicates that the other party was the originator of the message.
- Process.
- The sending device inputs data (such as Terry Smith’s pay of $100 and the secret key) into the hashing algorithm and calculates the fixed- length HMAC digest.
- This authenticated digest is then attached to the message and sent to the receiver.
Verifying the HMAC Value
- The receiving device removes the digest from the message and uses the plaintext message with its secret key as input into the same hashing function.
- If the digest that is calculated by the receiving device is equal to the digest that was sent, the message has not been altered.
- The origin of the message is authenticated because only the sender possesses a copy of the shared secret key.
Using Hashes
Hashing Files and Digital Media
- Integrity ensures that data is complete and unaltered.
- Cisco provides MD5 and SHA checksums for Cisco IOS images.
- Digital forensics uses hashing to verify all digital media.
- The examiner creates a hash and a bit-for-bit copy of the media to produce a digital clone.
- If the two values match, the copies are identical.
- Fixity - The fact that one set of bits is identical to the original set of bits establishing fixity answers questions.
- Does the examiner have the files they expect?
- Is the data corrupted or changed?
- Can the examiner prove that the files are not corrupt?
Hashing Passwords
- Algorithms turn data into fixed-length fingerprints.
- Digital hashes cannot be reversed to discover the original input.
- If input changes, the hash changes.
- The system stores digital hash rather than plain password.
Cracking Hashes
- Attacker guesses the password.
- Attacks used:
- Dictionary attack: Uses a file of common words and passwords; compares hashes.
- Brute-force attack: Attempts every possible character combination; takes time and processing power.
Salting
- Makes password hashing more secure.
- A salt, which is a random string of characters, is an additional input added to the password before hashing. This creates a different hash result even when the two passwords are identical.
- The database stores both the hash and the salt.
- The salt does not have to be secret since it is a random number.
Implementing Salting
- Use a cryptographically secure pseudo-random number generator (CSPRNG) to generate salt.
- Recommendations:
- The salt needs to be unique for every user password.
- Never reuse a salt.
- The length of the salt should match the length of the hash function’s output.
- Always hash on the server, in a web application.
- Key stretching makes attempts to figure out passwords work very slowly and is a technique that will also help to protect against attack.
- To store a password:
- Use CSPRNG to generate a long, random salt.
- Add the salt to the beginning of the password.
- Hash it with SHA-256, a standard cryptographic hash function.
- Save the salt and the hash in the user’s database record.
- To validate a password:
- Retrieve a user’s salt and hash from the database.
- Add the salt to the password and hash it with the same hash function.
- Compare the hash of the password just submitted by the user trying to log in to the one stored in the database.
- If the hashes do not match, the password the user has just tried to log in with is incorrect.
Preventing Attacks
- Salting prevents dictionary attacks and makes it impossible to use lookup tables and rainbow tables to crack a hash.
- Lookup tables:
- It stores the pre-computed hashes of passwords in a password dictionary, along with the corresponding password. They are a data structure that processes hundreds of hash lookups per second.
- Reverse lookup tables:
- This attack allows the cybercriminal to launch a dictionary or brute-force attack on many hashes without the pre-computed lookup table. The cybercriminal creates a lookup table that plots each password hash from the breached account database to a list of users. The cybercriminal hashes each password guess and uses the lookup table to get a list of users whose password matched the cybercriminal’s guess.
- Rainbow tables:
- They sacrifice hash-cracking speed to make the lookup tables smaller. A smaller table means that the table can store the solutions to more hashes in the same amount of space.
Public Key Cryptography
Using Digital Signatures
- Provide authenticity, integrity, and nonrepudiation.
- Serve as legal proof.
- Properties:
- Authentic: The signature cannot be forged.
- Unalterable: The document cannot be altered after signing.
- Not Reusable: The signature cannot be transferred to another document.
- Non-Repudiated: The signed document is proof of signing by the actual person.
- Uses:
- Code signing: Verifies the integrity of executable files and authenticates the source.
- Digital certificates: Authenticate the identity of a system and establish encrypted connections.
- Algorithms:
- Digital Signature Algorithm (DSA): Original standard for generating and verifying digital signatures.
- Rivest-Shamir Adleman Algorithm (RSA): Commonly used for generating and verifying digital signatures.
- Elliptic Curve Digital Signature Algorithm (ECDSA): Provides digital signature authentication and non-repudiation.
Digital Signatures for Code Signing
- Provide assurance of authenticity and integrity of software code.
- Executable files are wrapped in a digitally signed envelope.
- Assurances provided.
- Code is authentic and sourced by the publisher.
- Code has not been modified.
- Nonrepudiation of publishing.
Digital Signatures for Digital Certificates
- A digital certificate is equivalent to an electronic passport.
- Authenticates and verifies user identity.
- Provides confidentiality.
- Process (Bob and Alice example):
- Alice requests an order from bob’s website, after the certificate has been verified, Bob’s certificate is stored on Alice’s website.
- Alice’s receiving device accepts the order confirmation with the digital signature and obtains Bob’s public key.
- Alice’s computer then decrypts the signature using Bob’s public key. This step reveals the assumed hash value of the sending device.
- Alice’s computer creates a hash of the received document, without its signature, and compares this hash to the decrypted signature hash. If the hashes match, the document is authentic.
Authorities and the PKI Trust System
Public Key Management
- Internet traffic uses public key exchange for asymmetric connections.
- An SSL certificate confirms website identity.
- A trusted third party validates credentials prior to issuance.
- Web browsers check website security certificates and verify their validity with a certificate authority (CA).
Public Key Infrastructure (PKI)
- Consists of specifications, systems, and tools that are used to create, manage, distribute, use, store, and revoke digital certificates.
- Certificates contain a public key, its purpose, the CA, the validity date range, and the algorithm used to create the signature.
- The certificate store resides on a local computer and stores issued certificates and private keys.
- The PKI CA is a trusted third party that issues PKI certificates to entities and individuals after verifying their identity. It signs these certificates using its private key.
- The certificate database stores all certificates approved by the CA.
PKI Framework
- Facilitates a scalable trust relationship.
- Consists of hardware, software, people, policies, and procedures.
- A registration authority (RA) is a subordinate CA certified by a root CA.
PKI Authorities System
- Vendors provide CA servers as a managed service or product.
- Organizations can implement private PKIs using Microsoft Server or Open SSL.
- CAs issue certificates based on classes (0-5) that indicate the rigor of identity verification; higher classes are more trusted.
PKI Trust System
- Topologies of trust:
- Single-root PKI: A single CA issues all certificates; simple but not scalable and has a single point of failure.
- Cross-certified CA: Peer-to-peer model where CAs establish trust relationships; provides redundancy.
- Hierarchical CA: Root CA issues certificates to subordinate CAs; increased scalability and manageability.
Interoperability
- SSL, IPsec, S/MIME, and EAP-TLS use X.509 certificates.
- The IETF published the Internet X.509 PKI Certificate Policy and Certification Practices Framework (RFC 2527) to address interoperability concerns.
- The X.509 version 3 (X.509 v3) standard defines the format of a digital certificate.
- SSL is the most widely used certificate-based authentication
Certificate Enrollment, Authentication, and Revocation
- Securely obtain a copy of the CA’s public key.
- Systems must have the CA’s public key (self-signed certificate).
- Distribution of CA certificates is often handled automatically (e.g., web browsers).
- The certificate enrollment process is used by a host system to enroll with a PKI.
- CA certificates are retrieved in-band over a network, and the authentication is done OOB using the telephone.
- Only a root CA can issue a self-signed certificate that is recognized or verified by other CAs within the PKI.
- Revocation methods:
- Certification Revocation List (CRL): Invalidate certificates because they expired. A list of revoked certificate serial numbers that have been invalidated because they expired. PKI entities regularly poll the CRL repository to receive the current CRL.
- Online Certificate Status Protocol (OCSP): An internet protocol used to query an OCSP server for the revocation status of an X.509 digital certificate.
Applications and Impacts of Cryptography
PKI Applications
- SSL/TLS certificate-based peer authentication.
- Secure network traffic using IPsec VPNs.
- HTTPS Web traffic.
- Control access to the network using 802.1x authentication.
- Secure email using the S/MIME protocol.
- Secure instant messaging.
- Approve and authorize applications with Code Signing.
- Protect user data with the Encryption File System (EFS).
- Implement two-factor authentication with smart cards.
- Securing USB storage devices.
Encrypted Network Transactions
- SSL/TLS protocols are extensible and modular.
- The cipher suite include:
- MAC algorithm
- Encryption algorithm
- Key exchange algorithm
- Authentication algorithm.
- Algorithms can be changed without replacing the entire protocol.
- Increase of SSL/TLS traffic poses a security risk because the traffic is encrypted and cannot be intercepted and monitored by normal means.
- Users can introduce malware or leak confidential information over an SSL/TLS connection.
- Threat actors can use SSL/TLS to introduce regulatory compliance violations, viruses, malware, data loss, and intrusion attempts in a network.
- PKI-related issues with validating certificates:
- Validity date range: X.509v3 certificates specify "not before" and "not after" dates.
- Signature validation error: The public key is not authentic.Fails if the root certificate of the CA hierarchy is not available in the browser’s certificate store.
Encryption and Security Monitoring
- Network monitoring becomes more challenging when packets are encrypted.
- Configure rules to distinguish between SSL and non-SSL traffic, HTTPS and non-HTTPS SSL traffic.
- Enhance security through server certificate validation using CRLs and OCSP.
- Implement antimalware protection and URL filtering of HTTPS content.
- Deploy a Cisco SSL Appliance to decrypt SSL traffic and send it to IPS appliances to identify risks normally hidden by SSL.
- Attacks can target encryption algorithms themselves.
- Data can be hidden by encrypting it.