Package list libcryptx-perl / upstream/0.070
New upstream version 0.070 gregor herrmann 8 months ago
210 changed file(s) with 1115 addition(s) and 1059 deletion(s). Raw diff Collapse all Expand all
00 Changes for CryptX
1
2 0.070 2021-02-12
3 - fix #66 remove -flto=auto (Makefile.PL)
4 - fix #65 typo in docs (lib/Crypt/Cipher.pm)
5 - bundled libtomcrypt update branch:develop (commit:910d6252 2021-01-19)
16
27 0.069 2020-08-25
38 - fix #64 ECC: segfault on invalid input
33 "Karel Miko"
44 ],
55 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010",
6 "generated_by" : "ExtUtils::MakeMaker version 7.58, CPAN::Meta::Converter version 2.150010",
77 "license" : [
88 "perl_5"
99 ],
4949 "url" : "https://github.com/DCIT/perl-CryptX"
5050 }
5151 },
52 "version" : "0.069",
52 "version" : "0.070",
5353 "x_serialization_backend" : "JSON::PP version 4.05"
5454 }
77 configure_requires:
88 ExtUtils::MakeMaker: '0'
99 dynamic_config: 1
10 generated_by: 'ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010'
10 generated_by: 'ExtUtils::MakeMaker version 7.58, CPAN::Meta::Converter version 2.150010'
1111 license: perl
1212 meta-spec:
1313 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2222 resources:
2323 bugtracker: https://github.com/DCIT/perl-CryptX/issues
2424 repository: https://github.com/DCIT/perl-CryptX
25 version: '0.069'
25 version: '0.070'
2626 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
3131 $mycflags .= " $ENV{CPPFLAGS}" if $ENV{CPPFLAGS};
3232
3333 #FIX: gcc with -flto is a trouble maker see https://github.com/DCIT/perl-CryptX/issues/32
34 #FIX: another issue with "-flto=auto" see https://github.com/DCIT/perl-CryptX/pull/66
35 $mycflags =~ s/-flto=[a-zA-Z0-9]+//g; # -flto=auto -flto=jobserver -flto=N ...
3436 $mycflags =~ s/-flto\b//g;
3537
3638 #FIX: avoid -Wwrite-strings -Wcast-qual -pedantic -pedantic-errors -ansi -std=c89
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 ### not used
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::Checksum Exporter);
77 our %EXPORT_TAGS = ( all => [qw( adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::Checksum Exporter);
77 our %EXPORT_TAGS = ( all => [qw( crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Cipher);
99
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
9595
9696 Decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of B<blocksize> bytes.
9797
98 $plaintext = $d->encrypt($ciphertext);
98 $plaintext = $d->decrypt($ciphertext);
9999
100100 =head2 keysize
101101
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( chaes chaes_hex chaes_b64 chaes_b64u chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak384 keccak384_hex keccak384_b64 keccak384_b64u keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak512 keccak512_hex keccak512_b64 keccak512_b64u keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( md2 md2_hex md2_b64 md2_b64u md2_file md2_file_hex md2_file_b64 md2_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( md4 md4_hex md4_b64 md4_b64u md4_file md4_file_hex md4_file_b64 md4_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( md5 md5_hex md5_b64 md5_b64u md5_file md5_file_hex md5_file_b64 md5_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha1 sha1_hex sha1_b64 sha1_b64u sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha224 sha224_hex sha224_b64 sha224_b64u sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha256 sha256_hex sha256_b64 sha256_b64u sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha384 sha384_hex sha384_b64 sha384_b64u sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha512 sha512_hex sha512_b64 sha512_b64u sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha512_224 sha512_224_hex sha512_224_b64 sha512_224_b64u sha512_224_file sha512_224_file_hex sha512_224_file_b64 sha512_224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( tiger192 tiger192_hex tiger192_b64 tiger192_b64u tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw(pbkdf1 pbkdf2 hkdf hkdf_expand hkdf_extract)] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b blake2b_hex blake2b_b64 blake2b_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( f9 f9_hex f9_b64 f9_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( hmac hmac_hex hmac_b64 hmac_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 omac_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( pmac pmac_hex pmac_b64 pmac_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( pelican pelican_hex pelican_b64 pelican_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( poly1305 poly1305_hex poly1305_b64 poly1305_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 xcbc_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 use Carp 'croak';
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.069';
6 our $VERSION = '0.070';
77
88 use Crypt::Cipher;
99
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 ### not used
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( dh_shared_secret )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( dsa_encrypt dsa_decrypt dsa_sign_message dsa_verify_message dsa_sign_hash dsa_verify_hash )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( ecc_encrypt ecc_decrypt ecc_sign_message ecc_verify_message ecc_sign_hash ecc_verify_hash ecc_shared_secret )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw(rsa_encrypt rsa_decrypt rsa_sign_message rsa_verify_message rsa_sign_hash rsa_verify_hash)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw( )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use Carp;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings ;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 require XSLoader;
77 XSLoader::load('CryptX', $VERSION);
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.069';
4 our $VERSION = '0.070';
55
66 use CryptX;
77 use Carp;
7979
8080 #endif
8181
82 #define __LTC_AES_TAB_C__
82 #define LTC_AES_TAB_C
8383 #include "aes_tab.c"
8484
8585 static ulong32 setup_mix(ulong32 temp)
274274 @return CRYPT_OK if successful
275275 */
276276 #ifdef LTC_CLEAN_STACK
277 static int _rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
277 static int s_rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
278278 #else
279279 int ECB_ENC(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
280280 #endif
442442 #ifdef LTC_CLEAN_STACK
443443 int ECB_ENC(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
444444 {
445 int err = _rijndael_ecb_encrypt(pt, ct, skey);
445 int err = s_rijndael_ecb_encrypt(pt, ct, skey);
446446 burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2);
447447 return err;
448448 }
458458 @return CRYPT_OK if successful
459459 */
460460 #ifdef LTC_CLEAN_STACK
461 static int _rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
461 static int s_rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
462462 #else
463463 int ECB_DEC(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
464464 #endif
627627 #ifdef LTC_CLEAN_STACK
628628 int ECB_DEC(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
629629 {
630 int err = _rijndael_ecb_decrypt(ct, pt, skey);
630 int err = s_rijndael_ecb_decrypt(ct, pt, skey);
631631 burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2);
632632 return err;
633633 }
1414 Td4[x] = Si[x].[01, 01, 01, 01];
1515 */
1616
17 #ifdef __LTC_AES_TAB_C__
17 #ifdef LTC_AES_TAB_C
1818
1919 /**
2020 @file aes_tab.c
10181018 };
10191019 #endif
10201020
1021 #endif /* __LTC_AES_TAB_C__ */
1021 #endif /* LTC_AES_TAB_C */
875875 @return CRYPT_OK if successful
876876 */
877877 #ifdef LTC_CLEAN_STACK
878 static int _anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
878 static int s_anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
879879 #else
880880 int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
881881 #endif
10121012 int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
10131013 {
10141014 int err;
1015 err = _anubis_setup(key, keylen, num_rounds, skey);
1015 err = s_anubis_setup(key, keylen, num_rounds, skey);
10161016 burn_stack(sizeof(int) * 5 + sizeof(ulong32) * (MAX_N + MAX_N + 5));
10171017 return err;
10181018 }
471471 @return CRYPT_OK if successful
472472 */
473473 #ifdef LTC_CLEAN_STACK
474 static int _blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
474 static int s_blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
475475 #else
476476 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
477477 #endif
498498 #ifdef LTC_CLEAN_STACK
499499 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
500500 {
501 int err = _blowfish_ecb_encrypt(pt, ct, skey);
501 int err = s_blowfish_ecb_encrypt(pt, ct, skey);
502502 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
503503 return err;
504504 }
512512 @return CRYPT_OK if successful
513513 */
514514 #ifdef LTC_CLEAN_STACK
515 static int _blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
515 static int s_blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
516516 #else
517517 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
518518 #endif
559559 #ifdef LTC_CLEAN_STACK
560560 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
561561 {
562 int err = _blowfish_ecb_decrypt(ct, pt, skey);
562 int err = s_blowfish_ecb_decrypt(ct, pt, skey);
563563 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
564564 return err;
565565 }
397397 @return CRYPT_OK if successful
398398 */
399399 #ifdef LTC_CLEAN_STACK
400 static int _cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
400 static int s_cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
401401 #else
402402 int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
403403 #endif
484484 int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
485485 {
486486 int z;
487 z = _cast5_setup(key, keylen, num_rounds, skey);
487 z = s_cast5_setup(key, keylen, num_rounds, skey);
488488 burn_stack(sizeof(ulong32)*8 + 16 + sizeof(int)*2);
489489 return z;
490490 }
491491 #endif
492492
493 #ifdef _MSC_VER
494 #define INLINE __inline
495 #else
496 #define INLINE
497 #endif
498
499 INLINE static ulong32 FI(ulong32 R, ulong32 Km, ulong32 Kr)
493 LTC_INLINE static ulong32 FI(ulong32 R, ulong32 Km, ulong32 Kr)
500494 {
501495 ulong32 I;
502496 I = (Km + R);
504498 return ((S1[LTC_BYTE(I, 3)] ^ S2[LTC_BYTE(I,2)]) - S3[LTC_BYTE(I,1)]) + S4[LTC_BYTE(I,0)];
505499 }
506500
507 INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr)
501 LTC_INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr)
508502 {
509503 ulong32 I;
510504 I = (Km ^ R);
512506 return ((S1[LTC_BYTE(I, 3)] - S2[LTC_BYTE(I,2)]) + S3[LTC_BYTE(I,1)]) ^ S4[LTC_BYTE(I,0)];
513507 }
514508
515 INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr)
509 LTC_INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr)
516510 {
517511 ulong32 I;
518512 I = (Km - R);
527521 @param skey The key as scheduled
528522 */
529523 #ifdef LTC_CLEAN_STACK
530 static int _cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
524 static int s_cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
531525 #else
532526 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
533527 #endif
567561 #ifdef LTC_CLEAN_STACK
568562 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
569563 {
570 int err =_cast5_ecb_encrypt(pt,ct,skey);
564 int err = s_cast5_ecb_encrypt(pt,ct,skey);
571565 burn_stack(sizeof(ulong32)*3);
572566 return err;
573567 }
580574 @param skey The key as scheduled
581575 */
582576 #ifdef LTC_CLEAN_STACK
583 static int _cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
577 static int s_cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
584578 #else
585579 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
586580 #endif
620614 #ifdef LTC_CLEAN_STACK
621615 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
622616 {
623 int err = _cast5_ecb_decrypt(ct,pt,skey);
617 int err = s_cast5_ecb_decrypt(ct,pt,skey);
624618 burn_stack(sizeof(ulong32)*3);
625619 return err;
626620 }
12921292 static void cookey(const ulong32 *raw1, ulong32 *keyout);
12931293
12941294 #ifdef LTC_CLEAN_STACK
1295 static void _deskey(const unsigned char *key, short edf, ulong32 *keyout)
1295 static void s_deskey(const unsigned char *key, short edf, ulong32 *keyout)
12961296 #else
12971297 static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
12981298 #endif
13461346 #ifdef LTC_CLEAN_STACK
13471347 static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
13481348 {
1349 _deskey(key, edf, keyout);
1349 s_deskey(key, edf, keyout);
13501350 burn_stack(sizeof(int)*5 + sizeof(ulong32)*32 + sizeof(unsigned char)*112);
13511351 }
13521352 #endif
13531353
13541354 #ifdef LTC_CLEAN_STACK
1355 static void _cookey(const ulong32 *raw1, ulong32 *keyout)
1355 static void s_cookey(const ulong32 *raw1, ulong32 *keyout)
13561356 #else
13571357 static void cookey(const ulong32 *raw1, ulong32 *keyout)
13581358 #endif
13821382 #ifdef LTC_CLEAN_STACK
13831383 static void cookey(const ulong32 *raw1, ulong32 *keyout)
13841384 {
1385 _cookey(raw1, keyout);
1385 s_cookey(raw1, keyout);
13861386 burn_stack(sizeof(ulong32 *) * 2 + sizeof(ulong32)*32 + sizeof(int));
13871387 }
13881388 #endif
13901390 #ifndef LTC_CLEAN_STACK
13911391 static void desfunc(ulong32 *block, const ulong32 *keys)
13921392 #else
1393 static void _desfunc(ulong32 *block, const ulong32 *keys)
1393 static void s_desfunc(ulong32 *block, const ulong32 *keys)
13941394 #endif
13951395 {
13961396 ulong32 work, right, leftt;
15041504 #ifdef LTC_CLEAN_STACK
15051505 static void desfunc(ulong32 *block, const ulong32 *keys)
15061506 {
1507 _desfunc(block, keys);
1507 s_desfunc(block, keys);
15081508 burn_stack(sizeof(ulong32) * 4 + sizeof(int));
15091509 }
15101510 #endif
3434
3535 typedef unsigned short int ushort16;
3636
37 #define _LOW16(x) ((x)&0xffff) /* compiler should be able to optimize this away if x is 16 bits */
38 #define _HIGH16(x) ((x)>>16)
39 #define _MUL(a,b) { \
40 ulong32 p = (ulong32)_LOW16(a) * b; \
37 #define LOW16(x) ((x)&0xffff) /* compiler should be able to optimize this away if x is 16 bits */
38 #define HIGH16(x) ((x)>>16)
39 #define MUL(a,b) { \
40 ulong32 p = (ulong32)LOW16(a) * b; \
4141 if (p) { \
42 p = _LOW16(p) - _HIGH16(p); \
43 a = (ushort16)p - (ushort16)_HIGH16(p); \
42 p = LOW16(p) - HIGH16(p); \
43 a = (ushort16)p - (ushort16)HIGH16(p); \
4444 } \
4545 else \
4646 a = 1 - a - b; \
4747 }
48 #define _STORE16(x,y) { (y)[0] = (unsigned char)(((x)>>8)&255); (y)[1] = (unsigned char)((x)&255); }
49 #define _LOAD16(x,y) { x = ((ushort16)((y)[0] & 255)<<8) | ((ushort16)((y)[1] & 255)); }
50
51 static ushort16 _mul_inv(ushort16 x)
48 #define STORE16(x,y) { (y)[0] = (unsigned char)(((x)>>8)&255); (y)[1] = (unsigned char)((x)&255); }
49 #define LOAD16(x,y) { x = ((ushort16)((y)[0] & 255)<<8) | ((ushort16)((y)[1] & 255)); }
50
51 static ushort16 s_mul_inv(ushort16 x)
5252 {
5353 ushort16 y = x;
5454 unsigned i;
5555
5656 for (i = 0; i < 15; i++) {
57 _MUL(y, _LOW16(y));
58 _MUL(y, x);
59 }
60 return _LOW16(y);
61 }
62
63 static ushort16 _add_inv(ushort16 x)
64 {
65 return _LOW16(0 - x);
66 }
67
68 static int _setup_key(const unsigned char *key, symmetric_key *skey)
57 MUL(y, LOW16(y));
58 MUL(y, x);
59 }
60 return LOW16(y);
61 }
62
63 static ushort16 s_add_inv(ushort16 x)
64 {
65 return LOW16(0 - x);
66 }
67
68 static int s_setup_key(const unsigned char *key, symmetric_key *skey)
6969 {
7070 int i, j;
7171 ushort16 *e_key = skey->idea.ek;
7373
7474 /* prepare enc key */
7575 for (i = 0; i < 8; i++) {
76 _LOAD16(e_key[i], key + 2 * i);
76 LOAD16(e_key[i], key + 2 * i);
7777 }
7878 for (; i < LTC_IDEA_KEYLEN; i++) {
7979 j = (i - i % 8) - 8;
80 e_key[i] = _LOW16((e_key[j+(i+1)%8] << 9) | (e_key[j+(i+2)%8] >> 7));
80 e_key[i] = LOW16((e_key[j+(i+1)%8] << 9) | (e_key[j+(i+2)%8] >> 7));
8181 }
8282
8383 /* prepare dec key */
8484 for (i = 0; i < LTC_IDEA_ROUNDS; i++) {
85 d_key[i*6+0] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]);
86 d_key[i*6+1] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1+(i>0 ? 1 : 0)]);
87 d_key[i*6+2] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2-(i>0 ? 1 : 0)]);
88 d_key[i*6+3] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]);
89 d_key[i*6+4] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+4];
90 d_key[i*6+5] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+5];
91 }
92 d_key[i*6+0] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]);
93 d_key[i*6+1] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1]);
94 d_key[i*6+2] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2]);
95 d_key[i*6+3] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]);
96
97 return CRYPT_OK;
98 }
99
100 static int _process_block(const unsigned char *in, unsigned char *out, const ushort16 *m_key)
85 d_key[i*6+0] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]);
86 d_key[i*6+1] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1+(i>0 ? 1 : 0)]);
87 d_key[i*6+2] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2-(i>0 ? 1 : 0)]);
88 d_key[i*6+3] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]);
89 d_key[i*6+4] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+4];
90 d_key[i*6+5] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+5];
91 }
92 d_key[i*6+0] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]);
93 d_key[i*6+1] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1]);
94 d_key[i*6+2] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2]);
95 d_key[i*6+3] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]);
96
97 return CRYPT_OK;
98 }
99
100 static int s_process_block(const unsigned char *in, unsigned char *out, const ushort16 *m_key)
101101 {
102102 int i;
103103 ushort16 x0, x1, x2, x3, t0, t1;
104104
105 _LOAD16(x0, in + 0);
106 _LOAD16(x1, in + 2);
107 _LOAD16(x2, in + 4);
108 _LOAD16(x3, in + 6);
105 LOAD16(x0, in + 0);
106 LOAD16(x1, in + 2);
107 LOAD16(x2, in + 4);
108 LOAD16(x3, in + 6);
109109
110110 for (i = 0; i < LTC_IDEA_ROUNDS; i++) {
111 _MUL(x0, m_key[i*6+0]);
111 MUL(x0, m_key[i*6+0]);
112112 x1 += m_key[i*6+1];
113113 x2 += m_key[i*6+2];
114 _MUL(x3, m_key[i*6+3]);
114 MUL(x3, m_key[i*6+3]);
115115 t0 = x0^x2;
116 _MUL(t0, m_key[i*6+4]);
116 MUL(t0, m_key[i*6+4]);
117117 t1 = t0 + (x1^x3);
118 _MUL(t1, m_key[i*6+5]);
118 MUL(t1, m_key[i*6+5]);
119119 t0 += t1;
120120 x0 ^= t1;
121121 x3 ^= t0;
124124 x2 = t0;
125125 }
126126
127 _MUL(x0, m_key[LTC_IDEA_ROUNDS*6+0]);
127 MUL(x0, m_key[LTC_IDEA_ROUNDS*6+0]);
128128 x2 += m_key[LTC_IDEA_ROUNDS*6+1];
129129 x1 += m_key[LTC_IDEA_ROUNDS*6+2];
130 _MUL(x3, m_key[LTC_IDEA_ROUNDS*6+3]);
131
132 _STORE16(x0, out + 0);
133 _STORE16(x2, out + 2);
134 _STORE16(x1, out + 4);
135 _STORE16(x3, out + 6);
130 MUL(x3, m_key[LTC_IDEA_ROUNDS*6+3]);
131
132 STORE16(x0, out + 0);
133 STORE16(x2, out + 2);
134 STORE16(x1, out + 4);
135 STORE16(x3, out + 6);
136136
137137 return CRYPT_OK;
138138 }
145145 if (num_rounds != 0 && num_rounds != 8) return CRYPT_INVALID_ROUNDS;
146146 if (keylen != 16) return CRYPT_INVALID_KEYSIZE;
147147
148 return _setup_key(key, skey);
148 return s_setup_key(key, skey);
149149 }
150150
151151 int idea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
152152 {
153 int err = _process_block(pt, ct, skey->idea.ek);
153 int err = s_process_block(pt, ct, skey->idea.ek);
154154 #ifdef LTC_CLEAN_STACK
155155 burn_stack(sizeof(ushort16) * 6 + sizeof(int));
156156 #endif
159159
160160 int idea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
161161 {
162 int err = _process_block(ct, pt, skey->idea.dk);
162 int err = s_process_block(ct, pt, skey->idea.dk);
163163 #ifdef LTC_CLEAN_STACK
164164 burn_stack(sizeof(ushort16) * 6 + sizeof(int));
165165 #endif
88
99 #ifdef LTC_MULTI2
1010
11 static void pi1(ulong32 *p)
11 static void s_pi1(ulong32 *p)
1212 {
1313 p[1] ^= p[0];
1414 }
1515
16 static void pi2(ulong32 *p, const ulong32 *k)
16 static void s_pi2(ulong32 *p, const ulong32 *k)
1717 {
1818 ulong32 t;
1919 t = (p[1] + k[0]) & 0xFFFFFFFFUL;
2222 p[0] ^= t;
2323 }
2424
25 static void pi3(ulong32 *p, const ulong32 *k)
25 static void s_pi3(ulong32 *p, const ulong32 *k)
2626 {
2727 ulong32 t;
2828 t = p[0] + k[1];
3434 p[1] ^= t;
3535 }
3636
37 static void pi4(ulong32 *p, const ulong32 *k)
37 static void s_pi4(ulong32 *p, const ulong32 *k)
3838 {
3939 ulong32 t;
4040 t = (p[1] + k[3]) & 0xFFFFFFFFUL;
4242 p[0] ^= t;
4343 }
4444
45 static void setup(const ulong32 *dk, const ulong32 *k, ulong32 *uk)
45 static void s_setup(const ulong32 *dk, const ulong32 *k, ulong32 *uk)
4646 {
4747 int n, t;
4848 ulong32 p[2];
5151
5252 t = 4;
5353 n = 0;
54 pi1(p);
55 pi2(p, k);
54 s_pi1(p);
55 s_pi2(p, k);
5656 uk[n++] = p[0];
57 pi3(p, k);
57 s_pi3(p, k);
5858 uk[n++] = p[1];
59 pi4(p, k);
59 s_pi4(p, k);
6060 uk[n++] = p[0];
61 pi1(p);
61 s_pi1(p);
6262 uk[n++] = p[1];
63 pi2(p, k+t);
63 s_pi2(p, k+t);
6464 uk[n++] = p[0];
65 pi3(p, k+t);
65 s_pi3(p, k+t);
6666 uk[n++] = p[1];
67 pi4(p, k+t);
67 s_pi4(p, k+t);
6868 uk[n++] = p[0];
69 pi1(p);
69 s_pi1(p);
7070 uk[n++] = p[1];
7171 }
7272
73 static void encrypt(ulong32 *p, int N, const ulong32 *uk)
73 static void s_encrypt(ulong32 *p, int N, const ulong32 *uk)
7474 {
7575 int n, t;
7676 for (t = n = 0; ; ) {
77 pi1(p); if (++n == N) break;
78 pi2(p, uk+t); if (++n == N) break;
79 pi3(p, uk+t); if (++n == N) break;
80 pi4(p, uk+t); if (++n == N) break;
77 s_pi1(p); if (++n == N) break;
78 s_pi2(p, uk+t); if (++n == N) break;
79 s_pi3(p, uk+t); if (++n == N) break;
80 s_pi4(p, uk+t); if (++n == N) break;
8181 t ^= 4;
8282 }
8383 }
8484
85 static void decrypt(ulong32 *p, int N, const ulong32 *uk)
85 static void s_decrypt(ulong32 *p, int N, const ulong32 *uk)
8686 {
8787 int n, t;
8888 for (t = 4*(((N-1)>>2)&1), n = N; ; ) {
8989 switch (n<=4 ? n : ((n-1)%4)+1) {
90 case 4: pi4(p, uk+t); --n; /* FALLTHROUGH */
91 case 3: pi3(p, uk+t); --n; /* FALLTHROUGH */
92 case 2: pi2(p, uk+t); --n; /* FALLTHROUGH */
93 case 1: pi1(p); --n; break;
90 case 4: s_pi4(p, uk+t); --n; /* FALLTHROUGH */
91 case 3: s_pi3(p, uk+t); --n; /* FALLTHROUGH */
92 case 2: s_pi2(p, uk+t); --n; /* FALLTHROUGH */
93 case 1: s_pi1(p); --n; break;
9494 case 0: return;
9595 }
9696 t ^= 4;
127127 }
128128 LOAD32H(dk[0], key + 32);
129129 LOAD32H(dk[1], key + 36);
130 setup(dk, sk, skey->multi2.uk);
130 s_setup(dk, sk, skey->multi2.uk);
131131
132132 zeromem(sk, sizeof(sk));
133133 zeromem(dk, sizeof(dk));
149149 LTC_ARGCHK(skey != NULL);
150150 LOAD32H(p[0], pt);
151151 LOAD32H(p[1], pt+4);
152 encrypt(p, skey->multi2.N, skey->multi2.uk);
152 s_encrypt(p, skey->multi2.N, skey->multi2.uk);
153153 STORE32H(p[0], ct);
154154 STORE32H(p[1], ct+4);
155155 return CRYPT_OK;
170170 LTC_ARGCHK(skey != NULL);
171171 LOAD32H(p[0], ct);
172172 LOAD32H(p[1], ct+4);
173 decrypt(p, skey->multi2.N, skey->multi2.uk);
173 s_decrypt(p, skey->multi2.N, skey->multi2.uk);
174174 STORE32H(p[0], pt);
175175 STORE32H(p[1], pt+4);
176176 return CRYPT_OK;
101101 @return CRYPT_OK if successful
102102 */
103103 #ifdef LTC_CLEAN_STACK
104 static int _noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
104 static int s_noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
105105 #else
106106 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
107107 #endif
141141 #ifdef LTC_CLEAN_STACK
142142 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
143143 {
144 int err = _noekeon_ecb_encrypt(pt, ct, skey);
144 int err = s_noekeon_ecb_encrypt(pt, ct, skey);
145145 burn_stack(sizeof(ulong32) * 5 + sizeof(int));
146146 return err;
147147 }
155155 @return CRYPT_OK if successful
156156 */
157157 #ifdef LTC_CLEAN_STACK
158 static int _noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
158 static int s_noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
159159 #else
160160 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
161161 #endif
194194 #ifdef LTC_CLEAN_STACK
195195 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
196196 {
197 int err = _noekeon_ecb_decrypt(ct, pt, skey);
197 int err = s_noekeon_ecb_decrypt(ct, pt, skey);
198198 burn_stack(sizeof(ulong32) * 5 + sizeof(int));
199199 return err;
200200 }
138138 @return CRYPT_OK if successful
139139 */
140140 #ifdef LTC_CLEAN_STACK
141 static int _rc2_ecb_encrypt( const unsigned char *pt,
141 static int s_rc2_ecb_encrypt( const unsigned char *pt,
142142 unsigned char *ct,
143143 const symmetric_key *skey)
144144 #else
199199 unsigned char *ct,
200200 const symmetric_key *skey)
201201 {
202 int err = _rc2_ecb_encrypt(pt, ct, skey);
202 int err = s_rc2_ecb_encrypt(pt, ct, skey);
203203 burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 5);
204204 return err;
205205 }
216216 @return CRYPT_OK if successful
217217 */
218218 #ifdef LTC_CLEAN_STACK
219 static int _rc2_ecb_decrypt( const unsigned char *ct,
219 static int s_rc2_ecb_decrypt( const unsigned char *ct,
220220 unsigned char *pt,
221221 const symmetric_key *skey)
222222 #else
278278 unsigned char *pt,
279279 const symmetric_key *skey)
280280 {
281 int err = _rc2_ecb_decrypt(ct, pt, skey);
281 int err = s_rc2_ecb_decrypt(ct, pt, skey);
282282 burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 4 + sizeof(int));
283283 return err;
284284 }
4242 @return CRYPT_OK if successful
4343 */
4444 #ifdef LTC_CLEAN_STACK
45 static int _rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
45 static int s_rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
4646 #else
4747 int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
4848 #endif
103103 int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
104104 {
105105 int x;
106 x = _rc5_setup(key, keylen, num_rounds, skey);
106 x = s_rc5_setup(key, keylen, num_rounds, skey);
107107 burn_stack(sizeof(ulong32) * 122 + sizeof(int));
108108 return x;
109109 }
117117 @return CRYPT_OK if successful
118118 */
119119 #ifdef LTC_CLEAN_STACK
120 static int _rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
120 static int s_rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
121121 #else
122122 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
123123 #endif
163163 #ifdef LTC_CLEAN_STACK
164164 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
165165 {
166 int err = _rc5_ecb_encrypt(pt, ct, skey);
166 int err = s_rc5_ecb_encrypt(pt, ct, skey);
167167 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
168168 return err;
169169 }
177177 @return CRYPT_OK if successful
178178 */
179179 #ifdef LTC_CLEAN_STACK
180 static int _rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
180 static int s_rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
181181 #else
182182 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
183183 #endif
224224 #ifdef LTC_CLEAN_STACK
225225 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
226226 {
227 int err = _rc5_ecb_decrypt(ct, pt, skey);
227 int err = s_rc5_ecb_decrypt(ct, pt, skey);
228228 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
229229 return err;
230230 }
3939 @return CRYPT_OK if successful
4040 */
4141 #ifdef LTC_CLEAN_STACK
42 static int _rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
42 static int s_rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
4343 #else
4444 int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
4545 #endif
9898 int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
9999 {
100100 int x;
101 x = _rc6_setup(key, keylen, num_rounds, skey);
101 x = s_rc6_setup(key, keylen, num_rounds, skey);
102102 burn_stack(sizeof(ulong32) * 122);
103103 return x;
104104 }
111111 @param skey The key as scheduled
112112 */
113113 #ifdef LTC_CLEAN_STACK
114 static int _rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
114 static int s_rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
115115 #else
116116 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
117117 #endif
153153 #ifdef LTC_CLEAN_STACK
154154 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
155155 {
156 int err = _rc6_ecb_encrypt(pt, ct, skey);
156 int err = s_rc6_ecb_encrypt(pt, ct, skey);
157157 burn_stack(sizeof(ulong32) * 6 + sizeof(int));
158158 return err;
159159 }
166166 @param skey The key as scheduled
167167 */
168168 #ifdef LTC_CLEAN_STACK
169 static int _rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
169 static int s_rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
170170 #else
171171 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
172172 #endif
210210 #ifdef LTC_CLEAN_STACK
211211 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
212212 {
213 int err = _rc6_ecb_decrypt(ct, pt, skey);
213 int err = s_rc6_ecb_decrypt(ct, pt, skey);
214214 burn_stack(sizeof(ulong32) * 6 + sizeof(int));
215215 return err;
216216 }
2323
2424 #ifdef LTC_SAFER
2525
26 #define __LTC_SAFER_TAB_C__
26 #define LTC_SAFER_TAB_C
2727 #include "safer_tab.c"
2828
2929 const struct ltc_cipher_descriptor safer_k64_desc = {
9090 /******************* Types ****************************************************/
9191
9292 #ifdef LTC_CLEAN_STACK
93 static void _Safer_Expand_Userkey(const unsigned char *userkey_1,
93 static void s_safer_expand_userkey(const unsigned char *userkey_1,
9494 const unsigned char *userkey_2,
9595 unsigned int nof_rounds,
9696 int strengthened,
9797 safer_key_t key)
9898 #else
99 static void Safer_Expand_Userkey(const unsigned char *userkey_1,
99 static void safer_expand_userkey(const unsigned char *userkey_1,
100100 const unsigned char *userkey_2,
101101 unsigned int nof_rounds,
102102 int strengthened,
159159 }
160160
161161 #ifdef LTC_CLEAN_STACK
162 static void Safer_Expand_Userkey(const unsigned char *userkey_1,
162 static void safer_expand_userkey(const unsigned char *userkey_1,
163163 const unsigned char *userkey_2,
164164 unsigned int nof_rounds,
165165 int strengthened,
166166 safer_key_t key)
167167 {
168 _Safer_Expand_Userkey(userkey_1, userkey_2, nof_rounds, strengthened, key);
168 s_safer_expand_userkey(userkey_1, userkey_2, nof_rounds, strengthened, key);
169169 burn_stack(sizeof(unsigned char) * (2 * (LTC_SAFER_BLOCK_LEN + 1)) + sizeof(unsigned int)*2);
170170 }
171171 #endif
183183 return CRYPT_INVALID_KEYSIZE;
184184 }
185185
186 Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
186 safer_expand_userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
187187 return CRYPT_OK;
188188 }
189189
200200 return CRYPT_INVALID_KEYSIZE;
201201 }
202202
203 Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
203 safer_expand_userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
204204 return CRYPT_OK;
205205 }
206206
217217 return CRYPT_INVALID_KEYSIZE;
218218 }
219219
220 Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
220 safer_expand_userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
221221 return CRYPT_OK;
222222 }
223223
234234 return CRYPT_INVALID_KEYSIZE;
235235 }
236236
237 Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
238 return CRYPT_OK;
239 }
240
241 #ifdef LTC_CLEAN_STACK
242 static int _safer_ecb_encrypt(const unsigned char *pt,
237 safer_expand_userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
238 return CRYPT_OK;
239 }
240
241 #ifdef LTC_CLEAN_STACK
242 static int s_safer_ecb_encrypt(const unsigned char *pt,
243243 unsigned char *ct,
244244 const symmetric_key *skey)
245245 #else
286286 unsigned char *ct,
287287 const symmetric_key *skey)
288288 {
289 int err = _safer_ecb_encrypt(pt, ct, skey);
289 int err = s_safer_ecb_encrypt(pt, ct, skey);
290290 burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
291291 return err;
292292 }
293293 #endif
294294
295295 #ifdef LTC_CLEAN_STACK
296 static int _safer_ecb_decrypt(const unsigned char *ct,
296 static int s_safer_ecb_decrypt(const unsigned char *ct,
297297 unsigned char *pt,
298298 const symmetric_key *skey)
299299 #else
341341 unsigned char *pt,
342342 const symmetric_key *skey)
343343 {
344 int err = _safer_ecb_decrypt(ct, pt, skey);
344 int err = s_safer_ecb_decrypt(ct, pt, skey);
345345 burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
346346 return err;
347347 }
55 Tables for LTC_SAFER block ciphers
66 */
77
8 #ifdef __LTC_SAFER_TAB_C__
8 #ifdef LTC_SAFER_TAB_C
99
1010 /* This is the box defined by ebox[x] = 45^x mod 257.
1111 * Its assumed that the value "256" corresponds to zero. */
4848 184, 64, 120, 45, 58, 233, 100, 31, 146, 144, 125, 57, 111, 224, 137, 48
4949 };
5050
51 #endif /* __LTC_SAFER_TAB_C__ */
51 #endif /* LTC_SAFER_TAB_C */
5252
5353
88
99 #ifdef LTC_SAFERP
1010
11 #define __LTC_SAFER_TAB_C__
11 #define LTC_SAFER_TAB_C
1212 #include "safer_tab.c"
1313
1414 const struct ltc_cipher_descriptor saferp_desc =
136136
137137 #ifdef LTC_SMALL_CODE
138138
139 static void _round(unsigned char *b, int i, const symmetric_key *skey)
139 static void s_round(unsigned char *b, int i, const symmetric_key *skey)
140140 {
141141 ROUND(b, i);
142142 }
143143
144 static void _iround(unsigned char *b, int i, const symmetric_key *skey)
144 static void s_iround(unsigned char *b, int i, const symmetric_key *skey)
145145 {
146146 iROUND(b, i);
147147 }
148148
149 static void _lt(unsigned char *b, unsigned char *b2)
149 static void s_lt(unsigned char *b, unsigned char *b2)
150150 {
151151 LT(b, b2);
152152 }
153153
154 static void _ilt(unsigned char *b, unsigned char *b2)
154 static void s_ilt(unsigned char *b, unsigned char *b2)
155155 {
156156 iLT(b, b2);
157157 }
158158
159159 #undef ROUND
160 #define ROUND(b, i) _round(b, i, skey)
160 #define ROUND(b, i) s_round(b, i, skey)
161161
162162 #undef iROUND
163 #define iROUND(b, i) _iround(b, i, skey)
163 #define iROUND(b, i) s_iround(b, i, skey)
164164
165165 #undef LT
166 #define LT(b, b2) _lt(b, b2)
166 #define LT(b, b2) s_lt(b, b2)
167167
168168 #undef iLT
169 #define iLT(b, b2) _ilt(b, b2)
169 #define iLT(b, b2) s_ilt(b, b2)
170170
171171 #endif
172172
2626 };
2727
2828 /* linear transformation */
29 #define _LT(i,a,b,c,d,e) { \
29 #define s_lt(i,a,b,c,d,e) { \
3030 a = ROLc(a, 13); \
3131 c = ROLc(c, 3); \
3232 d = ROLc(d ^ c ^ (a << 3), 7); \
3636 }
3737
3838 /* inverse linear transformation */
39 #define _ILT(i,a,b,c,d,e) { \
39 #define s_ilt(i,a,b,c,d,e) { \
4040 c = RORc(c, 22); \
4141 a = RORc(a, 5); \
4242 c ^= d ^ (b << 7); \
4949 }
5050
5151 /* order of output from S-box functions */
52 #define _beforeS0(f) f(0,a,b,c,d,e)
53 #define _afterS0(f) f(1,b,e,c,a,d)
54 #define _afterS1(f) f(2,c,b,a,e,d)
55 #define _afterS2(f) f(3,a,e,b,d,c)
56 #define _afterS3(f) f(4,e,b,d,c,a)
57 #define _afterS4(f) f(5,b,a,e,c,d)
58 #define _afterS5(f) f(6,a,c,b,e,d)
59 #define _afterS6(f) f(7,a,c,d,b,e)
60 #define _afterS7(f) f(8,d,e,b,a,c)
52 #define s_beforeS0(f) f(0,a,b,c,d,e)
53 #define s_afterS0(f) f(1,b,e,c,a,d)
54 #define s_afterS1(f) f(2,c,b,a,e,d)
55 #define s_afterS2(f) f(3,a,e,b,d,c)
56 #define s_afterS3(f) f(4,e,b,d,c,a)
57 #define s_afterS4(f) f(5,b,a,e,c,d)
58 #define s_afterS5(f) f(6,a,c,b,e,d)
59 #define s_afterS6(f) f(7,a,c,d,b,e)
60 #define s_afterS7(f) f(8,d,e,b,a,c)
6161
6262 /* order of output from inverse S-box functions */
63 #define _beforeI7(f) f(8,a,b,c,d,e)
64 #define _afterI7(f) f(7,d,a,b,e,c)
65 #define _afterI6(f) f(6,a,b,c,e,d)
66 #define _afterI5(f) f(5,b,d,e,c,a)
67 #define _afterI4(f) f(4,b,c,e,a,d)
68 #define _afterI3(f) f(3,a,b,e,c,d)
69 #define _afterI2(f) f(2,b,d,e,c,a)
70 #define _afterI1(f) f(1,a,b,c,e,d)
71 #define _afterI0(f) f(0,a,d,b,e,c)
63 #define s_beforeI7(f) f(8,a,b,c,d,e)
64 #define s_afterI7(f) f(7,d,a,b,e,c)
65 #define s_afterI6(f) f(6,a,b,c,e,d)
66 #define s_afterI5(f) f(5,b,d,e,c,a)
67 #define s_afterI4(f) f(4,b,c,e,a,d)
68 #define s_afterI3(f) f(3,a,b,e,c,d)
69 #define s_afterI2(f) f(2,b,d,e,c,a)
70 #define s_afterI1(f) f(1,a,b,c,e,d)
71 #define s_afterI0(f) f(0,a,d,b,e,c)
7272
7373 /* The instruction sequences for the S-box functions
7474 * come from Dag Arne Osvik's paper "Speeding up Serpent".
7575 */
7676
77 #define _S0(i, r0, r1, r2, r3, r4) { \
77 #define s_s0(i, r0, r1, r2, r3, r4) { \
7878 r3 ^= r0; \
7979 r4 = r1; \
8080 r1 &= r3; \
9595 r4 ^= r3; \
9696 }
9797
98 #define _I0(i, r0, r1, r2, r3, r4) { \
98 #define s_i0(i, r0, r1, r2, r3, r4) { \
9999 r2 = ~r2; \
100100 r4 = r1; \
101101 r1 |= r0; \
117117 r4 ^= r2; \
118118 }
119119
120 #define _S1(i, r0, r1, r2, r3, r4) { \
120 #define s_s1(i, r0, r1, r2, r3, r4) { \
121121 r0 = ~r0; \
122122 r2 = ~r2; \
123123 r4 = r0; \
138138 r0 ^= r4; \
139139 }
140140
141 #define _I1(i, r0, r1, r2, r3, r4) { \
141 #define s_i1(i, r0, r1, r2, r3, r4) { \
142142 r4 = r1; \
143143 r1 ^= r3; \
144144 r3 &= r1; \
160160 r3 ^= r1; \
161161 }
162162
163 #define _S2(i, r0, r1, r2, r3, r4) { \
163 #define s_s2(i, r0, r1, r2, r3, r4) { \
164164 r4 = r0; \
165165 r0 &= r2; \
166166 r0 ^= r3; \
179179 r4 = ~r4; \
180180 }
181181
182 #define _I2(i, r0, r1, r2, r3, r4) { \
182 #define s_i2(i, r0, r1, r2, r3, r4) { \
183183 r2 ^= r3; \
184184 r3 ^= r0; \
185185 r4 = r3; \
201201 r3 ^= r0; \
202202 }
203203
204 #define _S3(i, r0, r1, r2, r3, r4) { \
204 #define s_s3(i, r0, r1, r2, r3, r4) { \
205205 r4 = r0; \
206206 r0 |= r3; \
207207 r3 ^= r1; \
223223 r1 ^= r0; \
224224 }
225225
226 #define _I3(i, r0, r1, r2, r3, r4) { \
226 #define s_i3(i, r0, r1, r2, r3, r4) { \
227227 r4 = r2; \
228228 r2 ^= r1; \
229229 r1 &= r2; \
244244 r2 ^= r4; \
245245 }
246246
247 #define _S4(i, r0, r1, r2, r3, r4) { \
247 #define s_s4(i, r0, r1, r2, r3, r4) { \
248248 r1 ^= r3; \
249249 r3 = ~r3; \
250250 r2 ^= r3; \
267267 r4 ^= r2; \
268268 }
269269
270 #define _I4(i, r0, r1, r2, r3, r4) { \
270 #define s_i4(i, r0, r1, r2, r3, r4) { \
271271 r4 = r2; \
272272 r2 &= r3; \
273273 r2 ^= r1; \
290290 r2 ^= r1; \
291291 }
292292
293 #define _S5(i, r0, r1, r2, r3, r4) { \
293 #define s_s5(i, r0, r1, r2, r3, r4) { \
294294 r0 ^= r1; \
295295 r1 ^= r3; \
296296 r3 = ~r3; \
312312 r2 ^= r4; \
313313 }
314314
315 #define _I5(i, r0, r1, r2, r3, r4) { \
315 #define s_i5(i, r0, r1, r2, r3, r4) { \
316316 r1 = ~r1; \
317317 r4 = r3; \
318318 r2 ^= r1; \
334334 r4 = ~r4; \
335335 }
336336
337 #define _S6(i, r0, r1, r2, r3, r4) { \
337 #define s_s6(i, r0, r1, r2, r3, r4) { \
338338 r2 = ~r2; \
339339 r4 = r3; \
340340 r3 &= r0; \
355355 r2 ^= r3; \
356356 }
357357
358 #define _I6(i, r0, r1, r2, r3, r4) { \
358 #define s_i6(i, r0, r1, r2, r3, r4) { \
359359 r0 ^= r2; \
360360 r4 = r2; \
361361 r2 &= r0; \
375375 r4 ^= r0; \
376376 }
377377
378 #define _S7(i, r0, r1, r2, r3, r4) { \
378 #define s_s7(i, r0, r1, r2, r3, r4) { \
379379 r4 = r2; \
380380 r2 &= r1; \
381381 r2 ^= r3; \
398398 r4 ^= r1; \
399399 }
400400
401 #define _I7(i, r0, r1, r2, r3, r4) { \
401 #define s_i7(i, r0, r1, r2, r3, r4) { \
402402 r4 = r2; \
403403 r2 ^= r0; \
404404 r0 &= r3; \
421421 }
422422
423423 /* key xor */
424 #define _KX(r, a, b, c, d, e) { \
424 #define s_kx(r, a, b, c, d, e) { \
425425 a ^= k[4 * r + 0]; \
426426 b ^= k[4 * r + 1]; \
427427 c ^= k[4 * r + 2]; \
428428 d ^= k[4 * r + 3]; \
429429 }
430430
431 #define _LK(r, a, b, c, d, e) { \
431 #define s_lk(r, a, b, c, d, e) { \
432432 a = k[(8-r)*4 + 0]; \
433433 b = k[(8-r)*4 + 1]; \
434434 c = k[(8-r)*4 + 2]; \
435435 d = k[(8-r)*4 + 3]; \
436436 }
437437
438 #define _SK(r, a, b, c, d, e) { \
438 #define s_sk(r, a, b, c, d, e) { \
439439 k[(8-r)*4 + 4] = a; \
440440 k[(8-r)*4 + 5] = b; \
441441 k[(8-r)*4 + 6] = c; \
442442 k[(8-r)*4 + 7] = d; \
443443 }
444444
445 static int _setup_key(const unsigned char *key, int keylen, int rounds, ulong32 *k)
445 static int s_setup_key(const unsigned char *key, int keylen, int rounds, ulong32 *k)
446446 {
447447 int i;
448448 ulong32 t;
466466 k -= 20;
467467
468468 for (i = 0; i < rounds/8; i++) {
469 _afterS2(_LK); _afterS2(_S3); _afterS3(_SK);
470 _afterS1(_LK); _afterS1(_S2); _afterS2(_SK);
471 _afterS0(_LK); _afterS0(_S1); _afterS1(_SK);
472 _beforeS0(_LK); _beforeS0(_S0); _afterS0(_SK);
469 s_afterS2(s_lk); s_afterS2(s_s3); s_afterS3(s_sk);
470 s_afterS1(s_lk); s_afterS1(s_s2); s_afterS2(s_sk);
471 s_afterS0(s_lk); s_afterS0(s_s1); s_afterS1(s_sk);
472 s_beforeS0(s_lk); s_beforeS0(s_s0); s_afterS0(s_sk);
473473 k += 8*4;
474 _afterS6(_LK); _afterS6(_S7); _afterS7(_SK);
475 _afterS5(_LK); _afterS5(_S6); _afterS6(_SK);
476 _afterS4(_LK); _afterS4(_S5); _afterS5(_SK);
477 _afterS3(_LK); _afterS3(_S4); _afterS4(_SK);
474 s_afterS6(s_lk); s_afterS6(s_s7); s_afterS7(s_sk);
475 s_afterS5(s_lk); s_afterS5(s_s6); s_afterS6(s_sk);
476 s_afterS4(s_lk); s_afterS4(s_s5); s_afterS5(s_sk);
477 s_afterS3(s_lk); s_afterS3(s_s4); s_afterS4(s_sk);
478478 }
479 _afterS2(_LK); _afterS2(_S3); _afterS3(_SK);
479 s_afterS2(s_lk); s_afterS2(s_s3); s_afterS3(s_sk);
480480
481481 return CRYPT_OK;
482482 }
483483
484 static int _enc_block(const unsigned char *in, unsigned char *out, const ulong32 *k)
484 static int s_enc_block(const unsigned char *in, unsigned char *out, const ulong32 *k)
485485 {
486486 ulong32 a, b, c, d, e;
487487 unsigned int i = 1;
492492 LOAD32L(d, in + 12);
493493
494494 do {
495 _beforeS0(_KX); _beforeS0(_S0); _afterS0(_LT);
496 _afterS0(_KX); _afterS0(_S1); _afterS1(_LT);
497 _afterS1(_KX); _afterS1(_S2); _afterS2(_LT);
498 _afterS2(_KX); _afterS2(_S3); _afterS3(_LT);
499 _afterS3(_KX); _afterS3(_S4); _afterS4(_LT);
500 _afterS4(_KX); _afterS4(_S5); _afterS5(_LT);
501 _afterS5(_KX); _afterS5(_S6); _afterS6(_LT);
502 _afterS6(_KX); _afterS6(_S7);
495 s_beforeS0(s_kx); s_beforeS0(s_s0); s_afterS0(s_lt);
496 s_afterS0(s_kx); s_afterS0(s_s1); s_afterS1(s_lt);
497 s_afterS1(s_kx); s_afterS1(s_s2); s_afterS2(s_lt);
498 s_afterS2(s_kx); s_afterS2(s_s3); s_afterS3(s_lt);
499 s_afterS3(s_kx); s_afterS3(s_s4); s_afterS4(s_lt);
500 s_afterS4(s_kx); s_afterS4(s_s5); s_afterS5(s_lt);
501 s_afterS5(s_kx); s_afterS5(s_s6); s_afterS6(s_lt);
502 s_afterS6(s_kx); s_afterS6(s_s7);
503503
504504 if (i == 4) break;
505505
510510 d = a;
511511 a = e;
512512 k += 32;
513 _beforeS0(_LT);
513 s_beforeS0(s_lt);
514514 } while (1);
515515
516 _afterS7(_KX);
516 s_afterS7(s_kx);
517517
518518 STORE32L(d, out + 0);
519519 STORE32L(e, out + 4);
523523 return CRYPT_OK;
524524 }
525525
526 static int _dec_block(const unsigned char *in, unsigned char *out, const ulong32 *k)
526 static int s_dec_block(const unsigned char *in, unsigned char *out, const ulong32 *k)
527527 {
528528 ulong32 a, b, c, d, e;
529529 unsigned int i;
536536 i = 4;
537537 k += 96;
538538
539 _beforeI7(_KX);
539 s_beforeI7(s_kx);
540540 goto start;
541541
542542 do {
544544 b = d;
545545 d = e;
546546 k -= 32;
547 _beforeI7(_ILT);
547 s_beforeI7(s_ilt);
548548 start:
549 _beforeI7(_I7); _afterI7(_KX);
550 _afterI7(_ILT); _afterI7(_I6); _afterI6(_KX);
551 _afterI6(_ILT); _afterI6(_I5); _afterI5(_KX);
552 _afterI5(_ILT); _afterI5(_I4); _afterI4(_KX);
553 _afterI4(_ILT); _afterI4(_I3); _afterI3(_KX);
554 _afterI3(_ILT); _afterI3(_I2); _afterI2(_KX);
555 _afterI2(_ILT); _afterI2(_I1); _afterI1(_KX);
556 _afterI1(_ILT); _afterI1(_I0); _afterI0(_KX);
549 s_beforeI7(s_i7); s_afterI7(s_kx);
550 s_afterI7(s_ilt); s_afterI7(s_i6); s_afterI6(s_kx);
551 s_afterI6(s_ilt); s_afterI6(s_i5); s_afterI5(s_kx);
552 s_afterI5(s_ilt); s_afterI5(s_i4); s_afterI4(s_kx);
553 s_afterI4(s_ilt); s_afterI4(s_i3); s_afterI3(s_kx);
554 s_afterI3(s_ilt); s_afterI3(s_i2); s_afterI2(s_kx);
555 s_afterI2(s_ilt); s_afterI2(s_i1); s_afterI1(s_kx);
556 s_afterI1(s_ilt); s_afterI1(s_i0); s_afterI0(s_kx);
557557 } while (--i != 0);
558558
559559 STORE32L(a, out + 0);
574574 if (num_rounds != 0 && num_rounds != 32) return CRYPT_INVALID_ROUNDS;
575575 if (keylen != 16 && keylen != 24 && keylen != 32) return CRYPT_INVALID_KEYSIZE;
576576
577 err = _setup_key(key, keylen, 32, skey->serpent.k);
577 err = s_setup_key(key, keylen, 32, skey->serpent.k);
578578 #ifdef LTC_CLEAN_STACK
579579 burn_stack(sizeof(ulong32) * 14 + sizeof(int));
580580 #endif
583583
584584 int serpent_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
585585 {
586 int err = _enc_block(pt, ct, skey->serpent.k);
586 int err = s_enc_block(pt, ct, skey->serpent.k);
587587 #ifdef LTC_CLEAN_STACK
588588 burn_stack(sizeof(ulong32) * 5 + sizeof(int));
589589 #endif
592592
593593 int serpent_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
594594 {
595 int err = _dec_block(ct, pt, skey->serpent.k);
595 int err = s_dec_block(ct, pt, skey->serpent.k);
596596 #ifdef LTC_CLEAN_STACK
597597 burn_stack(sizeof(ulong32) * 5 + sizeof(int));
598598 #endif
132132 @return CRYPT_OK if successful
133133 */
134134 #ifdef LTC_CLEAN_STACK
135 static int _skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
135 static int s_skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
136136 #else
137137 int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
138138 #endif
182182 #ifdef LTC_CLEAN_STACK
183183 int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
184184 {
185 int err = _skipjack_ecb_encrypt(pt, ct, skey);
185 int err = s_skipjack_ecb_encrypt(pt, ct, skey);
186186 burn_stack(sizeof(unsigned) * 8 + sizeof(int) * 2);
187187 return err;
188188 }
196196 @return CRYPT_OK if successful
197197 */
198198 #ifdef LTC_CLEAN_STACK
199 static int _skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
199 static int s_skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
200200 #else
201201 int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
202202 #endif
250250 #ifdef LTC_CLEAN_STACK
251251 int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
252252 {
253 int err = _skipjack_ecb_decrypt(ct, pt, skey);
253 int err = s_skipjack_ecb_decrypt(ct, pt, skey);
254254 burn_stack(sizeof(unsigned) * 7 + sizeof(int) * 2);
255255 return err;
256256 }
6767
6868 LOAD32H(y, &pt[0]);
6969 LOAD32H(z, &pt[4]);
70 for (r = 0; r < 32; r += 4) {
70 for (r = 0; r < 32; r++) {
7171 sum += delta;
7272 y += ((z<<4) + skey->tea.k[0]) ^ (z + sum) ^ ((z>>5) + skey->tea.k[1]);
7373 z += ((y<<4) + skey->tea.k[2]) ^ (y + sum) ^ ((y>>5) + skey->tea.k[3]);
153153 zeromem(&skey, sizeof(skey));
154154
155155 l = sizeof(key);
156 if ((err = base16_decode(tests[i].key, XSTRLEN(tests[i].key), key, &l)) != CRYPT) return err;
156 if ((err = base16_decode(tests[i].key, XSTRLEN(tests[i].key), key, &l)) != CRYPT_OK) return err;
157157 l = sizeof(ptct[0]);
158 if ((err = base16_decode(tests[i].pt, XSTRLEN(tests[i].pt), ptct[0], &l)) != CRYPT) return err;
158 if ((err = base16_decode(tests[i].pt, XSTRLEN(tests[i].pt), ptct[0], &l)) != CRYPT_OK) return err;
159159 l = sizeof(ptct[1]);
160 if ((err = base16_decode(tests[i].ct, XSTRLEN(tests[i].ct), ptct[1], &l)) != CRYPT) return err;
160 if ((err = base16_decode(tests[i].ct, XSTRLEN(tests[i].ct), ptct[1], &l)) != CRYPT_OK) return err;
161161
162162 if ((err = tea_setup(key, 16, 0, &skey)) != CRYPT_OK) {
163163 return err;
165165 tea_ecb_encrypt(ptct[0], tmp[0], &skey);
166166 tea_ecb_decrypt(tmp[0], tmp[1], &skey);
167167
168 if (compare_testvector(tmp[0], 8, ptct[0], 8, "TEA Encrypt", i) != 0 ||
169 compare_testvector(tmp[1], 8, ptct[1], 8, "TEA Decrypt", i) != 0) {
168 if (compare_testvector(tmp[0], 8, ptct[1], 8, "TEA Encrypt", i) != 0 ||
169 compare_testvector(tmp[1], 8, ptct[0], 8, "TEA Decrypt", i) != 0) {
170170 return CRYPT_FAIL_TESTVECTOR;
171171 }
172172
5757
5858 #ifdef LTC_TWOFISH_TABLES
5959
60 #define __LTC_TWOFISH_TAB_C__
60 #define LTC_TWOFISH_TAB_C
6161 #include "twofish_tab.c"
6262
6363 #define sbox(i, x) ((ulong32)SBOX[i][(x)&255])
8282
8383 /* computes S_i[x] */
8484 #ifdef LTC_CLEAN_STACK
85 static ulong32 _sbox(int i, ulong32 x)
85 static ulong32 s_sbox(int i, ulong32 x)
8686 #else
8787 static ulong32 sbox(int i, ulong32 x)
8888 #endif
124124 static ulong32 sbox(int i, ulong32 x)
125125 {
126126 ulong32 y;
127 y = _sbox(i, x);
127 y = s_sbox(i, x);
128128 burn_stack(sizeof(unsigned char) * 11);
129129 return y;
130130 }
281281 #else
282282
283283 #ifdef LTC_CLEAN_STACK
284 static ulong32 _g_func(ulong32 x, const symmetric_key *key)
284 static ulong32 s_g_func(ulong32 x, const symmetric_key *key)
285285 #else
286286 static ulong32 g_func(ulong32 x, const symmetric_key *key)
287287 #endif
317317 static ulong32 g_func(ulong32 x, const symmetric_key *key)
318318 {
319319 ulong32 y;
320 y = _g_func(x, key);
320 y = s_g_func(x, key);
321321 burn_stack(sizeof(unsigned char) * 4 + sizeof(ulong32));
322322 return y;
323323 }
334334 @return CRYPT_OK if successful
335335 */
336336 #ifdef LTC_CLEAN_STACK
337 static int _twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
337 static int s_twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
338338 #else
339339 int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
340340 #endif
447447 int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
448448 {
449449 int x;
450 x = _twofish_setup(key, keylen, num_rounds, skey);
450 x = s_twofish_setup(key, keylen, num_rounds, skey);
451451 burn_stack(sizeof(int) * 7 + sizeof(unsigned char) * 56 + sizeof(ulong32) * 2);
452452 return x;
453453 }
461461 @return CRYPT_OK if successful
462462 */
463463 #ifdef LTC_CLEAN_STACK
464 static int _twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
464 static int s_twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
465465 #else
466466 int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
467467 #endif
521521 #ifdef LTC_CLEAN_STACK
522522 int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
523523 {
524 int err = _twofish_ecb_encrypt(pt, ct, skey);
524 int err = s_twofish_ecb_encrypt(pt, ct, skey);
525525 burn_stack(sizeof(ulong32) * 10 + sizeof(int));
526526 return err;
527527 }
535535 @return CRYPT_OK if successful
536536 */
537537 #ifdef LTC_CLEAN_STACK
538 static int _twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
538 static int s_twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
539539 #else
540540 int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
541541 #endif
597597 #ifdef LTC_CLEAN_STACK
598598 int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
599599 {
600 int err =_twofish_ecb_decrypt(ct, pt, skey);
600 int err = s_twofish_ecb_decrypt(ct, pt, skey);
601601 burn_stack(sizeof(ulong32) * 10 + sizeof(int));
602602 return err;
603603 }
55 Twofish tables, Tom St Denis
66 */
77 #ifdef LTC_TWOFISH_TABLES
8 #ifdef __LTC_TWOFISH_TAB_C__
8 #ifdef LTC_TWOFISH_TAB_C
99
1010 /* pre generated 8x8 tables from the four 4x4s */
1111 static const unsigned char SBOX[2][256] = {
481481
482482 #endif /* LTC_TWOFISH_ALL_TABLES */
483483
484 #endif /* __LTC_TWOFISH_TAB_C__ */
484 #endif /* LTC_TWOFISH_TAB_C */
485485 #endif
5151
5252 #ifndef LTC_FAST
5353 /* right shift */
54 static void _gcm_rightshift(unsigned char *a)
54 static void s_gcm_rightshift(unsigned char *a)
5555 {
5656 int x;
5757 for (x = 15; x > 0; x--) {
8585 }
8686 }
8787 z = V[15] & 0x01;
88 _gcm_rightshift(V);
88 s_gcm_rightshift(V);
8989 V[0] ^= poly[z];
9090 }
9191 XMEMCPY(c, Z, 16);
1414 @param aad_block [in] AAD data (block_len size)
1515 @return CRYPT_OK if successful
1616 */
17 static int _ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
17 static int s_ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
1818 {
1919 unsigned char tmp[MAXBLOCKSIZE];
2020 int err;
5858 ocb->adata_buffer_bytes += l;
5959
6060 if (ocb->adata_buffer_bytes == ocb->block_len) {
61 if ((err = _ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
61 if ((err = s_ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
6262 return err;
6363 }
6464 ocb->adata_buffer_bytes = 0;
7979 last_block_len = datalen - full_blocks_len;
8080
8181 for (x=0; x<full_blocks; x++) {
82 if ((err = _ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
82 if ((err = s_ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
8383 return err;
8484 }
8585 }
88
99 #ifdef LTC_OCB3_MODE
1010
11 static void _ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
11 static void s_ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
1212 {
1313 int x, y, bottom;
1414 int idx, shift;
165165 }
166166
167167 /* initialize ocb->Offset_current = Offset_0 */
168 _ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
168 s_ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
169169
170170 /* initialize checksum to all zeros */
171171 zeromem(ocb->checksum, ocb->block_len);
146146 { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
147147 };
148148
149 static void blake2b_set_lastnode(hash_state *md) { md->blake2b.f[1] = CONST64(0xffffffffffffffff); }
149 static void s_blake2b_set_lastnode(hash_state *md) { md->blake2b.f[1] = CONST64(0xffffffffffffffff); }
150150
151151 /* Some helper functions, not necessarily useful */
152 static int blake2b_is_lastblock(const hash_state *md) { return md->blake2b.f[0] != 0; }
153
154 static void blake2b_set_lastblock(hash_state *md)
152 static int s_blake2b_is_lastblock(const hash_state *md) { return md->blake2b.f[0] != 0; }
153
154 static void s_blake2b_set_lastblock(hash_state *md)
155155 {
156156 if (md->blake2b.last_node) {
157 blake2b_set_lastnode(md);
157 s_blake2b_set_lastnode(md);
158158 }
159159 md->blake2b.f[0] = CONST64(0xffffffffffffffff);
160160 }
161161
162 static void blake2b_increment_counter(hash_state *md, ulong64 inc)
162 static void s_blake2b_increment_counter(hash_state *md, ulong64 inc)
163163 {
164164 md->blake2b.t[0] += inc;
165165 if (md->blake2b.t[0] < inc) md->blake2b.t[1]++;
166166 }
167167
168 static void blake2b_init0(hash_state *md)
168 static void s_blake2b_init0(hash_state *md)
169169 {
170170 unsigned long i;
171171 XMEMSET(&md->blake2b, 0, sizeof(md->blake2b));
176176 }
177177
178178 /* init xors IV with input parameter block */
179 static int blake2b_init_param(hash_state *md, const unsigned char *P)
179 static int s_blake2b_init_param(hash_state *md, const unsigned char *P)
180180 {
181181 unsigned long i;
182182
183 blake2b_init0(md);
183 s_blake2b_init0(md);
184184
185185 /* IV XOR ParamBlock */
186186 for (i = 0; i < 8; ++i) {
227227 P[O_FANOUT] = 1;
228228 P[O_DEPTH] = 1;
229229
230 err = blake2b_init_param(md, P);
230 err = s_blake2b_init_param(md, P);
231231 if (err != CRYPT_OK) return err;
232232
233233 if (key) {
298298 } while (0)
299299
300300 #ifdef LTC_CLEAN_STACK
301 static int _blake2b_compress(hash_state *md, const unsigned char *buf)
301 static int ss_blake2b_compress(hash_state *md, const unsigned char *buf)
302302 #else
303 static int blake2b_compress(hash_state *md, const unsigned char *buf)
303 static int s_blake2b_compress(hash_state *md, const unsigned char *buf)
304304 #endif
305305 {
306306 ulong64 m[16];
347347 #undef ROUND
348348
349349 #ifdef LTC_CLEAN_STACK
350 static int blake2b_compress(hash_state *md, const unsigned char *buf)
350 static int s_blake2b_compress(hash_state *md, const unsigned char *buf)
351351 {
352352 int err;
353 err = _blake2b_compress(md, buf);
353 err = ss_blake2b_compress(md, buf);
354354 burn_stack(sizeof(ulong64) * 32 + sizeof(unsigned long));
355355 return err;
356356 }
378378 if (inlen > fill) {
379379 md->blake2b.curlen = 0;
380380 XMEMCPY(md->blake2b.buf + (left % sizeof(md->blake2b.buf)), in, fill); /* Fill buffer */
381 blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
382 blake2b_compress(md, md->blake2b.buf); /* Compress */
381 s_blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
382 s_blake2b_compress(md, md->blake2b.buf); /* Compress */
383383 in += fill;
384384 inlen -= fill;
385385 while (inlen > BLAKE2B_BLOCKBYTES) {
386 blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
387 blake2b_compress(md, in);
386 s_blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
387 s_blake2b_compress(md, in);
388388 in += BLAKE2B_BLOCKBYTES;
389389 inlen -= BLAKE2B_BLOCKBYTES;
390390 }
411411
412412 /* if(md->blakebs.outlen != outlen) return CRYPT_INVALID_ARG; */
413413
414 if (blake2b_is_lastblock(md)) {
414 if (s_blake2b_is_lastblock(md)) {
415415 return CRYPT_ERROR;
416416 }
417417
418 blake2b_increment_counter(md, md->blake2b.curlen);
419 blake2b_set_lastblock(md);
418 s_blake2b_increment_counter(md, md->blake2b.curlen);
419 s_blake2b_set_lastblock(md);
420420 XMEMSET(md->blake2b.buf + md->blake2b.curlen, 0, BLAKE2B_BLOCKBYTES - md->blake2b.curlen); /* Padding */
421 blake2b_compress(md, md->blake2b.buf);
421 s_blake2b_compress(md, md->blake2b.buf);
422422
423423 for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */
424424 STORE64L(md->blake2b.h[i], buffer + i * 8);
138138 { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
139139 };
140140
141 static void blake2s_set_lastnode(hash_state *md) { md->blake2s.f[1] = 0xffffffffUL; }
141 static void s_blake2s_set_lastnode(hash_state *md) { md->blake2s.f[1] = 0xffffffffUL; }
142142
143143 /* Some helper functions, not necessarily useful */
144 static int blake2s_is_lastblock(const hash_state *md) { return md->blake2s.f[0] != 0; }
145
146 static void blake2s_set_lastblock(hash_state *md)
144 static int s_blake2s_is_lastblock(const hash_state *md) { return md->blake2s.f[0] != 0; }
145
146 static void s_blake2s_set_lastblock(hash_state *md)
147147 {
148148 if (md->blake2s.last_node) {
149 blake2s_set_lastnode(md);
149 s_blake2s_set_lastnode(md);
150150 }
151151 md->blake2s.f[0] = 0xffffffffUL;
152152 }
153153
154 static void blake2s_increment_counter(hash_state *md, const ulong32 inc)
154 static void s_blake2s_increment_counter(hash_state *md, const ulong32 inc)
155155 {
156156 md->blake2s.t[0] += inc;
157157 if (md->blake2s.t[0] < inc) md->blake2s.t[1]++;
158158 }
159159
160 static int blake2s_init0(hash_state *md)
160 static int s_blake2s_init0(hash_state *md)
161161 {
162162 int i;
163163 XMEMSET(&md->blake2s, 0, sizeof(struct blake2s_state));
170170 }
171171
172172 /* init2 xors IV with input parameter block */
173 static int blake2s_init_param(hash_state *md, const unsigned char *P)
173 static int s_blake2s_init_param(hash_state *md, const unsigned char *P)
174174 {
175175 unsigned long i;
176176
177 blake2s_init0(md);
177 s_blake2s_init0(md);
178178
179179 /* IV XOR ParamBlock */
180180 for (i = 0; i < 8; ++i) {
221221 P[O_FANOUT] = 1;
222222 P[O_DEPTH] = 1;
223223
224 err = blake2s_init_param(md, P);
224 err = s_blake2s_init_param(md, P);
225225 if (err != CRYPT_OK) return err;
226226
227227 if (key) {
290290 } while (0)
291291
292292 #ifdef LTC_CLEAN_STACK
293 static int _blake2s_compress(hash_state *md, const unsigned char *buf)
293 static int ss_blake2s_compress(hash_state *md, const unsigned char *buf)
294294 #else
295 static int blake2s_compress(hash_state *md, const unsigned char *buf)
295 static int s_blake2s_compress(hash_state *md, const unsigned char *buf)
296296 #endif
297297 {
298298 unsigned long i;
336336 #undef ROUND
337337
338338 #ifdef LTC_CLEAN_STACK
339 static int blake2s_compress(hash_state *md, const unsigned char *buf)
339 static int s_blake2s_compress(hash_state *md, const unsigned char *buf)
340340 {
341341 int err;
342 err = _blake2s_compress(md, buf);
342 err = ss_blake2s_compress(md, buf);
343343 burn_stack(sizeof(ulong32) * (32) + sizeof(unsigned long));
344344 return err;
345345 }
367367 if (inlen > fill) {
368368 md->blake2s.curlen = 0;
369369 XMEMCPY(md->blake2s.buf + (left % sizeof(md->blake2s.buf)), in, fill); /* Fill buffer */
370 blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES);
371 blake2s_compress(md, md->blake2s.buf); /* Compress */
370 s_blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES);
371 s_blake2s_compress(md, md->blake2s.buf); /* Compress */
372372 in += fill;
373373 inlen -= fill;
374374 while (inlen > BLAKE2S_BLOCKBYTES) {
375 blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES);
376 blake2s_compress(md, in);
375 s_blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES);
376 s_blake2s_compress(md, in);
377377 in += BLAKE2S_BLOCKBYTES;
378378 inlen -= BLAKE2S_BLOCKBYTES;
379379 }
400400
401401 /* if(md->blake2s.outlen != outlen) return CRYPT_INVALID_ARG; */
402402
403 if (blake2s_is_lastblock(md)) {
403 if (s_blake2s_is_lastblock(md)) {
404404 return CRYPT_ERROR;
405405 }
406 blake2s_increment_counter(md, md->blake2s.curlen);
407 blake2s_set_lastblock(md);
406 s_blake2s_increment_counter(md, md->blake2s.curlen);
407 s_blake2s_set_lastblock(md);
408408 XMEMSET(md->blake2s.buf + md->blake2s.curlen, 0, BLAKE2S_BLOCKBYTES - md->blake2s.curlen); /* Padding */
409 blake2s_compress(md, md->blake2s.buf);
409 s_blake2s_compress(md, md->blake2s.buf);
410410
411411 for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */
412412 STORE32L(md->blake2s.h[i], buffer + i * 4);
120120 T0 <= encrypt T0
121121 state <= state xor T0 xor T1
122122 */
123 static int chc_compress(hash_state *md, const unsigned char *buf)
123 static int s_chc_compress(hash_state *md, const unsigned char *buf)
124124 {
125125 unsigned char T[2][MAXBLOCKSIZE];
126126 symmetric_key *key;
153153 @param len The length of the data (octets)
154154 @return CRYPT_OK if successful
155155 */
156 static int _chc_process(hash_state * md, const unsigned char *in, unsigned long inlen);
157 static HASH_PROCESS(_chc_process, chc_compress, chc, (unsigned long)cipher_blocksize)
156 static int ss_chc_process(hash_state * md, const unsigned char *in, unsigned long inlen);
157 static HASH_PROCESS(ss_chc_process, s_chc_compress, chc, (unsigned long)cipher_blocksize)
158158
159159 /**
160160 Process a block of memory though the hash
178178 return CRYPT_INVALID_CIPHER;
179179 }
180180
181 return _chc_process(md, in, inlen);
181 return ss_chc_process(md, in, inlen);
182182 }
183183
184184 /**
220220 while (md->chc.curlen < (unsigned long)cipher_blocksize) {
221221 md->chc.buf[md->chc.curlen++] = (unsigned char)0;
222222 }
223 chc_compress(md, md->chc.buf);
223 s_chc_compress(md, md->chc.buf);
224224 md->chc.curlen = 0;
225225 }
226226
231231
232232 /* store length */
233233 STORE64L(md->chc.length, md->chc.buf+(cipher_blocksize-8));
234 chc_compress(md, md->chc.buf);
234 s_chc_compress(md, md->chc.buf);
235235
236236 /* copy output */
237237 XMEMCPY(out, md->chc.state, cipher_blocksize);
4848 };
4949
5050 /* adds 16 bytes to the checksum */
51 static void md2_update_chksum(hash_state *md)
51 static void s_md2_update_chksum(hash_state *md)
5252 {
5353 int j;
5454 unsigned char L;
6262 }
6363 }
6464
65 static void md2_compress(hash_state *md)
65 static void s_md2_compress(hash_state *md)
6666 {
6767 int j, k;
6868 unsigned char t;
125125
126126 /* is 16 bytes full? */
127127 if (md->md2.curlen == 16) {
128 md2_compress(md);
129 md2_update_chksum(md);
128 s_md2_compress(md);
129 s_md2_update_chksum(md);
130130 md->md2.curlen = 0;
131131 }
132132 }
158158 }
159159
160160 /* hash and update */
161 md2_compress(md);
162 md2_update_chksum(md);
161 s_md2_compress(md);
162 s_md2_update_chksum(md);
163163
164164 /* hash checksum */
165165 XMEMCPY(md->md2.buf, md->md2.chksum, 16);
166 md2_compress(md);
166 s_md2_compress(md);
167167
168168 /* output is lower 16 bytes of X */
169169 XMEMCPY(out, md->md2.X, 16);
6464 }
6565
6666 #ifdef LTC_CLEAN_STACK
67 static int _md4_compress(hash_state *md, const unsigned char *buf)
67 static int ss_md4_compress(hash_state *md, const unsigned char *buf)
6868 #else
69 static int md4_compress(hash_state *md, const unsigned char *buf)
69 static int s_md4_compress(hash_state *md, const unsigned char *buf)
7070 #endif
7171 {
7272 ulong32 x[16], a, b, c, d;
148148 }
149149
150150 #ifdef LTC_CLEAN_STACK
151 static int md4_compress(hash_state *md, const unsigned char *buf)
151 static int s_md4_compress(hash_state *md, const unsigned char *buf)
152152 {
153153 int err;
154 err = _md4_compress(md, buf);
154 err = ss_md4_compress(md, buf);
155155 burn_stack(sizeof(ulong32) * 20 + sizeof(int));
156156 return err;
157157 }
181181 @param inlen The length of the data (octets)
182182 @return CRYPT_OK if successful
183183 */
184 HASH_PROCESS(md4_process, md4_compress, md4, 64)
184 HASH_PROCESS(md4_process, s_md4_compress, md4, 64)
185185
186186 /**
187187 Terminate the hash to get the digest
214214 while (md->md4.curlen < 64) {
215215 md->md4.buf[md->md4.curlen++] = (unsigned char)0;
216216 }
217 md4_compress(md, md->md4.buf);
217 s_md4_compress(md, md->md4.buf);
218218 md->md4.curlen = 0;
219219 }
220220
225225
226226 /* store length */
227227 STORE64L(md->md4.length, md->md4.buf+56);
228 md4_compress(md, md->md4.buf);
228 s_md4_compress(md, md->md4.buf);
229229
230230 /* copy output */
231231 for (i = 0; i < 4; i++) {
8989 #endif
9090
9191 #ifdef LTC_CLEAN_STACK
92 static int _md5_compress(hash_state *md, const unsigned char *buf)
92 static int ss_md5_compress(hash_state *md, const unsigned char *buf)
9393 #else
94 static int md5_compress(hash_state *md, const unsigned char *buf)
94 static int s_md5_compress(hash_state *md, const unsigned char *buf)
9595 #endif
9696 {
9797 ulong32 i, W[16], a, b, c, d;
207207 }
208208
209209 #ifdef LTC_CLEAN_STACK
210 static int md5_compress(hash_state *md, const unsigned char *buf)
210 static int s_md5_compress(hash_state *md, const unsigned char *buf)
211211 {
212212 int err;
213 err = _md5_compress(md, buf);
213 err = ss_md5_compress(md, buf);
214214 burn_stack(sizeof(ulong32) * 21);
215215 return err;
216216 }
240240 @param inlen The length of the data (octets)
241241 @return CRYPT_OK if successful
242242 */
243 HASH_PROCESS(md5_process, md5_compress, md5, 64)
243 HASH_PROCESS(md5_process, s_md5_compress, md5, 64)
244244
245245 /**
246246 Terminate the hash to get the digest
274274 while (md->md5.curlen < 64) {
275275 md->md5.buf[md->md5.curlen++] = (unsigned char)0;
276276 }
277 md5_compress(md, md->md5.buf);
277 s_md5_compress(md, md->md5.buf);
278278 md->md5.curlen = 0;
279279 }
280280
285285
286286 /* store length */
287287 STORE64L(md->md5.length, md->md5.buf+56);
288 md5_compress(md, md->md5.buf);
288 s_md5_compress(md, md->md5.buf);
289289
290290 /* copy output */
291291 for (i = 0; i < 4; i++) {
7272 (a) = ROLc((a), (s));
7373
7474 #ifdef LTC_CLEAN_STACK
75 static int _rmd128_compress(hash_state *md, const unsigned char *buf)
75 static int ss_rmd128_compress(hash_state *md, const unsigned char *buf)
7676 #else
77 static int rmd128_compress(hash_state *md, const unsigned char *buf)
77 static int s_rmd128_compress(hash_state *md, const unsigned char *buf)
7878 #endif
7979 {
8080 ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,X[16];
246246 }
247247
248248 #ifdef LTC_CLEAN_STACK
249 static int rmd128_compress(hash_state *md, const unsigned char *buf)
249 static int s_rmd128_compress(hash_state *md, const unsigned char *buf)
250250 {
251251 int err;
252 err = _rmd128_compress(md, buf);
252 err = ss_rmd128_compress(md, buf);
253253 burn_stack(sizeof(ulong32) * 24 + sizeof(int));
254254 return err;
255255 }
279279 @param inlen The length of the data (octets)
280280 @return CRYPT_OK if successful
281281 */
282 HASH_PROCESS(rmd128_process, rmd128_compress, rmd128, 64)
282 HASH_PROCESS(rmd128_process, s_rmd128_compress, rmd128, 64)
283283
284284 /**
285285 Terminate the hash to get the digest
313313 while (md->rmd128.curlen < 64) {
314314 md->rmd128.buf[md->rmd128.curlen++] = (unsigned char)0;
315315 }
316 rmd128_compress(md, md->rmd128.buf);
316 s_rmd128_compress(md, md->rmd128.buf);
317317 md->rmd128.curlen = 0;
318318 }
319319
324324
325325 /* store length */
326326 STORE64L(md->rmd128.length, md->rmd128.buf+56);
327 rmd128_compress(md, md->rmd128.buf);
327 s_rmd128_compress(md, md->rmd128.buf);
328328
329329 /* copy output */
330330 for (i = 0; i < 4; i++) {
9292
9393
9494 #ifdef LTC_CLEAN_STACK
95 static int _rmd160_compress(hash_state *md, const unsigned char *buf)
95 static int ss_rmd160_compress(hash_state *md, const unsigned char *buf)
9696 #else
97 static int rmd160_compress(hash_state *md, const unsigned char *buf)
97 static int s_rmd160_compress(hash_state *md, const unsigned char *buf)
9898 #endif
9999 {
100100 ulong32 aa,bb,cc,dd,ee,aaa,bbb,ccc,ddd,eee,X[16];
304304 }
305305
306306 #ifdef LTC_CLEAN_STACK
307 static int rmd160_compress(hash_state *md, const unsigned char *buf)
307 static int s_rmd160_compress(hash_state *md, const unsigned char *buf)
308308 {
309309 int err;
310 err = _rmd160_compress(md, buf);
310 err = ss_rmd160_compress(md, buf);
311311 burn_stack(sizeof(ulong32) * 26 + sizeof(int));
312312 return err;
313313 }
338338 @param inlen The length of the data (octets)
339339 @return CRYPT_OK if successful
340340 */
341 HASH_PROCESS(rmd160_process, rmd160_compress, rmd160, 64)
341 HASH_PROCESS(rmd160_process, s_rmd160_compress, rmd160, 64)
342342
343343 /**
344344 Terminate the hash to get the digest
372372 while (md->rmd160.curlen < 64) {
373373 md->rmd160.buf[md->rmd160.curlen++] = (unsigned char)0;
374374 }
375 rmd160_compress(md, md->rmd160.buf);
375 s_rmd160_compress(md, md->rmd160.buf);
376376 md->rmd160.curlen = 0;
377377 }
378378
383383
384384 /* store length */
385385 STORE64L(md->rmd160.length, md->rmd160.buf+56);
386 rmd160_compress(md, md->rmd160.buf);
386 s_rmd160_compress(md, md->rmd160.buf);
387387
388388 /* copy output */
389389 for (i = 0; i < 5; i++) {
6666 (a) = ROLc((a), (s));
6767
6868 #ifdef LTC_CLEAN_STACK
69 static int _rmd256_compress(hash_state *md, const unsigned char *buf)
69 static int ss_rmd256_compress(hash_state *md, const unsigned char *buf)
7070 #else
71 static int rmd256_compress(hash_state *md, const unsigned char *buf)
71 static int s_rmd256_compress(hash_state *md, const unsigned char *buf)
7272 #endif
7373 {
7474 ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,tmp,X[16];
255255 }
256256
257257 #ifdef LTC_CLEAN_STACK
258 static int rmd256_compress(hash_state *md, const unsigned char *buf)
258 static int s_rmd256_compress(hash_state *md, const unsigned char *buf)
259259 {
260260 int err;
261 err = _rmd256_compress(md, buf);
261 err = ss_rmd256_compress(md, buf);
262262 burn_stack(sizeof(ulong32) * 25 + sizeof(int));
263263 return err;
264264 }
292292 @param inlen The length of the data (octets)
293293 @return CRYPT_OK if successful
294294 */
295 HASH_PROCESS(rmd256_process, rmd256_compress, rmd256, 64)
295 HASH_PROCESS(rmd256_process, s_rmd256_compress, rmd256, 64)
296296
297297 /**
298298 Terminate the hash to get the digest
326326 while (md->rmd256.curlen < 64) {
327327 md->rmd256.buf[md->rmd256.curlen++] = (unsigned char)0;
328328 }
329 rmd256_compress(md, md->rmd256.buf);
329 s_rmd256_compress(md, md->rmd256.buf);
330330 md->rmd256.curlen = 0;
331331 }
332332
337337
338338 /* store length */
339339 STORE64L(md->rmd256.length, md->rmd256.buf+56);
340 rmd256_compress(md, md->rmd256.buf);
340 s_rmd256_compress(md, md->rmd256.buf);
341341
342342 /* copy output */
343343 for (i = 0; i < 8; i++) {
8787
8888
8989 #ifdef LTC_CLEAN_STACK
90 static int _rmd320_compress(hash_state *md, const unsigned char *buf)
90 static int ss_rmd320_compress(hash_state *md, const unsigned char *buf)
9191 #else
92 static int rmd320_compress(hash_state *md, const unsigned char *buf)
92 static int s_rmd320_compress(hash_state *md, const unsigned char *buf)
9393 #endif
9494 {
9595 ulong32 aa,bb,cc,dd,ee,aaa,bbb,ccc,ddd,eee,tmp,X[16];
318318 }
319319
320320 #ifdef LTC_CLEAN_STACK
321 static int rmd320_compress(hash_state *md, const unsigned char *buf)
321 static int s_rmd320_compress(hash_state *md, const unsigned char *buf)
322322 {
323323 int err;
324 err = _rmd320_compress(md, buf);
324 err = ss_rmd320_compress(md, buf);
325325 burn_stack(sizeof(ulong32) * 27 + sizeof(int));
326326 return err;
327327 }
357357 @param inlen The length of the data (octets)
358358 @return CRYPT_OK if successful
359359 */
360 HASH_PROCESS(rmd320_process, rmd320_compress, rmd320, 64)
360 HASH_PROCESS(rmd320_process, s_rmd320_compress, rmd320, 64)
361361
362362 /**
363363 Terminate the hash to get the digest
391391 while (md->rmd320.curlen < 64) {
392392 md->rmd320.buf[md->rmd320.curlen++] = (unsigned char)0;
393393 }
394 rmd320_compress(md, md->rmd320.buf);
394 s_rmd320_compress(md, md->rmd320.buf);
395395 md->rmd320.curlen = 0;
396396 }
397397
402402
403403 /* store length */
404404 STORE64L(md->rmd320.length, md->rmd320.buf+56);
405 rmd320_compress(md, md->rmd320.buf);
405 s_rmd320_compress(md, md->rmd320.buf);
406406
407407 /* copy output */
408408 for (i = 0; i < 10; i++) {
+7
-7