The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Crypt::PBE::PBKDF1 - Perl extension for PKCS #5 Password-Based Key Derivation Function 1 (PBKDF1)

SYNOPSIS

    use Crypt::PBE::PBKDF1;

    # OO style

    my $pbkdf1 = Crypt::PBE::PBKDF1->new(
        password   => $password,
        salt       => $salt,
        hash       => 'sha1'
    );

    $pbkdf1->derived_key;           # Byte
    $pbkdf1->derived_key_base64     # Base64 encoded
    $pbkdf1->derived_key_hex        # Hex


    use Crypt::PBE::PBKDF1 qw(pbkdf1_md2 pbkdf1_md5_base64 pbkdf1_sha1_hex);

    # Functional style

    $derived_key = pbkdf1 ( %params );           # Byte
    $derived_key = pbkdf1_base64 ( %params );    # Base64 encoded
    $derived_key = pbkdf1_hex ( %params );       # Hex

    # Functional style helpers
    $derived_key = pbkdf1_md2 ( %params );
    $derived_key = pbkdf1_md2_hex ( %params );
    $derived_key = pbkdf1_md2_base64 ( %params );

    $derived_key = pbkdf1_md5 ( %params );
    $derived_key = pbkdf1_md5_hex ( %params );
    $derived_key = pbkdf1_md5_base64 ( %params );

    $derived_key = pbkdf1_sha1 ( %params );
    $derived_key = pbkdf1_sha1_hex ( %params );
    $derived_key = pbkdf1_sha1_base64 ( %params );

DESCRIPTION

PBKDF2 applies a pseudorandom function, such as hash-based message authentication code (HMAC), to the input password or passphrase along with a salt value and repeats the process many times to produce a derived key, which can then be used as a cryptographic key in subsequent operations.

CONSTRUCTOR

Crypt::PBE::PBKDF1->new ( %params )

Params:

  • password : The password to use for the derivation

  • salt : The salt to use for the derivation. This value should be generated randomly.

  • hash : Hash algorithm (default "sha1")

  • count : The number of internal iteractions to perform for the derivation key (default "1_000")

METHODS

$pbkdf1->derived_key

Return the derived key in raw output (byte).

$pbkdf1->derived_key_base64

Return the derived key in Base64 encoded format.

$pbkdf1->derived_key_hex

Return the derived key in HEX format.

$pbkdf2->hash

Return the hash name.

$pbkdf2->count

Return the iteration count number.

$pbkdf2->derived_key_length

Return the derived key length.

FUNCTIONS

pbkdf1 ( hash => ..., password => ..., salt => ..., [ count => 1_000, dk_len => 0 ] )

Return derived key using PBKDF1 function:

    my $derived_key = pbkdf1 (
        hash     => 'sha1',
        password => 'mypassword',
        salt     => my_random_byte_sub(), 
        count    => 2_000
    );

    print length($derived_key)      # 20

pbkdf1_base64 ( hash => ..., password => ..., salt => ..., [ count => 1_000, dk_len => 0 ] )

Return derived key in Base64 using PBKDF1 function.

pbkdf1_hex ( hash => ..., password => ..., salt => ..., [ count => 1_000, dk_len => 0 ] )

Return derived key in HEX using PBKDF1 function.

EXPORTABLE HELPER FUNCTIONS

Return the derived key using MD2, MD5 and SHA1 digest:

pbkdf1_md2
pbkdf1_md5
pbkdf1_sha1

Return the derived key using MD2, MD5 and SHA1 digest in Base64:

pbkdf1_md2_base64
pbkdf1_md5_base64
pbkdf1_sha1_base64

Return the derived key using MD2, MD5 and SHA1 digest in HEX:

pbkdf1_md2_hex
pbkdf1_md5_hex
pbkdf1_sha1_hex

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/giterlizzi/perl-Crypt-PBE/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/giterlizzi/perl-Crypt-PBE

    git clone https://github.com/giterlizzi/perl-Crypt-PBE.git

AUTHOR

  • Giuseppe Di Terlizzi <gdt@cpan.org>

SEE ALSO

Crypt::PBE::PBKDF2
[RFC2898] PKCS #5: Password-Based Cryptography Specification Version 2.0 (https://tools.ietf.org/html/rfc2898)
[RFC8018] PKCS #5: Password-Based Cryptography Specification Version 2.1 (https://tools.ietf.org/html/rfc8018)

LICENSE AND COPYRIGHT

This software is copyright (c) 2020-2023 by Giuseppe Di Terlizzi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.