Steffen Schwigon
and 1 contributors

NAME

Crypt::OpenBSD::Blowfish - Perl extension for the OpenBSD Blowfish cipher implementation.

SYNOPSIS

  use Crypt::OpenBSD::Blowfish;
  my $bf = Crypt::OpenBSD::Blowfish->new($key);
  my $encrypted = $bf->encrypt$data);
  ...
  my $decrypted = $bf->decrypt($encrypted);

or to create key material:

  use Crypt::OpenBSD::Blowfish;
  my $bf = Crypt::OpenBSD::Blowfish->new();
  $bf->expandstate($salt,$pass);
  foreach (1..64) {
     $bf->expand0state($salt);
     $bf->expand0state($pass);
  }
  $key_material = $bf->encrypt_iterate($data,64);

DESCRIPTION

This module is a wrapper for the OpenBSD implementation of the Blowfish cipher. The C source is taken from the portable OpenSSH source code.

CLASS METHODS

Crypt::OpenBSD::Blowfish->blocksize

Returns 8, as the Blowfish block size is eight octets.

Crypt::OpenBSD::Blowfish->keysize

Returns 0, as the Blowfish key size is variable.

CONSTRUCTOR

$bf = Crypt::OpenBSD::Blowfish->new()

$bf = Crypt::OpenBSD::Blowfish->new($key)

Returns a Crypt::OpenBSD::Blowfish object. Passing a key will transform the S-boxes and subkeys with the key.

METHODS

$cipher->blocksize

Returns 8. Blowfish uses an eight-octet block size. May be called via either a class method or object method.

$encrypted = $cipher->encrypt($data)

Encrypt $data, which must be in 8-byte chunks.

$decrypted = $cipher->decrypt($data)

Decrypt $data, which must be in 8-byte chunks.

$cipher->expandstate($data,$key)

Expand the subkeys using data (salt) and a key.

$cipher->expand0state($key)

Expand the subkeys using key.

$encrypted = $bf->encrypt_iterate($data,$rounds)

Iteratively encrypt $data for $rounds rounds. Useful for creating key material for a password function.

EXPORT

None by default.

SEE ALSO

Git Hub home: https://github.com/lkinley/Crypt-OpenBSD-Blowfish/

AUTHOR

Lance Kinley, <lkinley@loyaltymethods.com>

COPYRIGHT AND LICENSE

Copyright (C) 2015 by Lance Kinley/Loyalty Methods, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.