K013 / Symmetric ciphers (block and stream)
CAST-128
CAST-128 (CAST5) is a symmetric block cipher used in various products.
CRYPTOGRAPHY LAB / K013
Cryptography Lab · CAST-128
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
CAST-128 (12/16 rounds)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- CAST-128 (CAST5) is a symmetric block cipher used in various products. Source document ↗
- Classification and reversibility
- A symmetric block cipher providing reversible encryption and decryption. Source document ↗
- Key or secret requirements
- The sender and receiver share the same secret symmetric key. Source document ↗
- Operating principle and structure
- A Feistel structure splits the block into 32-bit halves, processes the right half with a round function and combines it with the left. Source document ↗
- Key size, block size and parameters
- 40–128-bit keys, 64-bit blocks and 12 or 16 rounds. Source document ↗
- Security strength and recommendation
- AES is recommended for new use; CAST-128 is provided only for legacy purposes. Source document ↗
- Known attacks and vulnerabilities
- Deprecated because Sweet32/birthday attacks may become practical after about 2^32 blocks due to the 64-bit block size. Source document ↗
- Standards and certification
- Defined in RFC 2144 and adopted in ISO/IEC 18033-3:2010. Source document ↗
- Typical uses
- Used as the default symmetric cipher in some GPG/PGP versions. Source document ↗
- Implementations, libraries and tools
- CAST5 can be implemented or used with Bouncy Castle. Source document ↗
- Decryption or decoding
- Decryption follows the encryption procedure with the 16 subkey pairs in reverse order. Source document ↗
- Advantages
- Described as having good resistance to differential, linear and related-key analysis. Source document ↗
- Limitations and cautions
- Not broken in ordinary use, but old; avoid in new systems and use only for legacy compatibility. Source document ↗
- Distinguishing encryption, encoding and hashing
- CAST-128 is symmetric encryption, not encoding or hashing; it provides confidentiality only, so add a MAC when authentication is needed. Source document ↗
Practical examples
Example
Input plaintext blocks and a symmetric key to obtain 64-bit CAST-128 ciphertext blocks. Combine with a mode such as CBC and IV if needed; decrypt with the same key and mode information.
Procedure
Encryption: choose padding/mode/IV, encrypt plaintext with CAST-128 and symmetric key. Decryption: decrypt with same key/IV/mode, remove padding and recover plaintext. Base64 is a representation transformation, not encryption.
Scenario
Typically limited to decryption or integration for legacy PGP/GPG and older systems. Use modern ciphers and authenticated modes for new designs.
Pitfalls and alternatives
Considering Sweet32 risk and legacy status, prioritize AES-GCM or ChaCha20-Poly1305. If compatibility is unavoidable, apply encrypt-then-MAC and distinguish encryption from encoding and hashing.
References
- CAST-128 ↗
- Symmetric encryption ↗
- CAST5 (ECB) - @agntn/ciphers ↗
- Symmetric Cryptography — Expanded Algorithm Tutorial | Chuck Easttom ↗
- CAST-128 - PyCryptodome ↗
- CAST5-128 Cryptanalysis & Best Known Attacks | Security Margin · CryptArena ↗
- Is CAST5 still a secure algorithm to use? ↗
- The Apache Groovy programming language - Blogs - Encryption and decryption with Groovy® ↗
- The CAST-128 Algorithm: Interactive Visualizer ↗
- RFC 2144: The CAST-128 Encryption Algorithm | RFC Editor ↗
- CAST Encrypt and Decrypt Online | encode-decode.com ↗