Crypt::Present - Perl extension for Ultra-Lightweight PRESENT 64 bit block encryption module
use Crypt::Present; my $cipher = new Crypt::Present $key; my $ciphertext = $cipher->encrypt($plaintext); my $plaintext = $cipher->decrypt($ciphertext); You probably want to use this in conjunction with a block chaining module like Crypt::CBC.
Present is a ultra lightweight block encryption and can use key sizes of 80 or 128 bit (10 or 16 byte key). It is developed for use in RFID hardware with minimum numer of cricuits.
Crypt::Present has the following methods:
blocksize() keysize() encrypt() decrypt()
Returns the size (in bytes) of the block cipher.
Crypt::Present::keysize returns [ 10, 16 ] due to its ability to use 10 or 16 byte keys.b More accurately, it shouldn't, but it does anyway to play nicely with others.
my $cipher = new Crypt::Present $key;
This creates a new Crypt::Present BlockCipher object, using $key, where $key is a key of keysize() bytes (10 or 16 bytes).
keysize()
my $cipher = new Crypt::Present $key; my $ciphertext = $cipher->encrypt($plaintext);
This function encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext must be of blocksize() bytes. (hint: Present is an 8 byte block cipher)
blocksize()
my $cipher = new Crypt::Present $key; my $plaintext = $cipher->decrypt($ciphertext);
This function decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext must be of blocksize() bytes. (hint: see previous hint)
my $key = pack("H20", "0123456789"); # min. 8 bytes my $cipher = new Crypt::Present $key; my $ciphertext = $cipher->encrypt("plaintex"); # SEE NOTES print unpack("H16", $ciphertext), "\n";
Since this is non endianess pure perl code, it will run under all plattforms.
The module is capable of being used with Crypt::CBC. You're encouraged to read the perldoc for Crypt::CBC if you intend to use this module for Cipher Block Chaining modes. In fact, if you have any intentions of encrypting more than eight bytes of data with this, or any other block cipher, you're going to need some type of block chaining help. Crypt::CBC tends to be very good at this. If you're not going to encrypt more than eight bytes, your data must be exactly eight bytes long. If need be, do your own padding. "\0" as a null byte is perfectly valid to use for this.
PRESENT: An Ultra-Lightweight Block Cipher A. Bogdanov1, L.R. Knudsen2 , G. Leander1 , C. Paar1, A. Poschmann1, M.J.B. Robshaw3 , Y. Seurin3 , and C. Vikkelsoe2 1 Horst-Görtz-Institute for IT-Security, Ruhr-University Bochum, Germany 2 Technical University Denmark, DK-2800 Kgs. Lyngby, Denmark 3 France Telecom R&D, Issy les Moulineaux, France
leander@rub.de, {abogdanov,cpaar,poschmann}@crypto.rub.de lars@ramkilde.com, chv@mat.dtu.dk {matt.robshaw,yannick.seurin}@orange-ftgroup.com http://www.emsec.rub.de/media/crypto/attachments/files/2010/04/present_ches2007.pdf
Crypt::CBC
The implementation of the Present algorithm was developed by, and is copyright of, Eduard Gode.
Original algorithm, A. Bogdanov1, L.R. Knudsen2 , G. Leander1 , C. Paar1, A. Poschmann1, M.J.B. Robshaw3 , Y. Seurin3 , and C. Vikkelsoe2.
Original implementation, Eduard Gode.
Current revision and maintainer: Gduard Gode <eduard.gode@gode.de>
Copyright (C) 2012 by Eduard Gode
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Horst-Görtz-Institute'. Assuming CP1252
To install Crypt::Present, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::Present
CPAN shell
perl -MCPAN -e shell install Crypt::Present
For more information on module installation, please visit the detailed CPAN module installation guide.