Crypt:...lowfish(3pm)

πŸ’– Crypt::Eksblowfish::Uklblowfish β€” Blowfish cipher with unrestricted key length πŸ’–

okay bestie, this is the Crypt:...lowfish(3pm) page from your friendly neighborhood Perl docs, and we are about to get so into it. it's giving "niche crypto module that's weirdly specific," and honestly? obsessed. πŸ’…


✨ NAME ✨

Crypt::Eksblowfish::Uklblowfish β€” the Blowfish cipher, but with unrestricted key length πŸ¦‹


✨ SYNOPSIS ✨

use Crypt::Eksblowfish::Uklblowfish;

$block_size = Crypt::Eksblowfish::Uklblowfish->blocksize;
$key_size = Crypt::Eksblowfish::Uklblowfish->keysize;

$cipher = Crypt::Eksblowfish::Uklblowfish->new($key);

$block_size = $cipher->blocksize;
$ciphertext = $cipher->encrypt($plaintext);
$plaintext = $cipher->decrypt($ciphertext);

$p_array = $cipher->p_array;
$s_boxes = $cipher->s_boxes;
if($cipher->is_weak) { ...

look at that main character code block just existing. 🌈


✨ DESCRIPTION ✨

so. an object of this type encapsulates a keyed instance of the Blowfish block cipher, all ready to encrypt and decrypt. simple, right? BUT β€” and this is the plot twist β€” if you're just looking for an implementation of Blowfish, you most likely want Crypt::Eksblowfish::Blowfish instead. fr fr. this class is the weird one.

what makes it so different? it accepts some keys that Blowfish officially does not permit. that's the whole bit. it's the "hey bestie, technically the rules say no but I'm built different" class. πŸ’…

Blowfish itself is a symmetric cipher algorithm designed by Bruce Schneier in 1993. it operates on 64-bit blocks, and takes a variable-length key. officially the key can vary from 32 bits (4 octets) to 448 bits (56 octets), in increments of 8 bits (1 octet). that's the official tea. β˜•

but here's the thing: in fact the algorithm can easily operate on a key of any number of octets from 1 (8 bits) to 72 (576 bits). the algorithm doesn't care. some implementations don't enforce the official key length limits at all, and so β€” for compatibility β€” it is sometimes necessary to handle a Blowfish key of a prohibited length. and that, bestie, is literally the entire reason this class exists. 🫢

oh and the "Ukl" in the name stands for "unrestricted key length". iykyk. 🌸


🚨 the key length discourse 🚨

using a very short key is generally a bad idea, because there aren't very many keys of that length and so it's easy for an attacker to just... try them all. 😭 the official 32-bit minimum for Blowfish was already far too short for serious security at the time Blowfish was even designed. (a machine built to crack 56-bit DES keys by brute force in a few days each was publicly built only five years later. five!! years!!)

Do not base your security on the secrecy of a short key. periodt.

now, overlong keys have more interesting effects, which depend on internal features of Blowfish. listen closely:

  • when the key exceeds 64 octets (512 bits), varying key bits past that length results in subkeys which have predictable relationships. πŸ‘€
  • there's also some possibility of equivalent keys when the keys exceed 64 octets and differ only in the first 8 octets (64 bits).

these phenomena have not been extensively studied in the open literature, so it's genuinely difficult to judge the degree of cryptographic weakness that results from them. what is clear: beyond some length, Blowfish keys do not have as much strength as their length would suggest, and it's possible that overlong keys have specific weaknesses that render them weaker than shorter keys. if you're choosing a key for security, you're advised to stay within the official length limit of 56 octets. πŸ’€

in summary: using Blowfish keys of officially-unsupported lengths causes security problems. if you're using Blowfish for security, and you have the choice, use a key of an officially-supported length (and a standard implementation such as Crypt::Eksblowfish::Blowfish). use out-of-range key lengths (and this class) only for compatibility or cryptanalytic reasons, bestie. no cap. πŸŽ€


✨ CLASS METHODS ✨

  • Crypt::Eksblowfish::Uklblowfish->blocksize β€” returns 8, indicating the Blowfish block size of 8 octets. this method may be called on either the class or an instance, so do whatever feels right. πŸ’…
  • Crypt::Eksblowfish::Uklblowfish->keysize β€” returns 0, indicating that the key size is variable. this situation is handled specially by Crypt::CBC. iconic behaviour, honestly. ✨

✨ CONSTRUCTOR ✨

  • Crypt::Eksblowfish::Uklblowfish->new(KEY) β€” performs key setup on a new instance of the Blowfish algorithm, and returns the keyed state. the KEY may be any length from 1 octet to 72 octets inclusive. that's the range, bestie, respect it. 🌈

✨ METHODS ✨

  • $cipher->blocksize β€” returns 8, indicating the Blowfish block size of 8 octets. yep, same as the class method. this one may be called on either the class or an instance. consistent queen. πŸ‘‘
  • $cipher->encrypt(PLAINTEXT) β€” PLAINTEXT must be exactly eight octets. the block gets encrypted, and the ciphertext is returned. πŸ¦‹
  • $cipher->decrypt(CIPHERTEXT) β€” CIPHERTEXT must be exactly eight octets. the block gets decrypted, and the plaintext is returned. πŸ¦‹
  • $cipher->p_array
  • $cipher->s_boxes β€” these two extract the subkeys from the keyed cipher. this is not required in ordinary operation, so don't stress about it. see the superclass Crypt::Eksblowfish::Subkeyed for the details. 🌸
  • $cipher->is_weak β€” checks whether the cipher has been keyed with a weak key. it may be desired to avoid using weak keys. see the superclass Crypt::Eksblowfish::Subkeyed for details. πŸ’€
heads up though: this method does not detect any cryptographic weaknesses that might result from the related-key properties and other features of overlong keys. so don't get it twisted, bestie β€” it's not checking those problems for you. πŸ™ˆ

✨ SEE ALSO ✨

  • Crypt::Eksblowfish::Blowfish β€” the normal one. the one you probably actually want. πŸ’–

✨ AUTHOR ✨

Eksblowfish guts originally by Solar Designer (solar at openwall.com). 🫢

Modifications and Perl interface by Andrew Main (Zefram) <zefram@fysh.org>. ✨


Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Andrew Main (Zefram) <zefram@fysh.org>

The original Eksblowfish code (in the form of crypt()) from which this module is derived is in the public domain. it may be found at <http://www.openwall.com/crypt/>. 🌈


✨ LICENSE ✨

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay. πŸ’…


and that's the whole page, bestie!! πŸŽ€ this absolute gem of a doc rides along with perl v5.42.3 and was dated 2026-08-19 β€” that's the version and the date, all folded in at the end like a lil bow. stay keyed, stay safe, and for the love of everything use a key within the official length limit. mwah. πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from