Involved Source Filesblock.go
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
Blowfish is a legacy cipher and its short block size makes it vulnerable to
birthday bound attacks (see https://sweet32.info). It should only be used
where compatibility with legacy systems, not security, is the goal.
Deprecated: any new system should use AES (from crypto/aes, if necessary in
an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
golang.org/x/crypto/chacha20poly1305).
const.go
Package-Level Type Names (total 2, both are exported)
/* sort exporteds by: | */
A Cipher is an instance of Blowfish encryption using a particular key.
p[18]uint32s0[256]uint32s1[256]uint32s2[256]uint32s3[256]uint32
BlockSize returns the Blowfish block size, 8 bytes.
It is necessary to satisfy the Block interface in the
package "crypto/cipher".
Decrypt decrypts the 8-byte buffer src using the key k
and stores the result in dst.
Encrypt encrypts the 8-byte buffer src using the key k
and stores the result in dst.
Note that for amounts of data larger than a block,
it is not safe to just call Encrypt on successive blocks;
instead, use an encryption mode like CBC (see crypto/cipher/cbc.go).
*T : crypto/cipher.Block
func NewCipher(key []byte) (*Cipher, error)
func NewSaltedCipher(key, salt []byte) (*Cipher, error)
func ExpandKey(key []byte, c *Cipher)
func decryptBlock(l, r uint32, c *Cipher) (uint32, uint32)
func encryptBlock(l, r uint32, c *Cipher) (uint32, uint32)
func expandKeyWithSalt(key []byte, salt []byte, c *Cipher)
func initCipher(c *Cipher)
Package-Level Functions (total 8, in which 3 are exported)
ExpandKey performs a key expansion on the given *Cipher. Specifically, it
performs the Blowfish algorithm's key schedule which sets up the *Cipher's
pi and substitution tables for calls to Encrypt. This is used, primarily,
by the bcrypt package to reuse the Blowfish key schedule during its
set up. It's unlikely that you need to use this directly.
NewCipher creates and returns a Cipher.
The key argument should be the Blowfish key, from 1 to 56 bytes.
NewSaltedCipher creates a returns a Cipher that folds a salt into its key
schedule. For most purposes, NewCipher, instead of NewSaltedCipher, is
sufficient and desirable. For bcrypt compatibility, the key can be over 56
bytes.
This is similar to ExpandKey, but folds the salt during the key
schedule. While ExpandKey is essentially expandKeyWithSalt with an all-zero
salt passed in, reusing ExpandKey turns out to be a place of inefficiency
and specializing it here is useful.
getNextWord returns the next big-endian uint32 value from the byte slice
at the given position in a circular manner, updating the position.
Package-Level Constants (only one, which is exported)
The Blowfish block size in bytes.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.