diff --git a/Changes b/Changes index 156cfe2..be4792e 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,9 @@ Changes for CryptX + +0.070 2021-02-12 + - fix #66 remove -flto=auto (Makefile.PL) + - fix #65 typo in docs (lib/Crypt/Cipher.pm) + - bundled libtomcrypt update branch:develop (commit:910d6252 2021-01-19) 0.069 2020-08-25 - fix #64 ECC: segfault on invalid input diff --git a/META.json b/META.json index 7b1a3be..86b847d 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Karel Miko" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010", + "generated_by" : "ExtUtils::MakeMaker version 7.58, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], @@ -50,6 +50,6 @@ "url" : "https://github.com/DCIT/perl-CryptX" } }, - "version" : "0.069", + "version" : "0.070", "x_serialization_backend" : "JSON::PP version 4.05" } diff --git a/META.yml b/META.yml index 1773663..3bca656 100644 --- a/META.yml +++ b/META.yml @@ -8,7 +8,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010' +generated_by: 'ExtUtils::MakeMaker version 7.58, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -23,5 +23,5 @@ resources: bugtracker: https://github.com/DCIT/perl-CryptX/issues repository: https://github.com/DCIT/perl-CryptX -version: '0.069' +version: '0.070' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/Makefile.PL b/Makefile.PL index 72e1d02..5f1ffaf 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -32,6 +32,8 @@ $mycflags .= " $ENV{CPPFLAGS}" if $ENV{CPPFLAGS}; #FIX: gcc with -flto is a trouble maker see https://github.com/DCIT/perl-CryptX/issues/32 + #FIX: another issue with "-flto=auto" see https://github.com/DCIT/perl-CryptX/pull/66 + $mycflags =~ s/-flto=[a-zA-Z0-9]+//g; # -flto=auto -flto=jobserver -flto=N ... $mycflags =~ s/-flto\b//g; #FIX: avoid -Wwrite-strings -Wcast-qual -pedantic -pedantic-errors -ansi -std=c89 diff --git a/lib/Crypt/AuthEnc/CCM.pm b/lib/Crypt/AuthEnc/CCM.pm index 288cd78..7d46c1e 100644 --- a/lib/Crypt/AuthEnc/CCM.pm +++ b/lib/Crypt/AuthEnc/CCM.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] ); diff --git a/lib/Crypt/AuthEnc/ChaCha20Poly1305.pm b/lib/Crypt/AuthEnc/ChaCha20Poly1305.pm index 15f81a5..839f9d7 100644 --- a/lib/Crypt/AuthEnc/ChaCha20Poly1305.pm +++ b/lib/Crypt/AuthEnc/ChaCha20Poly1305.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] ); diff --git a/lib/Crypt/AuthEnc/EAX.pm b/lib/Crypt/AuthEnc/EAX.pm index fe6396b..9bba5f2 100644 --- a/lib/Crypt/AuthEnc/EAX.pm +++ b/lib/Crypt/AuthEnc/EAX.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] ); diff --git a/lib/Crypt/AuthEnc/GCM.pm b/lib/Crypt/AuthEnc/GCM.pm index 0f3b1aa..b0b161a 100644 --- a/lib/Crypt/AuthEnc/GCM.pm +++ b/lib/Crypt/AuthEnc/GCM.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] ); diff --git a/lib/Crypt/AuthEnc/OCB.pm b/lib/Crypt/AuthEnc/OCB.pm index f572a0c..a4d3cec 100644 --- a/lib/Crypt/AuthEnc/OCB.pm +++ b/lib/Crypt/AuthEnc/OCB.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] ); diff --git a/lib/Crypt/AuthEnc.pm b/lib/Crypt/AuthEnc.pm index 779a6dd..cb1ce39 100644 --- a/lib/Crypt/AuthEnc.pm +++ b/lib/Crypt/AuthEnc.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; ### not used diff --git a/lib/Crypt/Checksum/Adler32.pm b/lib/Crypt/Checksum/Adler32.pm index eb476e8..9b7bd32 100644 --- a/lib/Crypt/Checksum/Adler32.pm +++ b/lib/Crypt/Checksum/Adler32.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Checksum Exporter); our %EXPORT_TAGS = ( all => [qw( adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int )] ); diff --git a/lib/Crypt/Checksum/CRC32.pm b/lib/Crypt/Checksum/CRC32.pm index f134b15..f03dea0 100644 --- a/lib/Crypt/Checksum/CRC32.pm +++ b/lib/Crypt/Checksum/CRC32.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Checksum Exporter); our %EXPORT_TAGS = ( all => [qw( crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int )] ); diff --git a/lib/Crypt/Checksum.pm b/lib/Crypt/Checksum.pm index 7dbb171..650d9d2 100644 --- a/lib/Crypt/Checksum.pm +++ b/lib/Crypt/Checksum.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int diff --git a/lib/Crypt/Cipher/AES.pm b/lib/Crypt/Cipher/AES.pm index 040ecf8..f2b6320 100644 --- a/lib/Crypt/Cipher/AES.pm +++ b/lib/Crypt/Cipher/AES.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Anubis.pm b/lib/Crypt/Cipher/Anubis.pm index 3be4364..1a78d42 100644 --- a/lib/Crypt/Cipher/Anubis.pm +++ b/lib/Crypt/Cipher/Anubis.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Blowfish.pm b/lib/Crypt/Cipher/Blowfish.pm index cb4e442..74bb37a 100644 --- a/lib/Crypt/Cipher/Blowfish.pm +++ b/lib/Crypt/Cipher/Blowfish.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/CAST5.pm b/lib/Crypt/Cipher/CAST5.pm index 215363b..19ac992 100644 --- a/lib/Crypt/Cipher/CAST5.pm +++ b/lib/Crypt/Cipher/CAST5.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Camellia.pm b/lib/Crypt/Cipher/Camellia.pm index a336614..03e1fc7 100644 --- a/lib/Crypt/Cipher/Camellia.pm +++ b/lib/Crypt/Cipher/Camellia.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/DES.pm b/lib/Crypt/Cipher/DES.pm index 5b7c06d..20e076a 100644 --- a/lib/Crypt/Cipher/DES.pm +++ b/lib/Crypt/Cipher/DES.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/DES_EDE.pm b/lib/Crypt/Cipher/DES_EDE.pm index 2199678..1a6220a 100644 --- a/lib/Crypt/Cipher/DES_EDE.pm +++ b/lib/Crypt/Cipher/DES_EDE.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/IDEA.pm b/lib/Crypt/Cipher/IDEA.pm index 79c0b00..9f0b787 100644 --- a/lib/Crypt/Cipher/IDEA.pm +++ b/lib/Crypt/Cipher/IDEA.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/KASUMI.pm b/lib/Crypt/Cipher/KASUMI.pm index 7dfaa2c..1707485 100644 --- a/lib/Crypt/Cipher/KASUMI.pm +++ b/lib/Crypt/Cipher/KASUMI.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Khazad.pm b/lib/Crypt/Cipher/Khazad.pm index 37ebdd7..5f968b3 100644 --- a/lib/Crypt/Cipher/Khazad.pm +++ b/lib/Crypt/Cipher/Khazad.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/MULTI2.pm b/lib/Crypt/Cipher/MULTI2.pm index 5113ee3..e2ac7df 100644 --- a/lib/Crypt/Cipher/MULTI2.pm +++ b/lib/Crypt/Cipher/MULTI2.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Noekeon.pm b/lib/Crypt/Cipher/Noekeon.pm index 4aeb9c3..59d0e81 100644 --- a/lib/Crypt/Cipher/Noekeon.pm +++ b/lib/Crypt/Cipher/Noekeon.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/RC2.pm b/lib/Crypt/Cipher/RC2.pm index bd79afc..6095503 100644 --- a/lib/Crypt/Cipher/RC2.pm +++ b/lib/Crypt/Cipher/RC2.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/RC5.pm b/lib/Crypt/Cipher/RC5.pm index 8c20d26..4738eae 100644 --- a/lib/Crypt/Cipher/RC5.pm +++ b/lib/Crypt/Cipher/RC5.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/RC6.pm b/lib/Crypt/Cipher/RC6.pm index 791d485..a8e3eff 100644 --- a/lib/Crypt/Cipher/RC6.pm +++ b/lib/Crypt/Cipher/RC6.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/SAFERP.pm b/lib/Crypt/Cipher/SAFERP.pm index 56f188c..5defae6 100644 --- a/lib/Crypt/Cipher/SAFERP.pm +++ b/lib/Crypt/Cipher/SAFERP.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/SAFER_K128.pm b/lib/Crypt/Cipher/SAFER_K128.pm index 71cd53b..287dc5b 100644 --- a/lib/Crypt/Cipher/SAFER_K128.pm +++ b/lib/Crypt/Cipher/SAFER_K128.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/SAFER_K64.pm b/lib/Crypt/Cipher/SAFER_K64.pm index 58895f0..cc96466 100644 --- a/lib/Crypt/Cipher/SAFER_K64.pm +++ b/lib/Crypt/Cipher/SAFER_K64.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/SAFER_SK128.pm b/lib/Crypt/Cipher/SAFER_SK128.pm index cda2c8b..ade2715 100644 --- a/lib/Crypt/Cipher/SAFER_SK128.pm +++ b/lib/Crypt/Cipher/SAFER_SK128.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/SAFER_SK64.pm b/lib/Crypt/Cipher/SAFER_SK64.pm index fde477e..7cebd88 100644 --- a/lib/Crypt/Cipher/SAFER_SK64.pm +++ b/lib/Crypt/Cipher/SAFER_SK64.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/SEED.pm b/lib/Crypt/Cipher/SEED.pm index 6541d9e..bb4974d 100644 --- a/lib/Crypt/Cipher/SEED.pm +++ b/lib/Crypt/Cipher/SEED.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Serpent.pm b/lib/Crypt/Cipher/Serpent.pm index 4cae97a..ff9533c 100644 --- a/lib/Crypt/Cipher/Serpent.pm +++ b/lib/Crypt/Cipher/Serpent.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Skipjack.pm b/lib/Crypt/Cipher/Skipjack.pm index 226aa21..bd4fb0d 100644 --- a/lib/Crypt/Cipher/Skipjack.pm +++ b/lib/Crypt/Cipher/Skipjack.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/Twofish.pm b/lib/Crypt/Cipher/Twofish.pm index 88b0453..4ebf85c 100644 --- a/lib/Crypt/Cipher/Twofish.pm +++ b/lib/Crypt/Cipher/Twofish.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher/XTEA.pm b/lib/Crypt/Cipher/XTEA.pm index e1edab1..d7d9c72 100644 --- a/lib/Crypt/Cipher/XTEA.pm +++ b/lib/Crypt/Cipher/XTEA.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Cipher); diff --git a/lib/Crypt/Cipher.pm b/lib/Crypt/Cipher.pm index ac2a5dd..c1db4b2 100644 --- a/lib/Crypt/Cipher.pm +++ b/lib/Crypt/Cipher.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Carp; $Carp::Internal{(__PACKAGE__)}++; @@ -96,7 +96,7 @@ Decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of B bytes. - $plaintext = $d->encrypt($ciphertext); + $plaintext = $d->decrypt($ciphertext); =head2 keysize diff --git a/lib/Crypt/Digest/BLAKE2b_160.pm b/lib/Crypt/Digest/BLAKE2b_160.pm index f7c6ee3..6284452 100644 --- a/lib/Crypt/Digest/BLAKE2b_160.pm +++ b/lib/Crypt/Digest/BLAKE2b_160.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2b_256.pm b/lib/Crypt/Digest/BLAKE2b_256.pm index ddf2061..84d89a8 100644 --- a/lib/Crypt/Digest/BLAKE2b_256.pm +++ b/lib/Crypt/Digest/BLAKE2b_256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2b_384.pm b/lib/Crypt/Digest/BLAKE2b_384.pm index a8a1b7b..677dc0a 100644 --- a/lib/Crypt/Digest/BLAKE2b_384.pm +++ b/lib/Crypt/Digest/BLAKE2b_384.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2b_512.pm b/lib/Crypt/Digest/BLAKE2b_512.pm index 8a631af..210efbd 100644 --- a/lib/Crypt/Digest/BLAKE2b_512.pm +++ b/lib/Crypt/Digest/BLAKE2b_512.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2s_128.pm b/lib/Crypt/Digest/BLAKE2s_128.pm index 5d7368b..b45a9a9 100644 --- a/lib/Crypt/Digest/BLAKE2s_128.pm +++ b/lib/Crypt/Digest/BLAKE2s_128.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2s_160.pm b/lib/Crypt/Digest/BLAKE2s_160.pm index 249ca55..116e09e 100644 --- a/lib/Crypt/Digest/BLAKE2s_160.pm +++ b/lib/Crypt/Digest/BLAKE2s_160.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2s_224.pm b/lib/Crypt/Digest/BLAKE2s_224.pm index 3ab6de9..7aa240f 100644 --- a/lib/Crypt/Digest/BLAKE2s_224.pm +++ b/lib/Crypt/Digest/BLAKE2s_224.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/BLAKE2s_256.pm b/lib/Crypt/Digest/BLAKE2s_256.pm index bb84060..77276ba 100644 --- a/lib/Crypt/Digest/BLAKE2s_256.pm +++ b/lib/Crypt/Digest/BLAKE2s_256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/CHAES.pm b/lib/Crypt/Digest/CHAES.pm index eb33a03..03f6a42 100644 --- a/lib/Crypt/Digest/CHAES.pm +++ b/lib/Crypt/Digest/CHAES.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( chaes chaes_hex chaes_b64 chaes_b64u chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u )] ); diff --git a/lib/Crypt/Digest/Keccak224.pm b/lib/Crypt/Digest/Keccak224.pm index e435447..cd6b755 100644 --- a/lib/Crypt/Digest/Keccak224.pm +++ b/lib/Crypt/Digest/Keccak224.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u )] ); diff --git a/lib/Crypt/Digest/Keccak256.pm b/lib/Crypt/Digest/Keccak256.pm index 2c2c030..500887c 100644 --- a/lib/Crypt/Digest/Keccak256.pm +++ b/lib/Crypt/Digest/Keccak256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u )] ); diff --git a/lib/Crypt/Digest/Keccak384.pm b/lib/Crypt/Digest/Keccak384.pm index 14e0e16..0ee47d0 100644 --- a/lib/Crypt/Digest/Keccak384.pm +++ b/lib/Crypt/Digest/Keccak384.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( keccak384 keccak384_hex keccak384_b64 keccak384_b64u keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u )] ); diff --git a/lib/Crypt/Digest/Keccak512.pm b/lib/Crypt/Digest/Keccak512.pm index 84039e3..802c5f7 100644 --- a/lib/Crypt/Digest/Keccak512.pm +++ b/lib/Crypt/Digest/Keccak512.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( keccak512 keccak512_hex keccak512_b64 keccak512_b64u keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u )] ); diff --git a/lib/Crypt/Digest/MD2.pm b/lib/Crypt/Digest/MD2.pm index 8964946..90e3c37 100644 --- a/lib/Crypt/Digest/MD2.pm +++ b/lib/Crypt/Digest/MD2.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( md2 md2_hex md2_b64 md2_b64u md2_file md2_file_hex md2_file_b64 md2_file_b64u )] ); diff --git a/lib/Crypt/Digest/MD4.pm b/lib/Crypt/Digest/MD4.pm index 3b21a8f..521cd40 100644 --- a/lib/Crypt/Digest/MD4.pm +++ b/lib/Crypt/Digest/MD4.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( md4 md4_hex md4_b64 md4_b64u md4_file md4_file_hex md4_file_b64 md4_file_b64u )] ); diff --git a/lib/Crypt/Digest/MD5.pm b/lib/Crypt/Digest/MD5.pm index 8565414..2d2ddf8 100644 --- a/lib/Crypt/Digest/MD5.pm +++ b/lib/Crypt/Digest/MD5.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( md5 md5_hex md5_b64 md5_b64u md5_file md5_file_hex md5_file_b64 md5_file_b64u )] ); diff --git a/lib/Crypt/Digest/RIPEMD128.pm b/lib/Crypt/Digest/RIPEMD128.pm index 51d75fd..5c2fd48 100644 --- a/lib/Crypt/Digest/RIPEMD128.pm +++ b/lib/Crypt/Digest/RIPEMD128.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u )] ); diff --git a/lib/Crypt/Digest/RIPEMD160.pm b/lib/Crypt/Digest/RIPEMD160.pm index a249b10..dda6577 100644 --- a/lib/Crypt/Digest/RIPEMD160.pm +++ b/lib/Crypt/Digest/RIPEMD160.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u )] ); diff --git a/lib/Crypt/Digest/RIPEMD256.pm b/lib/Crypt/Digest/RIPEMD256.pm index 22b83da..5c86122 100644 --- a/lib/Crypt/Digest/RIPEMD256.pm +++ b/lib/Crypt/Digest/RIPEMD256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u )] ); diff --git a/lib/Crypt/Digest/RIPEMD320.pm b/lib/Crypt/Digest/RIPEMD320.pm index a438e95..53cc81b 100644 --- a/lib/Crypt/Digest/RIPEMD320.pm +++ b/lib/Crypt/Digest/RIPEMD320.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u )] ); diff --git a/lib/Crypt/Digest/SHA1.pm b/lib/Crypt/Digest/SHA1.pm index 1997a01..00e5bb8 100644 --- a/lib/Crypt/Digest/SHA1.pm +++ b/lib/Crypt/Digest/SHA1.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( sha1 sha1_hex sha1_b64 sha1_b64u sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u )] ); diff --git a/lib/Crypt/Digest/SHA224.pm b/lib/Crypt/Digest/SHA224.pm index c391023..e96aba2 100644 --- a/lib/Crypt/Digest/SHA224.pm +++ b/lib/Crypt/Digest/SHA224.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( sha224 sha224_hex sha224_b64 sha224_b64u sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u )] ); diff --git a/lib/Crypt/Digest/SHA256.pm b/lib/Crypt/Digest/SHA256.pm index 5c7d249..0002eb0 100644 --- a/lib/Crypt/Digest/SHA256.pm +++ b/lib/Crypt/Digest/SHA256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( sha256 sha256_hex sha256_b64 sha256_b64u sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u )] ); diff --git a/lib/Crypt/Digest/SHA384.pm b/lib/Crypt/Digest/SHA384.pm index 7510cda..f5f3be0 100644 --- a/lib/Crypt/Digest/SHA384.pm +++ b/lib/Crypt/Digest/SHA384.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( sha384 sha384_hex sha384_b64 sha384_b64u sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u )] ); diff --git a/lib/Crypt/Digest/SHA3_224.pm b/lib/Crypt/Digest/SHA3_224.pm index 12bb518..1a33de1 100644 --- a/lib/Crypt/Digest/SHA3_224.pm +++ b/lib/Crypt/Digest/SHA3_224.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/SHA3_256.pm b/lib/Crypt/Digest/SHA3_256.pm index 865f576..8728e16 100644 --- a/lib/Crypt/Digest/SHA3_256.pm +++ b/lib/Crypt/Digest/SHA3_256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/SHA3_384.pm b/lib/Crypt/Digest/SHA3_384.pm index 91ed8e9..15b58e0 100644 --- a/lib/Crypt/Digest/SHA3_384.pm +++ b/lib/Crypt/Digest/SHA3_384.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/SHA3_512.pm b/lib/Crypt/Digest/SHA3_512.pm index b7cb792..e3c929c 100644 --- a/lib/Crypt/Digest/SHA3_512.pm +++ b/lib/Crypt/Digest/SHA3_512.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/SHA512.pm b/lib/Crypt/Digest/SHA512.pm index 18d07e8..64efbca 100644 --- a/lib/Crypt/Digest/SHA512.pm +++ b/lib/Crypt/Digest/SHA512.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( sha512 sha512_hex sha512_b64 sha512_b64u sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u )] ); diff --git a/lib/Crypt/Digest/SHA512_224.pm b/lib/Crypt/Digest/SHA512_224.pm index 62e91cb..bd1f66c 100644 --- a/lib/Crypt/Digest/SHA512_224.pm +++ b/lib/Crypt/Digest/SHA512_224.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/SHA512_256.pm b/lib/Crypt/Digest/SHA512_256.pm index c3fc7f1..2a09f34 100644 --- a/lib/Crypt/Digest/SHA512_256.pm +++ b/lib/Crypt/Digest/SHA512_256.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); 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 )] ); diff --git a/lib/Crypt/Digest/SHAKE.pm b/lib/Crypt/Digest/SHAKE.pm index 7a0c0de..e6a1989 100644 --- a/lib/Crypt/Digest/SHAKE.pm +++ b/lib/Crypt/Digest/SHAKE.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Carp; $Carp::Internal{(__PACKAGE__)}++; diff --git a/lib/Crypt/Digest/Tiger192.pm b/lib/Crypt/Digest/Tiger192.pm index 4046d04..0cfbc50 100644 --- a/lib/Crypt/Digest/Tiger192.pm +++ b/lib/Crypt/Digest/Tiger192.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( tiger192 tiger192_hex tiger192_b64 tiger192_b64u tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u )] ); diff --git a/lib/Crypt/Digest/Whirlpool.pm b/lib/Crypt/Digest/Whirlpool.pm index 87e87e6..60505cc 100644 --- a/lib/Crypt/Digest/Whirlpool.pm +++ b/lib/Crypt/Digest/Whirlpool.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Digest Exporter); our %EXPORT_TAGS = ( all => [qw( whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u )] ); diff --git a/lib/Crypt/Digest.pm b/lib/Crypt/Digest.pm index c264b69..389da32 100644 --- a/lib/Crypt/Digest.pm +++ b/lib/Crypt/Digest.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; 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 )] ); diff --git a/lib/Crypt/KeyDerivation.pm b/lib/Crypt/KeyDerivation.pm index 9963f51..b625fe4 100644 --- a/lib/Crypt/KeyDerivation.pm +++ b/lib/Crypt/KeyDerivation.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw(pbkdf1 pbkdf2 hkdf hkdf_expand hkdf_extract)] ); diff --git a/lib/Crypt/Mac/BLAKE2b.pm b/lib/Crypt/Mac/BLAKE2b.pm index b3c5d10..7a2a104 100644 --- a/lib/Crypt/Mac/BLAKE2b.pm +++ b/lib/Crypt/Mac/BLAKE2b.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( blake2b blake2b_hex blake2b_b64 blake2b_b64u )] ); diff --git a/lib/Crypt/Mac/BLAKE2s.pm b/lib/Crypt/Mac/BLAKE2s.pm index 7da400b..9f72b37 100644 --- a/lib/Crypt/Mac/BLAKE2s.pm +++ b/lib/Crypt/Mac/BLAKE2s.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u )] ); diff --git a/lib/Crypt/Mac/F9.pm b/lib/Crypt/Mac/F9.pm index 7bbdea4..185a7a3 100644 --- a/lib/Crypt/Mac/F9.pm +++ b/lib/Crypt/Mac/F9.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( f9 f9_hex f9_b64 f9_b64u )] ); diff --git a/lib/Crypt/Mac/HMAC.pm b/lib/Crypt/Mac/HMAC.pm index ed55882..da8eb20 100644 --- a/lib/Crypt/Mac/HMAC.pm +++ b/lib/Crypt/Mac/HMAC.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( hmac hmac_hex hmac_b64 hmac_b64u )] ); diff --git a/lib/Crypt/Mac/OMAC.pm b/lib/Crypt/Mac/OMAC.pm index 7f1134c..1f0ed63 100644 --- a/lib/Crypt/Mac/OMAC.pm +++ b/lib/Crypt/Mac/OMAC.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 omac_b64u )] ); diff --git a/lib/Crypt/Mac/PMAC.pm b/lib/Crypt/Mac/PMAC.pm index 51b20b9..66c1dbd 100644 --- a/lib/Crypt/Mac/PMAC.pm +++ b/lib/Crypt/Mac/PMAC.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( pmac pmac_hex pmac_b64 pmac_b64u )] ); diff --git a/lib/Crypt/Mac/Pelican.pm b/lib/Crypt/Mac/Pelican.pm index 043f973..3f190d1 100644 --- a/lib/Crypt/Mac/Pelican.pm +++ b/lib/Crypt/Mac/Pelican.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( pelican pelican_hex pelican_b64 pelican_b64u )] ); diff --git a/lib/Crypt/Mac/Poly1305.pm b/lib/Crypt/Mac/Poly1305.pm index eec58b1..79664e8 100644 --- a/lib/Crypt/Mac/Poly1305.pm +++ b/lib/Crypt/Mac/Poly1305.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( poly1305 poly1305_hex poly1305_b64 poly1305_b64u )] ); diff --git a/lib/Crypt/Mac/XCBC.pm b/lib/Crypt/Mac/XCBC.pm index cbd6793..1e764c0 100644 --- a/lib/Crypt/Mac/XCBC.pm +++ b/lib/Crypt/Mac/XCBC.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::Mac Exporter); our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 xcbc_b64u )] ); diff --git a/lib/Crypt/Mac.pm b/lib/Crypt/Mac.pm index 1069022..85d5075 100644 --- a/lib/Crypt/Mac.pm +++ b/lib/Crypt/Mac.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Carp; $Carp::Internal{(__PACKAGE__)}++; diff --git a/lib/Crypt/Misc.pm b/lib/Crypt/Misc.pm index e0a2e40..e4df149 100644 --- a/lib/Crypt/Misc.pm +++ b/lib/Crypt/Misc.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; use Carp 'croak'; diff --git a/lib/Crypt/Mode/CBC.pm b/lib/Crypt/Mode/CBC.pm index 33307da..d9738d3 100644 --- a/lib/Crypt/Mode/CBC.pm +++ b/lib/Crypt/Mode/CBC.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Crypt::Cipher; diff --git a/lib/Crypt/Mode/CFB.pm b/lib/Crypt/Mode/CFB.pm index 415e13d..ef02c20 100644 --- a/lib/Crypt/Mode/CFB.pm +++ b/lib/Crypt/Mode/CFB.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Crypt::Cipher; diff --git a/lib/Crypt/Mode/CTR.pm b/lib/Crypt/Mode/CTR.pm index a88e5a1..40726cf 100644 --- a/lib/Crypt/Mode/CTR.pm +++ b/lib/Crypt/Mode/CTR.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Crypt::Cipher; diff --git a/lib/Crypt/Mode/ECB.pm b/lib/Crypt/Mode/ECB.pm index ebb774a..7bddf25 100644 --- a/lib/Crypt/Mode/ECB.pm +++ b/lib/Crypt/Mode/ECB.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Crypt::Cipher; diff --git a/lib/Crypt/Mode/OFB.pm b/lib/Crypt/Mode/OFB.pm index c30d341..1e7cddc 100644 --- a/lib/Crypt/Mode/OFB.pm +++ b/lib/Crypt/Mode/OFB.pm @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Crypt::Cipher; diff --git a/lib/Crypt/Mode.pm b/lib/Crypt/Mode.pm index eac93fb..1b4f5a7 100644 --- a/lib/Crypt/Mode.pm +++ b/lib/Crypt/Mode.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; ### not used diff --git a/lib/Crypt/PK/DH.pm b/lib/Crypt/PK/DH.pm index 0e2ec79..4b77d43 100644 --- a/lib/Crypt/PK/DH.pm +++ b/lib/Crypt/PK/DH.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( dh_shared_secret )] ); diff --git a/lib/Crypt/PK/DSA.pm b/lib/Crypt/PK/DSA.pm index a511ee2..f7df618 100644 --- a/lib/Crypt/PK/DSA.pm +++ b/lib/Crypt/PK/DSA.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( dsa_encrypt dsa_decrypt dsa_sign_message dsa_verify_message dsa_sign_hash dsa_verify_hash )] ); diff --git a/lib/Crypt/PK/ECC.pm b/lib/Crypt/PK/ECC.pm index cf5c1d9..f320a42 100644 --- a/lib/Crypt/PK/ECC.pm +++ b/lib/Crypt/PK/ECC.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( ecc_encrypt ecc_decrypt ecc_sign_message ecc_verify_message ecc_sign_hash ecc_verify_hash ecc_shared_secret )] ); diff --git a/lib/Crypt/PK/Ed25519.pm b/lib/Crypt/PK/Ed25519.pm index 9774909..e28f899 100644 --- a/lib/Crypt/PK/Ed25519.pm +++ b/lib/Crypt/PK/Ed25519.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( )] ); diff --git a/lib/Crypt/PK/RSA.pm b/lib/Crypt/PK/RSA.pm index 80c4995..cec73b7 100644 --- a/lib/Crypt/PK/RSA.pm +++ b/lib/Crypt/PK/RSA.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw(rsa_encrypt rsa_decrypt rsa_sign_message rsa_verify_message rsa_sign_hash rsa_verify_hash)] ); diff --git a/lib/Crypt/PK/X25519.pm b/lib/Crypt/PK/X25519.pm index e6cb0cf..2c57806 100644 --- a/lib/Crypt/PK/X25519.pm +++ b/lib/Crypt/PK/X25519.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw( )] ); diff --git a/lib/Crypt/PK.pm b/lib/Crypt/PK.pm index 7da79ae..de962c0 100644 --- a/lib/Crypt/PK.pm +++ b/lib/Crypt/PK.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use Carp; diff --git a/lib/Crypt/PRNG/ChaCha20.pm b/lib/Crypt/PRNG/ChaCha20.pm index feb8030..f0dd691 100644 --- a/lib/Crypt/PRNG/ChaCha20.pm +++ b/lib/Crypt/PRNG/ChaCha20.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::PRNG Exporter); our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); diff --git a/lib/Crypt/PRNG/Fortuna.pm b/lib/Crypt/PRNG/Fortuna.pm index 02d2f30..559cb4c 100644 --- a/lib/Crypt/PRNG/Fortuna.pm +++ b/lib/Crypt/PRNG/Fortuna.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::PRNG Exporter); our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); diff --git a/lib/Crypt/PRNG/RC4.pm b/lib/Crypt/PRNG/RC4.pm index 45a796b..b1b818e 100644 --- a/lib/Crypt/PRNG/RC4.pm +++ b/lib/Crypt/PRNG/RC4.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::PRNG Exporter); our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); diff --git a/lib/Crypt/PRNG/Sober128.pm b/lib/Crypt/PRNG/Sober128.pm index d4726e8..0fc5ae1 100644 --- a/lib/Crypt/PRNG/Sober128.pm +++ b/lib/Crypt/PRNG/Sober128.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::PRNG Exporter); our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); diff --git a/lib/Crypt/PRNG/Yarrow.pm b/lib/Crypt/PRNG/Yarrow.pm index b5c29c3..b502ce4 100644 --- a/lib/Crypt/PRNG/Yarrow.pm +++ b/lib/Crypt/PRNG/Yarrow.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use base qw(Crypt::PRNG Exporter); our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); diff --git a/lib/Crypt/PRNG.pm b/lib/Crypt/PRNG.pm index 10d18d3..c30173a 100644 --- a/lib/Crypt/PRNG.pm +++ b/lib/Crypt/PRNG.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); diff --git a/lib/Crypt/Stream/ChaCha.pm b/lib/Crypt/Stream/ChaCha.pm index fffedb4..fc12da8 100644 --- a/lib/Crypt/Stream/ChaCha.pm +++ b/lib/Crypt/Stream/ChaCha.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; diff --git a/lib/Crypt/Stream/RC4.pm b/lib/Crypt/Stream/RC4.pm index a3c9ae4..cba8385 100644 --- a/lib/Crypt/Stream/RC4.pm +++ b/lib/Crypt/Stream/RC4.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; diff --git a/lib/Crypt/Stream/Rabbit.pm b/lib/Crypt/Stream/Rabbit.pm index e2d5274..60cc972 100644 --- a/lib/Crypt/Stream/Rabbit.pm +++ b/lib/Crypt/Stream/Rabbit.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; diff --git a/lib/Crypt/Stream/Salsa20.pm b/lib/Crypt/Stream/Salsa20.pm index 9917f57..ad88790 100644 --- a/lib/Crypt/Stream/Salsa20.pm +++ b/lib/Crypt/Stream/Salsa20.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; diff --git a/lib/Crypt/Stream/Sober128.pm b/lib/Crypt/Stream/Sober128.pm index ddeccb1..ec8a8fe 100644 --- a/lib/Crypt/Stream/Sober128.pm +++ b/lib/Crypt/Stream/Sober128.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; diff --git a/lib/Crypt/Stream/Sosemanuk.pm b/lib/Crypt/Stream/Sosemanuk.pm index 962a82f..8a87b17 100644 --- a/lib/Crypt/Stream/Sosemanuk.pm +++ b/lib/Crypt/Stream/Sosemanuk.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; diff --git a/lib/CryptX.pm b/lib/CryptX.pm index e72f8ef..d16431c 100644 --- a/lib/CryptX.pm +++ b/lib/CryptX.pm @@ -2,7 +2,7 @@ use strict; use warnings ; -our $VERSION = '0.069'; +our $VERSION = '0.070'; require XSLoader; XSLoader::load('CryptX', $VERSION); diff --git a/lib/Math/BigInt/LTM.pm b/lib/Math/BigInt/LTM.pm index 57d43ad..ebf71ca 100644 --- a/lib/Math/BigInt/LTM.pm +++ b/lib/Math/BigInt/LTM.pm @@ -2,7 +2,7 @@ use strict; use warnings; -our $VERSION = '0.069'; +our $VERSION = '0.070'; use CryptX; use Carp; diff --git a/src/ltc/ciphers/aes/aes.c b/src/ltc/ciphers/aes/aes.c index 9e1bb39..dd6f14e 100644 --- a/src/ltc/ciphers/aes/aes.c +++ b/src/ltc/ciphers/aes/aes.c @@ -80,7 +80,7 @@ #endif -#define __LTC_AES_TAB_C__ +#define LTC_AES_TAB_C #include "aes_tab.c" static ulong32 setup_mix(ulong32 temp) @@ -275,7 +275,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int ECB_ENC(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -443,7 +443,7 @@ #ifdef LTC_CLEAN_STACK int ECB_ENC(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _rijndael_ecb_encrypt(pt, ct, skey); + int err = s_rijndael_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2); return err; } @@ -459,7 +459,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int ECB_DEC(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -628,7 +628,7 @@ #ifdef LTC_CLEAN_STACK int ECB_DEC(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _rijndael_ecb_decrypt(ct, pt, skey); + int err = s_rijndael_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2); return err; } diff --git a/src/ltc/ciphers/aes/aes_tab.c b/src/ltc/ciphers/aes/aes_tab.c index 4dfa143..5e59004 100644 --- a/src/ltc/ciphers/aes/aes_tab.c +++ b/src/ltc/ciphers/aes/aes_tab.c @@ -15,7 +15,7 @@ Td4[x] = Si[x].[01, 01, 01, 01]; */ -#ifdef __LTC_AES_TAB_C__ +#ifdef LTC_AES_TAB_C /** @file aes_tab.c @@ -1019,4 +1019,4 @@ }; #endif -#endif /* __LTC_AES_TAB_C__ */ +#endif /* LTC_AES_TAB_C */ diff --git a/src/ltc/ciphers/anubis.c b/src/ltc/ciphers/anubis.c index 07cb5d3..f6a1c58 100644 --- a/src/ltc/ciphers/anubis.c +++ b/src/ltc/ciphers/anubis.c @@ -876,7 +876,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) +static int s_anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #else int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #endif @@ -1013,7 +1013,7 @@ int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) { int err; - err = _anubis_setup(key, keylen, num_rounds, skey); + err = s_anubis_setup(key, keylen, num_rounds, skey); burn_stack(sizeof(int) * 5 + sizeof(ulong32) * (MAX_N + MAX_N + 5)); return err; } diff --git a/src/ltc/ciphers/blowfish.c b/src/ltc/ciphers/blowfish.c index a0eaf36..35efc13 100644 --- a/src/ltc/ciphers/blowfish.c +++ b/src/ltc/ciphers/blowfish.c @@ -472,7 +472,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -499,7 +499,7 @@ #ifdef LTC_CLEAN_STACK int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _blowfish_ecb_encrypt(pt, ct, skey); + int err = s_blowfish_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(ulong32) * 2 + sizeof(int)); return err; } @@ -513,7 +513,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -560,7 +560,7 @@ #ifdef LTC_CLEAN_STACK int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _blowfish_ecb_decrypt(ct, pt, skey); + int err = s_blowfish_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(ulong32) * 2 + sizeof(int)); return err; } diff --git a/src/ltc/ciphers/cast5.c b/src/ltc/ciphers/cast5.c index 3672f3e..3b401a5 100644 --- a/src/ltc/ciphers/cast5.c +++ b/src/ltc/ciphers/cast5.c @@ -398,7 +398,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) +static int s_cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #else int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #endif @@ -485,19 +485,13 @@ int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) { int z; - z = _cast5_setup(key, keylen, num_rounds, skey); + z = s_cast5_setup(key, keylen, num_rounds, skey); burn_stack(sizeof(ulong32)*8 + 16 + sizeof(int)*2); return z; } #endif -#ifdef _MSC_VER - #define INLINE __inline -#else - #define INLINE -#endif - -INLINE static ulong32 FI(ulong32 R, ulong32 Km, ulong32 Kr) +LTC_INLINE static ulong32 FI(ulong32 R, ulong32 Km, ulong32 Kr) { ulong32 I; I = (Km + R); @@ -505,7 +499,7 @@ return ((S1[LTC_BYTE(I, 3)] ^ S2[LTC_BYTE(I,2)]) - S3[LTC_BYTE(I,1)]) + S4[LTC_BYTE(I,0)]; } -INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr) +LTC_INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr) { ulong32 I; I = (Km ^ R); @@ -513,7 +507,7 @@ return ((S1[LTC_BYTE(I, 3)] - S2[LTC_BYTE(I,2)]) + S3[LTC_BYTE(I,1)]) ^ S4[LTC_BYTE(I,0)]; } -INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr) +LTC_INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr) { ulong32 I; I = (Km - R); @@ -528,7 +522,7 @@ @param skey The key as scheduled */ #ifdef LTC_CLEAN_STACK -static int _cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -568,7 +562,7 @@ #ifdef LTC_CLEAN_STACK int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err =_cast5_ecb_encrypt(pt,ct,skey); + int err = s_cast5_ecb_encrypt(pt,ct,skey); burn_stack(sizeof(ulong32)*3); return err; } @@ -581,7 +575,7 @@ @param skey The key as scheduled */ #ifdef LTC_CLEAN_STACK -static int _cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -621,7 +615,7 @@ #ifdef LTC_CLEAN_STACK int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _cast5_ecb_decrypt(ct,pt,skey); + int err = s_cast5_ecb_decrypt(ct,pt,skey); burn_stack(sizeof(ulong32)*3); return err; } diff --git a/src/ltc/ciphers/des.c b/src/ltc/ciphers/des.c index 5d77b5d..5d00720 100644 --- a/src/ltc/ciphers/des.c +++ b/src/ltc/ciphers/des.c @@ -1293,7 +1293,7 @@ static void cookey(const ulong32 *raw1, ulong32 *keyout); #ifdef LTC_CLEAN_STACK -static void _deskey(const unsigned char *key, short edf, ulong32 *keyout) +static void s_deskey(const unsigned char *key, short edf, ulong32 *keyout) #else static void deskey(const unsigned char *key, short edf, ulong32 *keyout) #endif @@ -1347,13 +1347,13 @@ #ifdef LTC_CLEAN_STACK static void deskey(const unsigned char *key, short edf, ulong32 *keyout) { - _deskey(key, edf, keyout); + s_deskey(key, edf, keyout); burn_stack(sizeof(int)*5 + sizeof(ulong32)*32 + sizeof(unsigned char)*112); } #endif #ifdef LTC_CLEAN_STACK -static void _cookey(const ulong32 *raw1, ulong32 *keyout) +static void s_cookey(const ulong32 *raw1, ulong32 *keyout) #else static void cookey(const ulong32 *raw1, ulong32 *keyout) #endif @@ -1383,7 +1383,7 @@ #ifdef LTC_CLEAN_STACK static void cookey(const ulong32 *raw1, ulong32 *keyout) { - _cookey(raw1, keyout); + s_cookey(raw1, keyout); burn_stack(sizeof(ulong32 *) * 2 + sizeof(ulong32)*32 + sizeof(int)); } #endif @@ -1391,7 +1391,7 @@ #ifndef LTC_CLEAN_STACK static void desfunc(ulong32 *block, const ulong32 *keys) #else -static void _desfunc(ulong32 *block, const ulong32 *keys) +static void s_desfunc(ulong32 *block, const ulong32 *keys) #endif { ulong32 work, right, leftt; @@ -1505,7 +1505,7 @@ #ifdef LTC_CLEAN_STACK static void desfunc(ulong32 *block, const ulong32 *keys) { - _desfunc(block, keys); + s_desfunc(block, keys); burn_stack(sizeof(ulong32) * 4 + sizeof(int)); } #endif diff --git a/src/ltc/ciphers/idea.c b/src/ltc/ciphers/idea.c index 27db616..b195a4c 100644 --- a/src/ltc/ciphers/idea.c +++ b/src/ltc/ciphers/idea.c @@ -35,38 +35,38 @@ typedef unsigned short int ushort16; -#define _LOW16(x) ((x)&0xffff) /* compiler should be able to optimize this away if x is 16 bits */ -#define _HIGH16(x) ((x)>>16) -#define _MUL(a,b) { \ - ulong32 p = (ulong32)_LOW16(a) * b; \ +#define LOW16(x) ((x)&0xffff) /* compiler should be able to optimize this away if x is 16 bits */ +#define HIGH16(x) ((x)>>16) +#define MUL(a,b) { \ + ulong32 p = (ulong32)LOW16(a) * b; \ if (p) { \ - p = _LOW16(p) - _HIGH16(p); \ - a = (ushort16)p - (ushort16)_HIGH16(p); \ + p = LOW16(p) - HIGH16(p); \ + a = (ushort16)p - (ushort16)HIGH16(p); \ } \ else \ a = 1 - a - b; \ } -#define _STORE16(x,y) { (y)[0] = (unsigned char)(((x)>>8)&255); (y)[1] = (unsigned char)((x)&255); } -#define _LOAD16(x,y) { x = ((ushort16)((y)[0] & 255)<<8) | ((ushort16)((y)[1] & 255)); } - -static ushort16 _mul_inv(ushort16 x) +#define STORE16(x,y) { (y)[0] = (unsigned char)(((x)>>8)&255); (y)[1] = (unsigned char)((x)&255); } +#define LOAD16(x,y) { x = ((ushort16)((y)[0] & 255)<<8) | ((ushort16)((y)[1] & 255)); } + +static ushort16 s_mul_inv(ushort16 x) { ushort16 y = x; unsigned i; for (i = 0; i < 15; i++) { - _MUL(y, _LOW16(y)); - _MUL(y, x); - } - return _LOW16(y); -} - -static ushort16 _add_inv(ushort16 x) -{ - return _LOW16(0 - x); -} - -static int _setup_key(const unsigned char *key, symmetric_key *skey) + MUL(y, LOW16(y)); + MUL(y, x); + } + return LOW16(y); +} + +static ushort16 s_add_inv(ushort16 x) +{ + return LOW16(0 - x); +} + +static int s_setup_key(const unsigned char *key, symmetric_key *skey) { int i, j; ushort16 *e_key = skey->idea.ek; @@ -74,49 +74,49 @@ /* prepare enc key */ for (i = 0; i < 8; i++) { - _LOAD16(e_key[i], key + 2 * i); + LOAD16(e_key[i], key + 2 * i); } for (; i < LTC_IDEA_KEYLEN; i++) { j = (i - i % 8) - 8; - e_key[i] = _LOW16((e_key[j+(i+1)%8] << 9) | (e_key[j+(i+2)%8] >> 7)); + e_key[i] = LOW16((e_key[j+(i+1)%8] << 9) | (e_key[j+(i+2)%8] >> 7)); } /* prepare dec key */ for (i = 0; i < LTC_IDEA_ROUNDS; i++) { - d_key[i*6+0] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]); - d_key[i*6+1] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1+(i>0 ? 1 : 0)]); - d_key[i*6+2] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2-(i>0 ? 1 : 0)]); - d_key[i*6+3] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]); - d_key[i*6+4] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+4]; - d_key[i*6+5] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+5]; - } - d_key[i*6+0] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]); - d_key[i*6+1] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1]); - d_key[i*6+2] = _add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2]); - d_key[i*6+3] = _mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]); - - return CRYPT_OK; -} - -static int _process_block(const unsigned char *in, unsigned char *out, const ushort16 *m_key) + d_key[i*6+0] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]); + d_key[i*6+1] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1+(i>0 ? 1 : 0)]); + d_key[i*6+2] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2-(i>0 ? 1 : 0)]); + d_key[i*6+3] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]); + d_key[i*6+4] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+4]; + d_key[i*6+5] = e_key[(LTC_IDEA_ROUNDS-1-i)*6+5]; + } + d_key[i*6+0] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+0]); + d_key[i*6+1] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+1]); + d_key[i*6+2] = s_add_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+2]); + d_key[i*6+3] = s_mul_inv(e_key[(LTC_IDEA_ROUNDS-i)*6+3]); + + return CRYPT_OK; +} + +static int s_process_block(const unsigned char *in, unsigned char *out, const ushort16 *m_key) { int i; ushort16 x0, x1, x2, x3, t0, t1; - _LOAD16(x0, in + 0); - _LOAD16(x1, in + 2); - _LOAD16(x2, in + 4); - _LOAD16(x3, in + 6); + LOAD16(x0, in + 0); + LOAD16(x1, in + 2); + LOAD16(x2, in + 4); + LOAD16(x3, in + 6); for (i = 0; i < LTC_IDEA_ROUNDS; i++) { - _MUL(x0, m_key[i*6+0]); + MUL(x0, m_key[i*6+0]); x1 += m_key[i*6+1]; x2 += m_key[i*6+2]; - _MUL(x3, m_key[i*6+3]); + MUL(x3, m_key[i*6+3]); t0 = x0^x2; - _MUL(t0, m_key[i*6+4]); + MUL(t0, m_key[i*6+4]); t1 = t0 + (x1^x3); - _MUL(t1, m_key[i*6+5]); + MUL(t1, m_key[i*6+5]); t0 += t1; x0 ^= t1; x3 ^= t0; @@ -125,15 +125,15 @@ x2 = t0; } - _MUL(x0, m_key[LTC_IDEA_ROUNDS*6+0]); + MUL(x0, m_key[LTC_IDEA_ROUNDS*6+0]); x2 += m_key[LTC_IDEA_ROUNDS*6+1]; x1 += m_key[LTC_IDEA_ROUNDS*6+2]; - _MUL(x3, m_key[LTC_IDEA_ROUNDS*6+3]); - - _STORE16(x0, out + 0); - _STORE16(x2, out + 2); - _STORE16(x1, out + 4); - _STORE16(x3, out + 6); + MUL(x3, m_key[LTC_IDEA_ROUNDS*6+3]); + + STORE16(x0, out + 0); + STORE16(x2, out + 2); + STORE16(x1, out + 4); + STORE16(x3, out + 6); return CRYPT_OK; } @@ -146,12 +146,12 @@ if (num_rounds != 0 && num_rounds != 8) return CRYPT_INVALID_ROUNDS; if (keylen != 16) return CRYPT_INVALID_KEYSIZE; - return _setup_key(key, skey); + return s_setup_key(key, skey); } int idea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _process_block(pt, ct, skey->idea.ek); + int err = s_process_block(pt, ct, skey->idea.ek); #ifdef LTC_CLEAN_STACK burn_stack(sizeof(ushort16) * 6 + sizeof(int)); #endif @@ -160,7 +160,7 @@ int idea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _process_block(ct, pt, skey->idea.dk); + int err = s_process_block(ct, pt, skey->idea.dk); #ifdef LTC_CLEAN_STACK burn_stack(sizeof(ushort16) * 6 + sizeof(int)); #endif diff --git a/src/ltc/ciphers/multi2.c b/src/ltc/ciphers/multi2.c index d824e71..e1a84ac 100644 --- a/src/ltc/ciphers/multi2.c +++ b/src/ltc/ciphers/multi2.c @@ -9,12 +9,12 @@ #ifdef LTC_MULTI2 -static void pi1(ulong32 *p) +static void s_pi1(ulong32 *p) { p[1] ^= p[0]; } -static void pi2(ulong32 *p, const ulong32 *k) +static void s_pi2(ulong32 *p, const ulong32 *k) { ulong32 t; t = (p[1] + k[0]) & 0xFFFFFFFFUL; @@ -23,7 +23,7 @@ p[0] ^= t; } -static void pi3(ulong32 *p, const ulong32 *k) +static void s_pi3(ulong32 *p, const ulong32 *k) { ulong32 t; t = p[0] + k[1]; @@ -35,7 +35,7 @@ p[1] ^= t; } -static void pi4(ulong32 *p, const ulong32 *k) +static void s_pi4(ulong32 *p, const ulong32 *k) { ulong32 t; t = (p[1] + k[3]) & 0xFFFFFFFFUL; @@ -43,7 +43,7 @@ p[0] ^= t; } -static void setup(const ulong32 *dk, const ulong32 *k, ulong32 *uk) +static void s_setup(const ulong32 *dk, const ulong32 *k, ulong32 *uk) { int n, t; ulong32 p[2]; @@ -52,46 +52,46 @@ t = 4; n = 0; - pi1(p); - pi2(p, k); + s_pi1(p); + s_pi2(p, k); uk[n++] = p[0]; - pi3(p, k); + s_pi3(p, k); uk[n++] = p[1]; - pi4(p, k); + s_pi4(p, k); uk[n++] = p[0]; - pi1(p); + s_pi1(p); uk[n++] = p[1]; - pi2(p, k+t); + s_pi2(p, k+t); uk[n++] = p[0]; - pi3(p, k+t); + s_pi3(p, k+t); uk[n++] = p[1]; - pi4(p, k+t); + s_pi4(p, k+t); uk[n++] = p[0]; - pi1(p); + s_pi1(p); uk[n++] = p[1]; } -static void encrypt(ulong32 *p, int N, const ulong32 *uk) +static void s_encrypt(ulong32 *p, int N, const ulong32 *uk) { int n, t; for (t = n = 0; ; ) { - pi1(p); if (++n == N) break; - pi2(p, uk+t); if (++n == N) break; - pi3(p, uk+t); if (++n == N) break; - pi4(p, uk+t); if (++n == N) break; + s_pi1(p); if (++n == N) break; + s_pi2(p, uk+t); if (++n == N) break; + s_pi3(p, uk+t); if (++n == N) break; + s_pi4(p, uk+t); if (++n == N) break; t ^= 4; } } -static void decrypt(ulong32 *p, int N, const ulong32 *uk) +static void s_decrypt(ulong32 *p, int N, const ulong32 *uk) { int n, t; for (t = 4*(((N-1)>>2)&1), n = N; ; ) { switch (n<=4 ? n : ((n-1)%4)+1) { - case 4: pi4(p, uk+t); --n; /* FALLTHROUGH */ - case 3: pi3(p, uk+t); --n; /* FALLTHROUGH */ - case 2: pi2(p, uk+t); --n; /* FALLTHROUGH */ - case 1: pi1(p); --n; break; + case 4: s_pi4(p, uk+t); --n; /* FALLTHROUGH */ + case 3: s_pi3(p, uk+t); --n; /* FALLTHROUGH */ + case 2: s_pi2(p, uk+t); --n; /* FALLTHROUGH */ + case 1: s_pi1(p); --n; break; case 0: return; } t ^= 4; @@ -128,7 +128,7 @@ } LOAD32H(dk[0], key + 32); LOAD32H(dk[1], key + 36); - setup(dk, sk, skey->multi2.uk); + s_setup(dk, sk, skey->multi2.uk); zeromem(sk, sizeof(sk)); zeromem(dk, sizeof(dk)); @@ -150,7 +150,7 @@ LTC_ARGCHK(skey != NULL); LOAD32H(p[0], pt); LOAD32H(p[1], pt+4); - encrypt(p, skey->multi2.N, skey->multi2.uk); + s_encrypt(p, skey->multi2.N, skey->multi2.uk); STORE32H(p[0], ct); STORE32H(p[1], ct+4); return CRYPT_OK; @@ -171,7 +171,7 @@ LTC_ARGCHK(skey != NULL); LOAD32H(p[0], ct); LOAD32H(p[1], ct+4); - decrypt(p, skey->multi2.N, skey->multi2.uk); + s_decrypt(p, skey->multi2.N, skey->multi2.uk); STORE32H(p[0], pt); STORE32H(p[1], pt+4); return CRYPT_OK; diff --git a/src/ltc/ciphers/noekeon.c b/src/ltc/ciphers/noekeon.c index 229e33a..58d73ae 100644 --- a/src/ltc/ciphers/noekeon.c +++ b/src/ltc/ciphers/noekeon.c @@ -102,7 +102,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -142,7 +142,7 @@ #ifdef LTC_CLEAN_STACK int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _noekeon_ecb_encrypt(pt, ct, skey); + int err = s_noekeon_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(ulong32) * 5 + sizeof(int)); return err; } @@ -156,7 +156,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -195,7 +195,7 @@ #ifdef LTC_CLEAN_STACK int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _noekeon_ecb_decrypt(ct, pt, skey); + int err = s_noekeon_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(ulong32) * 5 + sizeof(int)); return err; } diff --git a/src/ltc/ciphers/rc2.c b/src/ltc/ciphers/rc2.c index f4c68ec..4832424 100644 --- a/src/ltc/ciphers/rc2.c +++ b/src/ltc/ciphers/rc2.c @@ -139,7 +139,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rc2_ecb_encrypt( const unsigned char *pt, +static int s_rc2_ecb_encrypt( const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else @@ -200,7 +200,7 @@ unsigned char *ct, const symmetric_key *skey) { - int err = _rc2_ecb_encrypt(pt, ct, skey); + int err = s_rc2_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 5); return err; } @@ -217,7 +217,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rc2_ecb_decrypt( const unsigned char *ct, +static int s_rc2_ecb_decrypt( const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else @@ -279,7 +279,7 @@ unsigned char *pt, const symmetric_key *skey) { - int err = _rc2_ecb_decrypt(ct, pt, skey); + int err = s_rc2_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 4 + sizeof(int)); return err; } diff --git a/src/ltc/ciphers/rc5.c b/src/ltc/ciphers/rc5.c index b6d3247..f21ba4f 100644 --- a/src/ltc/ciphers/rc5.c +++ b/src/ltc/ciphers/rc5.c @@ -43,7 +43,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) +static int s_rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #else int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #endif @@ -104,7 +104,7 @@ int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) { int x; - x = _rc5_setup(key, keylen, num_rounds, skey); + x = s_rc5_setup(key, keylen, num_rounds, skey); burn_stack(sizeof(ulong32) * 122 + sizeof(int)); return x; } @@ -118,7 +118,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -164,7 +164,7 @@ #ifdef LTC_CLEAN_STACK int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _rc5_ecb_encrypt(pt, ct, skey); + int err = s_rc5_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(ulong32) * 2 + sizeof(int)); return err; } @@ -178,7 +178,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -225,7 +225,7 @@ #ifdef LTC_CLEAN_STACK int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _rc5_ecb_decrypt(ct, pt, skey); + int err = s_rc5_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(ulong32) * 2 + sizeof(int)); return err; } diff --git a/src/ltc/ciphers/rc6.c b/src/ltc/ciphers/rc6.c index 02e1e98..d1341d3 100644 --- a/src/ltc/ciphers/rc6.c +++ b/src/ltc/ciphers/rc6.c @@ -40,7 +40,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) +static int s_rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #else int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #endif @@ -99,7 +99,7 @@ int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) { int x; - x = _rc6_setup(key, keylen, num_rounds, skey); + x = s_rc6_setup(key, keylen, num_rounds, skey); burn_stack(sizeof(ulong32) * 122); return x; } @@ -112,7 +112,7 @@ @param skey The key as scheduled */ #ifdef LTC_CLEAN_STACK -static int _rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -154,7 +154,7 @@ #ifdef LTC_CLEAN_STACK int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _rc6_ecb_encrypt(pt, ct, skey); + int err = s_rc6_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(ulong32) * 6 + sizeof(int)); return err; } @@ -167,7 +167,7 @@ @param skey The key as scheduled */ #ifdef LTC_CLEAN_STACK -static int _rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -211,7 +211,7 @@ #ifdef LTC_CLEAN_STACK int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _rc6_ecb_decrypt(ct, pt, skey); + int err = s_rc6_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(ulong32) * 6 + sizeof(int)); return err; } diff --git a/src/ltc/ciphers/safer/safer.c b/src/ltc/ciphers/safer/safer.c index 4c79846..84cc2d0 100644 --- a/src/ltc/ciphers/safer/safer.c +++ b/src/ltc/ciphers/safer/safer.c @@ -24,7 +24,7 @@ #ifdef LTC_SAFER -#define __LTC_SAFER_TAB_C__ +#define LTC_SAFER_TAB_C #include "safer_tab.c" const struct ltc_cipher_descriptor safer_k64_desc = { @@ -91,13 +91,13 @@ /******************* Types ****************************************************/ #ifdef LTC_CLEAN_STACK -static void _Safer_Expand_Userkey(const unsigned char *userkey_1, +static void s_safer_expand_userkey(const unsigned char *userkey_1, const unsigned char *userkey_2, unsigned int nof_rounds, int strengthened, safer_key_t key) #else -static void Safer_Expand_Userkey(const unsigned char *userkey_1, +static void safer_expand_userkey(const unsigned char *userkey_1, const unsigned char *userkey_2, unsigned int nof_rounds, int strengthened, @@ -160,13 +160,13 @@ } #ifdef LTC_CLEAN_STACK -static void Safer_Expand_Userkey(const unsigned char *userkey_1, +static void safer_expand_userkey(const unsigned char *userkey_1, const unsigned char *userkey_2, unsigned int nof_rounds, int strengthened, safer_key_t key) { - _Safer_Expand_Userkey(userkey_1, userkey_2, nof_rounds, strengthened, key); + s_safer_expand_userkey(userkey_1, userkey_2, nof_rounds, strengthened, key); burn_stack(sizeof(unsigned char) * (2 * (LTC_SAFER_BLOCK_LEN + 1)) + sizeof(unsigned int)*2); } #endif @@ -184,7 +184,7 @@ return CRYPT_INVALID_KEYSIZE; } - Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key); + safer_expand_userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key); return CRYPT_OK; } @@ -201,7 +201,7 @@ return CRYPT_INVALID_KEYSIZE; } - Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key); + safer_expand_userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key); return CRYPT_OK; } @@ -218,7 +218,7 @@ return CRYPT_INVALID_KEYSIZE; } - Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key); + safer_expand_userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key); return CRYPT_OK; } @@ -235,12 +235,12 @@ return CRYPT_INVALID_KEYSIZE; } - Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key); - return CRYPT_OK; -} - -#ifdef LTC_CLEAN_STACK -static int _safer_ecb_encrypt(const unsigned char *pt, + safer_expand_userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key); + return CRYPT_OK; +} + +#ifdef LTC_CLEAN_STACK +static int s_safer_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else @@ -287,14 +287,14 @@ unsigned char *ct, const symmetric_key *skey) { - int err = _safer_ecb_encrypt(pt, ct, skey); + int err = s_safer_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *)); return err; } #endif #ifdef LTC_CLEAN_STACK -static int _safer_ecb_decrypt(const unsigned char *ct, +static int s_safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else @@ -342,7 +342,7 @@ unsigned char *pt, const symmetric_key *skey) { - int err = _safer_ecb_decrypt(ct, pt, skey); + int err = s_safer_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *)); return err; } diff --git a/src/ltc/ciphers/safer/safer_tab.c b/src/ltc/ciphers/safer/safer_tab.c index b93f3f2..4cc0e47 100644 --- a/src/ltc/ciphers/safer/safer_tab.c +++ b/src/ltc/ciphers/safer/safer_tab.c @@ -6,7 +6,7 @@ Tables for LTC_SAFER block ciphers */ -#ifdef __LTC_SAFER_TAB_C__ +#ifdef LTC_SAFER_TAB_C /* This is the box defined by ebox[x] = 45^x mod 257. * Its assumed that the value "256" corresponds to zero. */ @@ -49,6 +49,6 @@ 184, 64, 120, 45, 58, 233, 100, 31, 146, 144, 125, 57, 111, 224, 137, 48 }; -#endif /* __LTC_SAFER_TAB_C__ */ +#endif /* LTC_SAFER_TAB_C */ diff --git a/src/ltc/ciphers/safer/saferp.c b/src/ltc/ciphers/safer/saferp.c index 6ee2719..86cc708 100644 --- a/src/ltc/ciphers/safer/saferp.c +++ b/src/ltc/ciphers/safer/saferp.c @@ -9,7 +9,7 @@ #ifdef LTC_SAFERP -#define __LTC_SAFER_TAB_C__ +#define LTC_SAFER_TAB_C #include "safer_tab.c" const struct ltc_cipher_descriptor saferp_desc = @@ -137,37 +137,37 @@ #ifdef LTC_SMALL_CODE -static void _round(unsigned char *b, int i, const symmetric_key *skey) +static void s_round(unsigned char *b, int i, const symmetric_key *skey) { ROUND(b, i); } -static void _iround(unsigned char *b, int i, const symmetric_key *skey) +static void s_iround(unsigned char *b, int i, const symmetric_key *skey) { iROUND(b, i); } -static void _lt(unsigned char *b, unsigned char *b2) +static void s_lt(unsigned char *b, unsigned char *b2) { LT(b, b2); } -static void _ilt(unsigned char *b, unsigned char *b2) +static void s_ilt(unsigned char *b, unsigned char *b2) { iLT(b, b2); } #undef ROUND -#define ROUND(b, i) _round(b, i, skey) +#define ROUND(b, i) s_round(b, i, skey) #undef iROUND -#define iROUND(b, i) _iround(b, i, skey) +#define iROUND(b, i) s_iround(b, i, skey) #undef LT -#define LT(b, b2) _lt(b, b2) +#define LT(b, b2) s_lt(b, b2) #undef iLT -#define iLT(b, b2) _ilt(b, b2) +#define iLT(b, b2) s_ilt(b, b2) #endif diff --git a/src/ltc/ciphers/serpent.c b/src/ltc/ciphers/serpent.c index f40e838..dbb999e 100644 --- a/src/ltc/ciphers/serpent.c +++ b/src/ltc/ciphers/serpent.c @@ -27,7 +27,7 @@ }; /* linear transformation */ -#define _LT(i,a,b,c,d,e) { \ +#define s_lt(i,a,b,c,d,e) { \ a = ROLc(a, 13); \ c = ROLc(c, 3); \ d = ROLc(d ^ c ^ (a << 3), 7); \ @@ -37,7 +37,7 @@ } /* inverse linear transformation */ -#define _ILT(i,a,b,c,d,e) { \ +#define s_ilt(i,a,b,c,d,e) { \ c = RORc(c, 22); \ a = RORc(a, 5); \ c ^= d ^ (b << 7); \ @@ -50,32 +50,32 @@ } /* order of output from S-box functions */ -#define _beforeS0(f) f(0,a,b,c,d,e) -#define _afterS0(f) f(1,b,e,c,a,d) -#define _afterS1(f) f(2,c,b,a,e,d) -#define _afterS2(f) f(3,a,e,b,d,c) -#define _afterS3(f) f(4,e,b,d,c,a) -#define _afterS4(f) f(5,b,a,e,c,d) -#define _afterS5(f) f(6,a,c,b,e,d) -#define _afterS6(f) f(7,a,c,d,b,e) -#define _afterS7(f) f(8,d,e,b,a,c) +#define s_beforeS0(f) f(0,a,b,c,d,e) +#define s_afterS0(f) f(1,b,e,c,a,d) +#define s_afterS1(f) f(2,c,b,a,e,d) +#define s_afterS2(f) f(3,a,e,b,d,c) +#define s_afterS3(f) f(4,e,b,d,c,a) +#define s_afterS4(f) f(5,b,a,e,c,d) +#define s_afterS5(f) f(6,a,c,b,e,d) +#define s_afterS6(f) f(7,a,c,d,b,e) +#define s_afterS7(f) f(8,d,e,b,a,c) /* order of output from inverse S-box functions */ -#define _beforeI7(f) f(8,a,b,c,d,e) -#define _afterI7(f) f(7,d,a,b,e,c) -#define _afterI6(f) f(6,a,b,c,e,d) -#define _afterI5(f) f(5,b,d,e,c,a) -#define _afterI4(f) f(4,b,c,e,a,d) -#define _afterI3(f) f(3,a,b,e,c,d) -#define _afterI2(f) f(2,b,d,e,c,a) -#define _afterI1(f) f(1,a,b,c,e,d) -#define _afterI0(f) f(0,a,d,b,e,c) +#define s_beforeI7(f) f(8,a,b,c,d,e) +#define s_afterI7(f) f(7,d,a,b,e,c) +#define s_afterI6(f) f(6,a,b,c,e,d) +#define s_afterI5(f) f(5,b,d,e,c,a) +#define s_afterI4(f) f(4,b,c,e,a,d) +#define s_afterI3(f) f(3,a,b,e,c,d) +#define s_afterI2(f) f(2,b,d,e,c,a) +#define s_afterI1(f) f(1,a,b,c,e,d) +#define s_afterI0(f) f(0,a,d,b,e,c) /* The instruction sequences for the S-box functions * come from Dag Arne Osvik's paper "Speeding up Serpent". */ -#define _S0(i, r0, r1, r2, r3, r4) { \ +#define s_s0(i, r0, r1, r2, r3, r4) { \ r3 ^= r0; \ r4 = r1; \ r1 &= r3; \ @@ -96,7 +96,7 @@ r4 ^= r3; \ } -#define _I0(i, r0, r1, r2, r3, r4) { \ +#define s_i0(i, r0, r1, r2, r3, r4) { \ r2 = ~r2; \ r4 = r1; \ r1 |= r0; \ @@ -118,7 +118,7 @@ r4 ^= r2; \ } -#define _S1(i, r0, r1, r2, r3, r4) { \ +#define s_s1(i, r0, r1, r2, r3, r4) { \ r0 = ~r0; \ r2 = ~r2; \ r4 = r0; \ @@ -139,7 +139,7 @@ r0 ^= r4; \ } -#define _I1(i, r0, r1, r2, r3, r4) { \ +#define s_i1(i, r0, r1, r2, r3, r4) { \ r4 = r1; \ r1 ^= r3; \ r3 &= r1; \ @@ -161,7 +161,7 @@ r3 ^= r1; \ } -#define _S2(i, r0, r1, r2, r3, r4) { \ +#define s_s2(i, r0, r1, r2, r3, r4) { \ r4 = r0; \ r0 &= r2; \ r0 ^= r3; \ @@ -180,7 +180,7 @@ r4 = ~r4; \ } -#define _I2(i, r0, r1, r2, r3, r4) { \ +#define s_i2(i, r0, r1, r2, r3, r4) { \ r2 ^= r3; \ r3 ^= r0; \ r4 = r3; \ @@ -202,7 +202,7 @@ r3 ^= r0; \ } -#define _S3(i, r0, r1, r2, r3, r4) { \ +#define s_s3(i, r0, r1, r2, r3, r4) { \ r4 = r0; \ r0 |= r3; \ r3 ^= r1; \ @@ -224,7 +224,7 @@ r1 ^= r0; \ } -#define _I3(i, r0, r1, r2, r3, r4) { \ +#define s_i3(i, r0, r1, r2, r3, r4) { \ r4 = r2; \ r2 ^= r1; \ r1 &= r2; \ @@ -245,7 +245,7 @@ r2 ^= r4; \ } -#define _S4(i, r0, r1, r2, r3, r4) { \ +#define s_s4(i, r0, r1, r2, r3, r4) { \ r1 ^= r3; \ r3 = ~r3; \ r2 ^= r3; \ @@ -268,7 +268,7 @@ r4 ^= r2; \ } -#define _I4(i, r0, r1, r2, r3, r4) { \ +#define s_i4(i, r0, r1, r2, r3, r4) { \ r4 = r2; \ r2 &= r3; \ r2 ^= r1; \ @@ -291,7 +291,7 @@ r2 ^= r1; \ } -#define _S5(i, r0, r1, r2, r3, r4) { \ +#define s_s5(i, r0, r1, r2, r3, r4) { \ r0 ^= r1; \ r1 ^= r3; \ r3 = ~r3; \ @@ -313,7 +313,7 @@ r2 ^= r4; \ } -#define _I5(i, r0, r1, r2, r3, r4) { \ +#define s_i5(i, r0, r1, r2, r3, r4) { \ r1 = ~r1; \ r4 = r3; \ r2 ^= r1; \ @@ -335,7 +335,7 @@ r4 = ~r4; \ } -#define _S6(i, r0, r1, r2, r3, r4) { \ +#define s_s6(i, r0, r1, r2, r3, r4) { \ r2 = ~r2; \ r4 = r3; \ r3 &= r0; \ @@ -356,7 +356,7 @@ r2 ^= r3; \ } -#define _I6(i, r0, r1, r2, r3, r4) { \ +#define s_i6(i, r0, r1, r2, r3, r4) { \ r0 ^= r2; \ r4 = r2; \ r2 &= r0; \ @@ -376,7 +376,7 @@ r4 ^= r0; \ } -#define _S7(i, r0, r1, r2, r3, r4) { \ +#define s_s7(i, r0, r1, r2, r3, r4) { \ r4 = r2; \ r2 &= r1; \ r2 ^= r3; \ @@ -399,7 +399,7 @@ r4 ^= r1; \ } -#define _I7(i, r0, r1, r2, r3, r4) { \ +#define s_i7(i, r0, r1, r2, r3, r4) { \ r4 = r2; \ r2 ^= r0; \ r0 &= r3; \ @@ -422,28 +422,28 @@ } /* key xor */ -#define _KX(r, a, b, c, d, e) { \ +#define s_kx(r, a, b, c, d, e) { \ a ^= k[4 * r + 0]; \ b ^= k[4 * r + 1]; \ c ^= k[4 * r + 2]; \ d ^= k[4 * r + 3]; \ } -#define _LK(r, a, b, c, d, e) { \ +#define s_lk(r, a, b, c, d, e) { \ a = k[(8-r)*4 + 0]; \ b = k[(8-r)*4 + 1]; \ c = k[(8-r)*4 + 2]; \ d = k[(8-r)*4 + 3]; \ } -#define _SK(r, a, b, c, d, e) { \ +#define s_sk(r, a, b, c, d, e) { \ k[(8-r)*4 + 4] = a; \ k[(8-r)*4 + 5] = b; \ k[(8-r)*4 + 6] = c; \ k[(8-r)*4 + 7] = d; \ } -static int _setup_key(const unsigned char *key, int keylen, int rounds, ulong32 *k) +static int s_setup_key(const unsigned char *key, int keylen, int rounds, ulong32 *k) { int i; ulong32 t; @@ -467,22 +467,22 @@ k -= 20; for (i = 0; i < rounds/8; i++) { - _afterS2(_LK); _afterS2(_S3); _afterS3(_SK); - _afterS1(_LK); _afterS1(_S2); _afterS2(_SK); - _afterS0(_LK); _afterS0(_S1); _afterS1(_SK); - _beforeS0(_LK); _beforeS0(_S0); _afterS0(_SK); + s_afterS2(s_lk); s_afterS2(s_s3); s_afterS3(s_sk); + s_afterS1(s_lk); s_afterS1(s_s2); s_afterS2(s_sk); + s_afterS0(s_lk); s_afterS0(s_s1); s_afterS1(s_sk); + s_beforeS0(s_lk); s_beforeS0(s_s0); s_afterS0(s_sk); k += 8*4; - _afterS6(_LK); _afterS6(_S7); _afterS7(_SK); - _afterS5(_LK); _afterS5(_S6); _afterS6(_SK); - _afterS4(_LK); _afterS4(_S5); _afterS5(_SK); - _afterS3(_LK); _afterS3(_S4); _afterS4(_SK); + s_afterS6(s_lk); s_afterS6(s_s7); s_afterS7(s_sk); + s_afterS5(s_lk); s_afterS5(s_s6); s_afterS6(s_sk); + s_afterS4(s_lk); s_afterS4(s_s5); s_afterS5(s_sk); + s_afterS3(s_lk); s_afterS3(s_s4); s_afterS4(s_sk); } - _afterS2(_LK); _afterS2(_S3); _afterS3(_SK); + s_afterS2(s_lk); s_afterS2(s_s3); s_afterS3(s_sk); return CRYPT_OK; } -static int _enc_block(const unsigned char *in, unsigned char *out, const ulong32 *k) +static int s_enc_block(const unsigned char *in, unsigned char *out, const ulong32 *k) { ulong32 a, b, c, d, e; unsigned int i = 1; @@ -493,14 +493,14 @@ LOAD32L(d, in + 12); do { - _beforeS0(_KX); _beforeS0(_S0); _afterS0(_LT); - _afterS0(_KX); _afterS0(_S1); _afterS1(_LT); - _afterS1(_KX); _afterS1(_S2); _afterS2(_LT); - _afterS2(_KX); _afterS2(_S3); _afterS3(_LT); - _afterS3(_KX); _afterS3(_S4); _afterS4(_LT); - _afterS4(_KX); _afterS4(_S5); _afterS5(_LT); - _afterS5(_KX); _afterS5(_S6); _afterS6(_LT); - _afterS6(_KX); _afterS6(_S7); + s_beforeS0(s_kx); s_beforeS0(s_s0); s_afterS0(s_lt); + s_afterS0(s_kx); s_afterS0(s_s1); s_afterS1(s_lt); + s_afterS1(s_kx); s_afterS1(s_s2); s_afterS2(s_lt); + s_afterS2(s_kx); s_afterS2(s_s3); s_afterS3(s_lt); + s_afterS3(s_kx); s_afterS3(s_s4); s_afterS4(s_lt); + s_afterS4(s_kx); s_afterS4(s_s5); s_afterS5(s_lt); + s_afterS5(s_kx); s_afterS5(s_s6); s_afterS6(s_lt); + s_afterS6(s_kx); s_afterS6(s_s7); if (i == 4) break; @@ -511,10 +511,10 @@ d = a; a = e; k += 32; - _beforeS0(_LT); + s_beforeS0(s_lt); } while (1); - _afterS7(_KX); + s_afterS7(s_kx); STORE32L(d, out + 0); STORE32L(e, out + 4); @@ -524,7 +524,7 @@ return CRYPT_OK; } -static int _dec_block(const unsigned char *in, unsigned char *out, const ulong32 *k) +static int s_dec_block(const unsigned char *in, unsigned char *out, const ulong32 *k) { ulong32 a, b, c, d, e; unsigned int i; @@ -537,7 +537,7 @@ i = 4; k += 96; - _beforeI7(_KX); + s_beforeI7(s_kx); goto start; do { @@ -545,16 +545,16 @@ b = d; d = e; k -= 32; - _beforeI7(_ILT); + s_beforeI7(s_ilt); start: - _beforeI7(_I7); _afterI7(_KX); - _afterI7(_ILT); _afterI7(_I6); _afterI6(_KX); - _afterI6(_ILT); _afterI6(_I5); _afterI5(_KX); - _afterI5(_ILT); _afterI5(_I4); _afterI4(_KX); - _afterI4(_ILT); _afterI4(_I3); _afterI3(_KX); - _afterI3(_ILT); _afterI3(_I2); _afterI2(_KX); - _afterI2(_ILT); _afterI2(_I1); _afterI1(_KX); - _afterI1(_ILT); _afterI1(_I0); _afterI0(_KX); + s_beforeI7(s_i7); s_afterI7(s_kx); + s_afterI7(s_ilt); s_afterI7(s_i6); s_afterI6(s_kx); + s_afterI6(s_ilt); s_afterI6(s_i5); s_afterI5(s_kx); + s_afterI5(s_ilt); s_afterI5(s_i4); s_afterI4(s_kx); + s_afterI4(s_ilt); s_afterI4(s_i3); s_afterI3(s_kx); + s_afterI3(s_ilt); s_afterI3(s_i2); s_afterI2(s_kx); + s_afterI2(s_ilt); s_afterI2(s_i1); s_afterI1(s_kx); + s_afterI1(s_ilt); s_afterI1(s_i0); s_afterI0(s_kx); } while (--i != 0); STORE32L(a, out + 0); @@ -575,7 +575,7 @@ if (num_rounds != 0 && num_rounds != 32) return CRYPT_INVALID_ROUNDS; if (keylen != 16 && keylen != 24 && keylen != 32) return CRYPT_INVALID_KEYSIZE; - err = _setup_key(key, keylen, 32, skey->serpent.k); + err = s_setup_key(key, keylen, 32, skey->serpent.k); #ifdef LTC_CLEAN_STACK burn_stack(sizeof(ulong32) * 14 + sizeof(int)); #endif @@ -584,7 +584,7 @@ int serpent_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _enc_block(pt, ct, skey->serpent.k); + int err = s_enc_block(pt, ct, skey->serpent.k); #ifdef LTC_CLEAN_STACK burn_stack(sizeof(ulong32) * 5 + sizeof(int)); #endif @@ -593,7 +593,7 @@ int serpent_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _dec_block(ct, pt, skey->serpent.k); + int err = s_dec_block(ct, pt, skey->serpent.k); #ifdef LTC_CLEAN_STACK burn_stack(sizeof(ulong32) * 5 + sizeof(int)); #endif diff --git a/src/ltc/ciphers/skipjack.c b/src/ltc/ciphers/skipjack.c index 2ab49f8..0251946 100644 --- a/src/ltc/ciphers/skipjack.c +++ b/src/ltc/ciphers/skipjack.c @@ -133,7 +133,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -183,7 +183,7 @@ #ifdef LTC_CLEAN_STACK int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _skipjack_ecb_encrypt(pt, ct, skey); + int err = s_skipjack_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(unsigned) * 8 + sizeof(int) * 2); return err; } @@ -197,7 +197,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -251,7 +251,7 @@ #ifdef LTC_CLEAN_STACK int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err = _skipjack_ecb_decrypt(ct, pt, skey); + int err = s_skipjack_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(unsigned) * 7 + sizeof(int) * 2); return err; } diff --git a/src/ltc/ciphers/tea.c b/src/ltc/ciphers/tea.c index 09a8c56..fc413d4 100644 --- a/src/ltc/ciphers/tea.c +++ b/src/ltc/ciphers/tea.c @@ -68,7 +68,7 @@ LOAD32H(y, &pt[0]); LOAD32H(z, &pt[4]); - for (r = 0; r < 32; r += 4) { + for (r = 0; r < 32; r++) { sum += delta; y += ((z<<4) + skey->tea.k[0]) ^ (z + sum) ^ ((z>>5) + skey->tea.k[1]); z += ((y<<4) + skey->tea.k[2]) ^ (y + sum) ^ ((y>>5) + skey->tea.k[3]); @@ -154,11 +154,11 @@ zeromem(&skey, sizeof(skey)); l = sizeof(key); - if ((err = base16_decode(tests[i].key, XSTRLEN(tests[i].key), key, &l)) != CRYPT) return err; + if ((err = base16_decode(tests[i].key, XSTRLEN(tests[i].key), key, &l)) != CRYPT_OK) return err; l = sizeof(ptct[0]); - if ((err = base16_decode(tests[i].pt, XSTRLEN(tests[i].pt), ptct[0], &l)) != CRYPT) return err; + if ((err = base16_decode(tests[i].pt, XSTRLEN(tests[i].pt), ptct[0], &l)) != CRYPT_OK) return err; l = sizeof(ptct[1]); - if ((err = base16_decode(tests[i].ct, XSTRLEN(tests[i].ct), ptct[1], &l)) != CRYPT) return err; + if ((err = base16_decode(tests[i].ct, XSTRLEN(tests[i].ct), ptct[1], &l)) != CRYPT_OK) return err; if ((err = tea_setup(key, 16, 0, &skey)) != CRYPT_OK) { return err; @@ -166,8 +166,8 @@ tea_ecb_encrypt(ptct[0], tmp[0], &skey); tea_ecb_decrypt(tmp[0], tmp[1], &skey); - if (compare_testvector(tmp[0], 8, ptct[0], 8, "TEA Encrypt", i) != 0 || - compare_testvector(tmp[1], 8, ptct[1], 8, "TEA Decrypt", i) != 0) { + if (compare_testvector(tmp[0], 8, ptct[1], 8, "TEA Encrypt", i) != 0 || + compare_testvector(tmp[1], 8, ptct[0], 8, "TEA Decrypt", i) != 0) { return CRYPT_FAIL_TESTVECTOR; } diff --git a/src/ltc/ciphers/twofish/twofish.c b/src/ltc/ciphers/twofish/twofish.c index 127d138..c006361 100644 --- a/src/ltc/ciphers/twofish/twofish.c +++ b/src/ltc/ciphers/twofish/twofish.c @@ -58,7 +58,7 @@ #ifdef LTC_TWOFISH_TABLES -#define __LTC_TWOFISH_TAB_C__ +#define LTC_TWOFISH_TAB_C #include "twofish_tab.c" #define sbox(i, x) ((ulong32)SBOX[i][(x)&255]) @@ -83,7 +83,7 @@ /* computes S_i[x] */ #ifdef LTC_CLEAN_STACK -static ulong32 _sbox(int i, ulong32 x) +static ulong32 s_sbox(int i, ulong32 x) #else static ulong32 sbox(int i, ulong32 x) #endif @@ -125,7 +125,7 @@ static ulong32 sbox(int i, ulong32 x) { ulong32 y; - y = _sbox(i, x); + y = s_sbox(i, x); burn_stack(sizeof(unsigned char) * 11); return y; } @@ -282,7 +282,7 @@ #else #ifdef LTC_CLEAN_STACK -static ulong32 _g_func(ulong32 x, const symmetric_key *key) +static ulong32 s_g_func(ulong32 x, const symmetric_key *key) #else static ulong32 g_func(ulong32 x, const symmetric_key *key) #endif @@ -318,7 +318,7 @@ static ulong32 g_func(ulong32 x, const symmetric_key *key) { ulong32 y; - y = _g_func(x, key); + y = s_g_func(x, key); burn_stack(sizeof(unsigned char) * 4 + sizeof(ulong32)); return y; } @@ -335,7 +335,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) +static int s_twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #else int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) #endif @@ -448,7 +448,7 @@ int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) { int x; - x = _twofish_setup(key, keylen, num_rounds, skey); + x = s_twofish_setup(key, keylen, num_rounds, skey); burn_stack(sizeof(int) * 7 + sizeof(unsigned char) * 56 + sizeof(ulong32) * 2); return x; } @@ -462,7 +462,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) +static int s_twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #else int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) #endif @@ -522,7 +522,7 @@ #ifdef LTC_CLEAN_STACK int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey) { - int err = _twofish_ecb_encrypt(pt, ct, skey); + int err = s_twofish_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(ulong32) * 10 + sizeof(int)); return err; } @@ -536,7 +536,7 @@ @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static int _twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) +static int s_twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #else int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) #endif @@ -598,7 +598,7 @@ #ifdef LTC_CLEAN_STACK int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey) { - int err =_twofish_ecb_decrypt(ct, pt, skey); + int err = s_twofish_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(ulong32) * 10 + sizeof(int)); return err; } diff --git a/src/ltc/ciphers/twofish/twofish_tab.c b/src/ltc/ciphers/twofish/twofish_tab.c index d6cc874..e52d284 100644 --- a/src/ltc/ciphers/twofish/twofish_tab.c +++ b/src/ltc/ciphers/twofish/twofish_tab.c @@ -6,7 +6,7 @@ Twofish tables, Tom St Denis */ #ifdef LTC_TWOFISH_TABLES -#ifdef __LTC_TWOFISH_TAB_C__ +#ifdef LTC_TWOFISH_TAB_C /* pre generated 8x8 tables from the four 4x4s */ static const unsigned char SBOX[2][256] = { @@ -482,5 +482,5 @@ #endif /* LTC_TWOFISH_ALL_TABLES */ -#endif /* __LTC_TWOFISH_TAB_C__ */ +#endif /* LTC_TWOFISH_TAB_C */ #endif diff --git a/src/ltc/encauth/gcm/gcm_gf_mult.c b/src/ltc/encauth/gcm/gcm_gf_mult.c index 58904af..10cd3c9 100644 --- a/src/ltc/encauth/gcm/gcm_gf_mult.c +++ b/src/ltc/encauth/gcm/gcm_gf_mult.c @@ -52,7 +52,7 @@ #ifndef LTC_FAST /* right shift */ -static void _gcm_rightshift(unsigned char *a) +static void s_gcm_rightshift(unsigned char *a) { int x; for (x = 15; x > 0; x--) { @@ -86,7 +86,7 @@ } } z = V[15] & 0x01; - _gcm_rightshift(V); + s_gcm_rightshift(V); V[0] ^= poly[z]; } XMEMCPY(c, Z, 16); diff --git a/src/ltc/encauth/ocb3/ocb3_add_aad.c b/src/ltc/encauth/ocb3/ocb3_add_aad.c index cb4602a..fd09aba 100644 --- a/src/ltc/encauth/ocb3/ocb3_add_aad.c +++ b/src/ltc/encauth/ocb3/ocb3_add_aad.c @@ -15,7 +15,7 @@ @param aad_block [in] AAD data (block_len size) @return CRYPT_OK if successful */ -static int _ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block) +static int s_ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block) { unsigned char tmp[MAXBLOCKSIZE]; int err; @@ -59,7 +59,7 @@ ocb->adata_buffer_bytes += l; if (ocb->adata_buffer_bytes == ocb->block_len) { - if ((err = _ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) { + if ((err = s_ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) { return err; } ocb->adata_buffer_bytes = 0; @@ -80,7 +80,7 @@ last_block_len = datalen - full_blocks_len; for (x=0; xblock_len)) != CRYPT_OK) { + if ((err = s_ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) { return err; } } diff --git a/src/ltc/encauth/ocb3/ocb3_init.c b/src/ltc/encauth/ocb3/ocb3_init.c index e663640..09493ac 100644 --- a/src/ltc/encauth/ocb3/ocb3_init.c +++ b/src/ltc/encauth/ocb3/ocb3_init.c @@ -9,7 +9,7 @@ #ifdef LTC_OCB3_MODE -static void _ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen) +static void s_ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen) { int x, y, bottom; int idx, shift; @@ -166,7 +166,7 @@ } /* initialize ocb->Offset_current = Offset_0 */ - _ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen); + s_ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen); /* initialize checksum to all zeros */ zeromem(ocb->checksum, ocb->block_len); diff --git a/src/ltc/hashes/blake2b.c b/src/ltc/hashes/blake2b.c index 5c31aa1..8cbeac2 100644 --- a/src/ltc/hashes/blake2b.c +++ b/src/ltc/hashes/blake2b.c @@ -147,26 +147,26 @@ { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } }; -static void blake2b_set_lastnode(hash_state *md) { md->blake2b.f[1] = CONST64(0xffffffffffffffff); } +static void s_blake2b_set_lastnode(hash_state *md) { md->blake2b.f[1] = CONST64(0xffffffffffffffff); } /* Some helper functions, not necessarily useful */ -static int blake2b_is_lastblock(const hash_state *md) { return md->blake2b.f[0] != 0; } - -static void blake2b_set_lastblock(hash_state *md) +static int s_blake2b_is_lastblock(const hash_state *md) { return md->blake2b.f[0] != 0; } + +static void s_blake2b_set_lastblock(hash_state *md) { if (md->blake2b.last_node) { - blake2b_set_lastnode(md); + s_blake2b_set_lastnode(md); } md->blake2b.f[0] = CONST64(0xffffffffffffffff); } -static void blake2b_increment_counter(hash_state *md, ulong64 inc) +static void s_blake2b_increment_counter(hash_state *md, ulong64 inc) { md->blake2b.t[0] += inc; if (md->blake2b.t[0] < inc) md->blake2b.t[1]++; } -static void blake2b_init0(hash_state *md) +static void s_blake2b_init0(hash_state *md) { unsigned long i; XMEMSET(&md->blake2b, 0, sizeof(md->blake2b)); @@ -177,11 +177,11 @@ } /* init xors IV with input parameter block */ -static int blake2b_init_param(hash_state *md, const unsigned char *P) +static int s_blake2b_init_param(hash_state *md, const unsigned char *P) { unsigned long i; - blake2b_init0(md); + s_blake2b_init0(md); /* IV XOR ParamBlock */ for (i = 0; i < 8; ++i) { @@ -228,7 +228,7 @@ P[O_FANOUT] = 1; P[O_DEPTH] = 1; - err = blake2b_init_param(md, P); + err = s_blake2b_init_param(md, P); if (err != CRYPT_OK) return err; if (key) { @@ -299,9 +299,9 @@ } while (0) #ifdef LTC_CLEAN_STACK -static int _blake2b_compress(hash_state *md, const unsigned char *buf) +static int ss_blake2b_compress(hash_state *md, const unsigned char *buf) #else -static int blake2b_compress(hash_state *md, const unsigned char *buf) +static int s_blake2b_compress(hash_state *md, const unsigned char *buf) #endif { ulong64 m[16]; @@ -348,10 +348,10 @@ #undef ROUND #ifdef LTC_CLEAN_STACK -static int blake2b_compress(hash_state *md, const unsigned char *buf) +static int s_blake2b_compress(hash_state *md, const unsigned char *buf) { int err; - err = _blake2b_compress(md, buf); + err = ss_blake2b_compress(md, buf); burn_stack(sizeof(ulong64) * 32 + sizeof(unsigned long)); return err; } @@ -379,13 +379,13 @@ if (inlen > fill) { md->blake2b.curlen = 0; XMEMCPY(md->blake2b.buf + (left % sizeof(md->blake2b.buf)), in, fill); /* Fill buffer */ - blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES); - blake2b_compress(md, md->blake2b.buf); /* Compress */ + s_blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES); + s_blake2b_compress(md, md->blake2b.buf); /* Compress */ in += fill; inlen -= fill; while (inlen > BLAKE2B_BLOCKBYTES) { - blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES); - blake2b_compress(md, in); + s_blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES); + s_blake2b_compress(md, in); in += BLAKE2B_BLOCKBYTES; inlen -= BLAKE2B_BLOCKBYTES; } @@ -412,14 +412,14 @@ /* if(md->blakebs.outlen != outlen) return CRYPT_INVALID_ARG; */ - if (blake2b_is_lastblock(md)) { + if (s_blake2b_is_lastblock(md)) { return CRYPT_ERROR; } - blake2b_increment_counter(md, md->blake2b.curlen); - blake2b_set_lastblock(md); + s_blake2b_increment_counter(md, md->blake2b.curlen); + s_blake2b_set_lastblock(md); XMEMSET(md->blake2b.buf + md->blake2b.curlen, 0, BLAKE2B_BLOCKBYTES - md->blake2b.curlen); /* Padding */ - blake2b_compress(md, md->blake2b.buf); + s_blake2b_compress(md, md->blake2b.buf); for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ STORE64L(md->blake2b.h[i], buffer + i * 8); diff --git a/src/ltc/hashes/blake2s.c b/src/ltc/hashes/blake2s.c index 647f649..e8cd6eb 100644 --- a/src/ltc/hashes/blake2s.c +++ b/src/ltc/hashes/blake2s.c @@ -139,26 +139,26 @@ { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, }; -static void blake2s_set_lastnode(hash_state *md) { md->blake2s.f[1] = 0xffffffffUL; } +static void s_blake2s_set_lastnode(hash_state *md) { md->blake2s.f[1] = 0xffffffffUL; } /* Some helper functions, not necessarily useful */ -static int blake2s_is_lastblock(const hash_state *md) { return md->blake2s.f[0] != 0; } - -static void blake2s_set_lastblock(hash_state *md) +static int s_blake2s_is_lastblock(const hash_state *md) { return md->blake2s.f[0] != 0; } + +static void s_blake2s_set_lastblock(hash_state *md) { if (md->blake2s.last_node) { - blake2s_set_lastnode(md); + s_blake2s_set_lastnode(md); } md->blake2s.f[0] = 0xffffffffUL; } -static void blake2s_increment_counter(hash_state *md, const ulong32 inc) +static void s_blake2s_increment_counter(hash_state *md, const ulong32 inc) { md->blake2s.t[0] += inc; if (md->blake2s.t[0] < inc) md->blake2s.t[1]++; } -static int blake2s_init0(hash_state *md) +static int s_blake2s_init0(hash_state *md) { int i; XMEMSET(&md->blake2s, 0, sizeof(struct blake2s_state)); @@ -171,11 +171,11 @@ } /* init2 xors IV with input parameter block */ -static int blake2s_init_param(hash_state *md, const unsigned char *P) +static int s_blake2s_init_param(hash_state *md, const unsigned char *P) { unsigned long i; - blake2s_init0(md); + s_blake2s_init0(md); /* IV XOR ParamBlock */ for (i = 0; i < 8; ++i) { @@ -222,7 +222,7 @@ P[O_FANOUT] = 1; P[O_DEPTH] = 1; - err = blake2s_init_param(md, P); + err = s_blake2s_init_param(md, P); if (err != CRYPT_OK) return err; if (key) { @@ -291,9 +291,9 @@ } while (0) #ifdef LTC_CLEAN_STACK -static int _blake2s_compress(hash_state *md, const unsigned char *buf) +static int ss_blake2s_compress(hash_state *md, const unsigned char *buf) #else -static int blake2s_compress(hash_state *md, const unsigned char *buf) +static int s_blake2s_compress(hash_state *md, const unsigned char *buf) #endif { unsigned long i; @@ -337,10 +337,10 @@ #undef ROUND #ifdef LTC_CLEAN_STACK -static int blake2s_compress(hash_state *md, const unsigned char *buf) +static int s_blake2s_compress(hash_state *md, const unsigned char *buf) { int err; - err = _blake2s_compress(md, buf); + err = ss_blake2s_compress(md, buf); burn_stack(sizeof(ulong32) * (32) + sizeof(unsigned long)); return err; } @@ -368,13 +368,13 @@ if (inlen > fill) { md->blake2s.curlen = 0; XMEMCPY(md->blake2s.buf + (left % sizeof(md->blake2s.buf)), in, fill); /* Fill buffer */ - blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES); - blake2s_compress(md, md->blake2s.buf); /* Compress */ + s_blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES); + s_blake2s_compress(md, md->blake2s.buf); /* Compress */ in += fill; inlen -= fill; while (inlen > BLAKE2S_BLOCKBYTES) { - blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES); - blake2s_compress(md, in); + s_blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES); + s_blake2s_compress(md, in); in += BLAKE2S_BLOCKBYTES; inlen -= BLAKE2S_BLOCKBYTES; } @@ -401,13 +401,13 @@ /* if(md->blake2s.outlen != outlen) return CRYPT_INVALID_ARG; */ - if (blake2s_is_lastblock(md)) { + if (s_blake2s_is_lastblock(md)) { return CRYPT_ERROR; } - blake2s_increment_counter(md, md->blake2s.curlen); - blake2s_set_lastblock(md); + s_blake2s_increment_counter(md, md->blake2s.curlen); + s_blake2s_set_lastblock(md); XMEMSET(md->blake2s.buf + md->blake2s.curlen, 0, BLAKE2S_BLOCKBYTES - md->blake2s.curlen); /* Padding */ - blake2s_compress(md, md->blake2s.buf); + s_blake2s_compress(md, md->blake2s.buf); for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ STORE32L(md->blake2s.h[i], buffer + i * 4); diff --git a/src/ltc/hashes/chc/chc.c b/src/ltc/hashes/chc/chc.c index fd69c01..e82b2b3 100644 --- a/src/ltc/hashes/chc/chc.c +++ b/src/ltc/hashes/chc/chc.c @@ -121,7 +121,7 @@ T0 <= encrypt T0 state <= state xor T0 xor T1 */ -static int chc_compress(hash_state *md, const unsigned char *buf) +static int s_chc_compress(hash_state *md, const unsigned char *buf) { unsigned char T[2][MAXBLOCKSIZE]; symmetric_key *key; @@ -154,8 +154,8 @@ @param len The length of the data (octets) @return CRYPT_OK if successful */ -static int _chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); -static HASH_PROCESS(_chc_process, chc_compress, chc, (unsigned long)cipher_blocksize) +static int ss_chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); +static HASH_PROCESS(ss_chc_process, s_chc_compress, chc, (unsigned long)cipher_blocksize) /** Process a block of memory though the hash @@ -179,7 +179,7 @@ return CRYPT_INVALID_CIPHER; } - return _chc_process(md, in, inlen); + return ss_chc_process(md, in, inlen); } /** @@ -221,7 +221,7 @@ while (md->chc.curlen < (unsigned long)cipher_blocksize) { md->chc.buf[md->chc.curlen++] = (unsigned char)0; } - chc_compress(md, md->chc.buf); + s_chc_compress(md, md->chc.buf); md->chc.curlen = 0; } @@ -232,7 +232,7 @@ /* store length */ STORE64L(md->chc.length, md->chc.buf+(cipher_blocksize-8)); - chc_compress(md, md->chc.buf); + s_chc_compress(md, md->chc.buf); /* copy output */ XMEMCPY(out, md->chc.state, cipher_blocksize); diff --git a/src/ltc/hashes/md2.c b/src/ltc/hashes/md2.c index 2b14976..6cf0a65 100644 --- a/src/ltc/hashes/md2.c +++ b/src/ltc/hashes/md2.c @@ -49,7 +49,7 @@ }; /* adds 16 bytes to the checksum */ -static void md2_update_chksum(hash_state *md) +static void s_md2_update_chksum(hash_state *md) { int j; unsigned char L; @@ -63,7 +63,7 @@ } } -static void md2_compress(hash_state *md) +static void s_md2_compress(hash_state *md) { int j, k; unsigned char t; @@ -126,8 +126,8 @@ /* is 16 bytes full? */ if (md->md2.curlen == 16) { - md2_compress(md); - md2_update_chksum(md); + s_md2_compress(md); + s_md2_update_chksum(md); md->md2.curlen = 0; } } @@ -159,12 +159,12 @@ } /* hash and update */ - md2_compress(md); - md2_update_chksum(md); + s_md2_compress(md); + s_md2_update_chksum(md); /* hash checksum */ XMEMCPY(md->md2.buf, md->md2.chksum, 16); - md2_compress(md); + s_md2_compress(md); /* output is lower 16 bytes of X */ XMEMCPY(out, md->md2.X, 16); diff --git a/src/ltc/hashes/md4.c b/src/ltc/hashes/md4.c index b3f2ddd..aadad5f 100644 --- a/src/ltc/hashes/md4.c +++ b/src/ltc/hashes/md4.c @@ -65,9 +65,9 @@ } #ifdef LTC_CLEAN_STACK -static int _md4_compress(hash_state *md, const unsigned char *buf) +static int ss_md4_compress(hash_state *md, const unsigned char *buf) #else -static int md4_compress(hash_state *md, const unsigned char *buf) +static int s_md4_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 x[16], a, b, c, d; @@ -149,10 +149,10 @@ } #ifdef LTC_CLEAN_STACK -static int md4_compress(hash_state *md, const unsigned char *buf) +static int s_md4_compress(hash_state *md, const unsigned char *buf) { int err; - err = _md4_compress(md, buf); + err = ss_md4_compress(md, buf); burn_stack(sizeof(ulong32) * 20 + sizeof(int)); return err; } @@ -182,7 +182,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(md4_process, md4_compress, md4, 64) +HASH_PROCESS(md4_process, s_md4_compress, md4, 64) /** Terminate the hash to get the digest @@ -215,7 +215,7 @@ while (md->md4.curlen < 64) { md->md4.buf[md->md4.curlen++] = (unsigned char)0; } - md4_compress(md, md->md4.buf); + s_md4_compress(md, md->md4.buf); md->md4.curlen = 0; } @@ -226,7 +226,7 @@ /* store length */ STORE64L(md->md4.length, md->md4.buf+56); - md4_compress(md, md->md4.buf); + s_md4_compress(md, md->md4.buf); /* copy output */ for (i = 0; i < 4; i++) { diff --git a/src/ltc/hashes/md5.c b/src/ltc/hashes/md5.c index 613b85d..ad404e1 100644 --- a/src/ltc/hashes/md5.c +++ b/src/ltc/hashes/md5.c @@ -90,9 +90,9 @@ #endif #ifdef LTC_CLEAN_STACK -static int _md5_compress(hash_state *md, const unsigned char *buf) +static int ss_md5_compress(hash_state *md, const unsigned char *buf) #else -static int md5_compress(hash_state *md, const unsigned char *buf) +static int s_md5_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 i, W[16], a, b, c, d; @@ -208,10 +208,10 @@ } #ifdef LTC_CLEAN_STACK -static int md5_compress(hash_state *md, const unsigned char *buf) +static int s_md5_compress(hash_state *md, const unsigned char *buf) { int err; - err = _md5_compress(md, buf); + err = ss_md5_compress(md, buf); burn_stack(sizeof(ulong32) * 21); return err; } @@ -241,7 +241,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(md5_process, md5_compress, md5, 64) +HASH_PROCESS(md5_process, s_md5_compress, md5, 64) /** Terminate the hash to get the digest @@ -275,7 +275,7 @@ while (md->md5.curlen < 64) { md->md5.buf[md->md5.curlen++] = (unsigned char)0; } - md5_compress(md, md->md5.buf); + s_md5_compress(md, md->md5.buf); md->md5.curlen = 0; } @@ -286,7 +286,7 @@ /* store length */ STORE64L(md->md5.length, md->md5.buf+56); - md5_compress(md, md->md5.buf); + s_md5_compress(md, md->md5.buf); /* copy output */ for (i = 0; i < 4; i++) { diff --git a/src/ltc/hashes/rmd128.c b/src/ltc/hashes/rmd128.c index 52602c7..e8f63e1 100644 --- a/src/ltc/hashes/rmd128.c +++ b/src/ltc/hashes/rmd128.c @@ -73,9 +73,9 @@ (a) = ROLc((a), (s)); #ifdef LTC_CLEAN_STACK -static int _rmd128_compress(hash_state *md, const unsigned char *buf) +static int ss_rmd128_compress(hash_state *md, const unsigned char *buf) #else -static int rmd128_compress(hash_state *md, const unsigned char *buf) +static int s_rmd128_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,X[16]; @@ -247,10 +247,10 @@ } #ifdef LTC_CLEAN_STACK -static int rmd128_compress(hash_state *md, const unsigned char *buf) +static int s_rmd128_compress(hash_state *md, const unsigned char *buf) { int err; - err = _rmd128_compress(md, buf); + err = ss_rmd128_compress(md, buf); burn_stack(sizeof(ulong32) * 24 + sizeof(int)); return err; } @@ -280,7 +280,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(rmd128_process, rmd128_compress, rmd128, 64) +HASH_PROCESS(rmd128_process, s_rmd128_compress, rmd128, 64) /** Terminate the hash to get the digest @@ -314,7 +314,7 @@ while (md->rmd128.curlen < 64) { md->rmd128.buf[md->rmd128.curlen++] = (unsigned char)0; } - rmd128_compress(md, md->rmd128.buf); + s_rmd128_compress(md, md->rmd128.buf); md->rmd128.curlen = 0; } @@ -325,7 +325,7 @@ /* store length */ STORE64L(md->rmd128.length, md->rmd128.buf+56); - rmd128_compress(md, md->rmd128.buf); + s_rmd128_compress(md, md->rmd128.buf); /* copy output */ for (i = 0; i < 4; i++) { diff --git a/src/ltc/hashes/rmd160.c b/src/ltc/hashes/rmd160.c index 9873917..1eba20a 100644 --- a/src/ltc/hashes/rmd160.c +++ b/src/ltc/hashes/rmd160.c @@ -93,9 +93,9 @@ #ifdef LTC_CLEAN_STACK -static int _rmd160_compress(hash_state *md, const unsigned char *buf) +static int ss_rmd160_compress(hash_state *md, const unsigned char *buf) #else -static int rmd160_compress(hash_state *md, const unsigned char *buf) +static int s_rmd160_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,ee,aaa,bbb,ccc,ddd,eee,X[16]; @@ -305,10 +305,10 @@ } #ifdef LTC_CLEAN_STACK -static int rmd160_compress(hash_state *md, const unsigned char *buf) +static int s_rmd160_compress(hash_state *md, const unsigned char *buf) { int err; - err = _rmd160_compress(md, buf); + err = ss_rmd160_compress(md, buf); burn_stack(sizeof(ulong32) * 26 + sizeof(int)); return err; } @@ -339,7 +339,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(rmd160_process, rmd160_compress, rmd160, 64) +HASH_PROCESS(rmd160_process, s_rmd160_compress, rmd160, 64) /** Terminate the hash to get the digest @@ -373,7 +373,7 @@ while (md->rmd160.curlen < 64) { md->rmd160.buf[md->rmd160.curlen++] = (unsigned char)0; } - rmd160_compress(md, md->rmd160.buf); + s_rmd160_compress(md, md->rmd160.buf); md->rmd160.curlen = 0; } @@ -384,7 +384,7 @@ /* store length */ STORE64L(md->rmd160.length, md->rmd160.buf+56); - rmd160_compress(md, md->rmd160.buf); + s_rmd160_compress(md, md->rmd160.buf); /* copy output */ for (i = 0; i < 5; i++) { diff --git a/src/ltc/hashes/rmd256.c b/src/ltc/hashes/rmd256.c index 42f20f6..0097198 100644 --- a/src/ltc/hashes/rmd256.c +++ b/src/ltc/hashes/rmd256.c @@ -67,9 +67,9 @@ (a) = ROLc((a), (s)); #ifdef LTC_CLEAN_STACK -static int _rmd256_compress(hash_state *md, const unsigned char *buf) +static int ss_rmd256_compress(hash_state *md, const unsigned char *buf) #else -static int rmd256_compress(hash_state *md, const unsigned char *buf) +static int s_rmd256_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,tmp,X[16]; @@ -256,10 +256,10 @@ } #ifdef LTC_CLEAN_STACK -static int rmd256_compress(hash_state *md, const unsigned char *buf) +static int s_rmd256_compress(hash_state *md, const unsigned char *buf) { int err; - err = _rmd256_compress(md, buf); + err = ss_rmd256_compress(md, buf); burn_stack(sizeof(ulong32) * 25 + sizeof(int)); return err; } @@ -293,7 +293,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(rmd256_process, rmd256_compress, rmd256, 64) +HASH_PROCESS(rmd256_process, s_rmd256_compress, rmd256, 64) /** Terminate the hash to get the digest @@ -327,7 +327,7 @@ while (md->rmd256.curlen < 64) { md->rmd256.buf[md->rmd256.curlen++] = (unsigned char)0; } - rmd256_compress(md, md->rmd256.buf); + s_rmd256_compress(md, md->rmd256.buf); md->rmd256.curlen = 0; } @@ -338,7 +338,7 @@ /* store length */ STORE64L(md->rmd256.length, md->rmd256.buf+56); - rmd256_compress(md, md->rmd256.buf); + s_rmd256_compress(md, md->rmd256.buf); /* copy output */ for (i = 0; i < 8; i++) { diff --git a/src/ltc/hashes/rmd320.c b/src/ltc/hashes/rmd320.c index f3bff83..0021d67 100644 --- a/src/ltc/hashes/rmd320.c +++ b/src/ltc/hashes/rmd320.c @@ -88,9 +88,9 @@ #ifdef LTC_CLEAN_STACK -static int _rmd320_compress(hash_state *md, const unsigned char *buf) +static int ss_rmd320_compress(hash_state *md, const unsigned char *buf) #else -static int rmd320_compress(hash_state *md, const unsigned char *buf) +static int s_rmd320_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,ee,aaa,bbb,ccc,ddd,eee,tmp,X[16]; @@ -319,10 +319,10 @@ } #ifdef LTC_CLEAN_STACK -static int rmd320_compress(hash_state *md, const unsigned char *buf) +static int s_rmd320_compress(hash_state *md, const unsigned char *buf) { int err; - err = _rmd320_compress(md, buf); + err = ss_rmd320_compress(md, buf); burn_stack(sizeof(ulong32) * 27 + sizeof(int)); return err; } @@ -358,7 +358,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(rmd320_process, rmd320_compress, rmd320, 64) +HASH_PROCESS(rmd320_process, s_rmd320_compress, rmd320, 64) /** Terminate the hash to get the digest @@ -392,7 +392,7 @@ while (md->rmd320.curlen < 64) { md->rmd320.buf[md->rmd320.curlen++] = (unsigned char)0; } - rmd320_compress(md, md->rmd320.buf); + s_rmd320_compress(md, md->rmd320.buf); md->rmd320.curlen = 0; } @@ -403,7 +403,7 @@ /* store length */ STORE64L(md->rmd320.length, md->rmd320.buf+56); - rmd320_compress(md, md->rmd320.buf); + s_rmd320_compress(md, md->rmd320.buf); /* copy output */ for (i = 0; i < 10; i++) { diff --git a/src/ltc/hashes/sha1.c b/src/ltc/hashes/sha1.c index 7057a3a..40709db 100644 --- a/src/ltc/hashes/sha1.c +++ b/src/ltc/hashes/sha1.c @@ -34,9 +34,9 @@ #define F3(x,y,z) (x ^ y ^ z) #ifdef LTC_CLEAN_STACK -static int _sha1_compress(hash_state *md, const unsigned char *buf) +static int ss_sha1_compress(hash_state *md, const unsigned char *buf) #else -static int sha1_compress(hash_state *md, const unsigned char *buf) +static int s_sha1_compress(hash_state *md, const unsigned char *buf) #endif { ulong32 a,b,c,d,e,W[80],i; @@ -140,10 +140,10 @@ } #ifdef LTC_CLEAN_STACK -static int sha1_compress(hash_state *md, const unsigned char *buf) +static int s_sha1_compress(hash_state *md, const unsigned char *buf) { int err; - err = _sha1_compress(md, buf); + err = ss_sha1_compress(md, buf); burn_stack(sizeof(ulong32) * 87); return err; } @@ -174,7 +174,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(sha1_process, sha1_compress, sha1, 64) +HASH_PROCESS(sha1_process, s_sha1_compress, sha1, 64) /** Terminate the hash to get the digest @@ -207,7 +207,7 @@ while (md->sha1.curlen < 64) { md->sha1.buf[md->sha1.curlen++] = (unsigned char)0; } - sha1_compress(md, md->sha1.buf); + s_sha1_compress(md, md->sha1.buf); md->sha1.curlen = 0; } @@ -218,7 +218,7 @@ /* store length */ STORE64H(md->sha1.length, md->sha1.buf+56); - sha1_compress(md, md->sha1.buf); + s_sha1_compress(md, md->sha1.buf); /* copy output */ for (i = 0; i < 5; i++) { diff --git a/src/ltc/hashes/sha2/sha256.c b/src/ltc/hashes/sha2/sha256.c index 6ae9179..ff20068 100644 --- a/src/ltc/hashes/sha2/sha256.c +++ b/src/ltc/hashes/sha2/sha256.c @@ -58,9 +58,9 @@ /* compress 512-bits */ #ifdef LTC_CLEAN_STACK -static int _sha256_compress(hash_state * md, const unsigned char *buf) +static int ss_sha256_compress(hash_state * md, const unsigned char *buf) #else -static int sha256_compress(hash_state * md, const unsigned char *buf) +static int s_sha256_compress(hash_state * md, const unsigned char *buf) #endif { ulong32 S[8], W[64], t0, t1; @@ -168,10 +168,8 @@ RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506ceb); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2); - +#endif #undef RND - -#endif /* feedback */ for (i = 0; i < 8; i++) { @@ -181,10 +179,10 @@ } #ifdef LTC_CLEAN_STACK -static int sha256_compress(hash_state * md, const unsigned char *buf) +static int s_sha256_compress(hash_state * md, const unsigned char *buf) { int err; - err = _sha256_compress(md, buf); + err = ss_sha256_compress(md, buf); burn_stack(sizeof(ulong32) * 74); return err; } @@ -219,7 +217,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(sha256_process, sha256_compress, sha256, 64) +HASH_PROCESS(sha256_process,s_sha256_compress, sha256, 64) /** Terminate the hash to get the digest @@ -253,7 +251,7 @@ while (md->sha256.curlen < 64) { md->sha256.buf[md->sha256.curlen++] = (unsigned char)0; } - sha256_compress(md, md->sha256.buf); + s_sha256_compress(md, md->sha256.buf); md->sha256.curlen = 0; } @@ -264,7 +262,7 @@ /* store length */ STORE64H(md->sha256.length, md->sha256.buf+56); - sha256_compress(md, md->sha256.buf); + s_sha256_compress(md, md->sha256.buf); /* copy output */ for (i = 0; i < 8; i++) { diff --git a/src/ltc/hashes/sha2/sha512.c b/src/ltc/hashes/sha2/sha512.c index 584725d..ef3a8c8 100644 --- a/src/ltc/hashes/sha2/sha512.c +++ b/src/ltc/hashes/sha2/sha512.c @@ -83,9 +83,9 @@ /* compress 1024-bits */ #ifdef LTC_CLEAN_STACK -static int _sha512_compress(hash_state * md, const unsigned char *buf) +static int ss_sha512_compress(hash_state * md, const unsigned char *buf) #else -static int sha512_compress(hash_state * md, const unsigned char *buf) +static int s_sha512_compress(hash_state * md, const unsigned char *buf) #endif { ulong64 S[8], W[80], t0, t1; @@ -150,10 +150,10 @@ /* compress 1024-bits */ #ifdef LTC_CLEAN_STACK -static int sha512_compress(hash_state * md, const unsigned char *buf) +static int s_sha512_compress(hash_state * md, const unsigned char *buf) { int err; - err = _sha512_compress(md, buf); + err = ss_sha512_compress(md, buf); burn_stack(sizeof(ulong64) * 90 + sizeof(int)); return err; } @@ -187,7 +187,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(sha512_process, sha512_compress, sha512, 128) +HASH_PROCESS(sha512_process, s_sha512_compress, sha512, 128) /** Terminate the hash to get the digest @@ -220,7 +220,7 @@ while (md->sha512.curlen < 128) { md->sha512.buf[md->sha512.curlen++] = (unsigned char)0; } - sha512_compress(md, md->sha512.buf); + s_sha512_compress(md, md->sha512.buf); md->sha512.curlen = 0; } @@ -234,7 +234,7 @@ /* store length */ STORE64H(md->sha512.length, md->sha512.buf+120); - sha512_compress(md, md->sha512.buf); + s_sha512_compress(md, md->sha512.buf); /* copy output */ for (i = 0; i < 8; i++) { diff --git a/src/ltc/hashes/sha3.c b/src/ltc/hashes/sha3.c index c064edb..4758e34 100644 --- a/src/ltc/hashes/sha3.c +++ b/src/ltc/hashes/sha3.c @@ -131,7 +131,7 @@ #define SHA3_KECCAK_SPONGE_WORDS 25 /* 1600 bits > 200 bytes > 25 x ulong64 */ #define SHA3_KECCAK_ROUNDS 24 -static const ulong64 keccakf_rndc[24] = { +static const ulong64 s_keccakf_rndc[24] = { CONST64(0x0000000000000001), CONST64(0x0000000000008082), CONST64(0x800000000000808a), CONST64(0x8000000080008000), CONST64(0x000000000000808b), CONST64(0x0000000080000001), @@ -146,15 +146,15 @@ CONST64(0x0000000080000001), CONST64(0x8000000080008008) }; -static const unsigned keccakf_rotc[24] = { +static const unsigned s_keccakf_rotc[24] = { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44 }; -static const unsigned keccakf_piln[24] = { +static const unsigned s_keccakf_piln[24] = { 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1 }; -static void keccakf(ulong64 s[25]) +static void s_keccakf(ulong64 s[25]) { int i, j, round; ulong64 t, bc[5]; @@ -173,9 +173,9 @@ /* Rho Pi */ t = s[1]; for(i = 0; i < 24; i++) { - j = keccakf_piln[i]; + j = s_keccakf_piln[i]; bc[0] = s[j]; - s[j] = ROL64(t, keccakf_rotc[i]); + s[j] = ROL64(t, s_keccakf_rotc[i]); t = bc[0]; } /* Chi */ @@ -188,11 +188,11 @@ } } /* Iota */ - s[0] ^= keccakf_rndc[round]; - } -} - -static LTC_INLINE int _done(hash_state *md, unsigned char *hash, ulong64 pad) + s[0] ^= s_keccakf_rndc[round]; + } +} + +static LTC_INLINE int ss_done(hash_state *md, unsigned char *hash, ulong64 pad) { unsigned i; @@ -201,7 +201,7 @@ md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (pad << (md->sha3.byte_index * 8))); md->sha3.s[SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words - 1] ^= CONST64(0x8000000000000000); - keccakf(md->sha3.s); + s_keccakf(md->sha3.s); /* store sha3.s[] as little-endian bytes into sha3.sb */ for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) { @@ -283,7 +283,7 @@ md->sha3.byte_index = 0; md->sha3.saved = 0; if(++md->sha3.word_index == (SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words)) { - keccakf(md->sha3.s); + s_keccakf(md->sha3.s); md->sha3.word_index = 0; } } @@ -297,7 +297,7 @@ LOAD64L(t, in); md->sha3.s[md->sha3.word_index] ^= t; if(++md->sha3.word_index == (SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words)) { - keccakf(md->sha3.s); + s_keccakf(md->sha3.s); md->sha3.word_index = 0; } } @@ -312,14 +312,14 @@ #ifdef LTC_SHA3 int sha3_done(hash_state *md, unsigned char *out) { - return _done(md, out, CONST64(0x06)); + return ss_done(md, out, CONST64(0x06)); } #endif #ifdef LTC_KECCAK int keccak_done(hash_state *md, unsigned char *out) { - return _done(md, out, CONST64(0x01)); + return ss_done(md, out, CONST64(0x01)); } #endif @@ -338,7 +338,7 @@ /* shake_xof operation must be done only once */ md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (CONST64(0x1F) << (md->sha3.byte_index * 8))); md->sha3.s[SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words - 1] ^= CONST64(0x8000000000000000); - keccakf(md->sha3.s); + s_keccakf(md->sha3.s); /* store sha3.s[] as little-endian bytes into sha3.sb */ for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) { STORE64L(md->sha3.s[i], md->sha3.sb + i * 8); @@ -349,7 +349,7 @@ for (idx = 0; idx < outlen; idx++) { if(md->sha3.byte_index >= (SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words) * 8) { - keccakf(md->sha3.s); + s_keccakf(md->sha3.s); /* store sha3.s[] as little-endian bytes into sha3.sb */ for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) { STORE64L(md->sha3.s[i], md->sha3.sb + i * 8); diff --git a/src/ltc/hashes/tiger.c b/src/ltc/hashes/tiger.c index 9c0586a..8ca2d54 100644 --- a/src/ltc/hashes/tiger.c +++ b/src/ltc/hashes/tiger.c @@ -547,14 +547,8 @@ CONST64(0xCD56D9430EA8280E) /* 1020 */, CONST64(0xC12591D7535F5065) /* 1021 */, CONST64(0xC83223F1720AEF96) /* 1022 */, CONST64(0xC3A0396F7363A51F) /* 1023 */}; -#ifdef _MSC_VER - #define INLINE __inline -#else - #define INLINE -#endif - /* one round of the hash function */ -INLINE static void tiger_round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, int mul) +LTC_INLINE static void tiger_round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, int mul) { ulong64 tmp; tmp = (*c ^= x); @@ -568,7 +562,7 @@ } /* one complete pass */ -static void pass(ulong64 *a, ulong64 *b, ulong64 *c, const ulong64 *x, int mul) +static void s_pass(ulong64 *a, ulong64 *b, ulong64 *c, const ulong64 *x, int mul) { tiger_round(a,b,c,x[0],mul); tiger_round(b,c,a,x[1],mul); @@ -581,7 +575,7 @@ } /* The key mixing schedule */ -static void key_schedule(ulong64 *x) +static void s_key_schedule(ulong64 *x) { x[0] -= x[7] ^ CONST64(0xA5A5A5A5A5A5A5A5); x[1] ^= x[0]; @@ -602,9 +596,9 @@ } #ifdef LTC_CLEAN_STACK -static int _tiger_compress(hash_state *md, const unsigned char *buf) +static int ss_tiger_compress(hash_state *md, const unsigned char *buf) #else -static int tiger_compress(hash_state *md, const unsigned char *buf) +static int s_tiger_compress(hash_state *md, const unsigned char *buf) #endif { ulong64 a, b, c, x[8]; @@ -618,11 +612,11 @@ b = md->tiger.state[1]; c = md->tiger.state[2]; - pass(&a,&b,&c,x,5); - key_schedule(x); - pass(&c,&a,&b,x,7); - key_schedule(x); - pass(&b,&c,&a,x,9); + s_pass(&a,&b,&c,x,5); + s_key_schedule(x); + s_pass(&c,&a,&b,x,7); + s_key_schedule(x); + s_pass(&b,&c,&a,x,9); /* store state */ md->tiger.state[0] = a ^ md->tiger.state[0]; @@ -633,10 +627,10 @@ } #ifdef LTC_CLEAN_STACK -static int tiger_compress(hash_state *md, const unsigned char *buf) +static int s_tiger_compress(hash_state *md, const unsigned char *buf) { int err; - err = _tiger_compress(md, buf); + err = ss_tiger_compress(md, buf); burn_stack(sizeof(ulong64) * 11 + sizeof(unsigned long)); return err; } @@ -665,7 +659,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(tiger_process, tiger_compress, tiger, 64) +HASH_PROCESS(tiger_process, s_tiger_compress, tiger, 64) /** Terminate the hash to get the digest @@ -695,7 +689,7 @@ while (md->tiger.curlen < 64) { md->tiger.buf[md->tiger.curlen++] = (unsigned char)0; } - tiger_compress(md, md->tiger.buf); + s_tiger_compress(md, md->tiger.buf); md->tiger.curlen = 0; } @@ -706,7 +700,7 @@ /* store length */ STORE64L(md->tiger.length, md->tiger.buf+56); - tiger_compress(md, md->tiger.buf); + s_tiger_compress(md, md->tiger.buf); /* copy output */ STORE64L(md->tiger.state[0], &out[0]); diff --git a/src/ltc/hashes/whirl/whirl.c b/src/ltc/hashes/whirl/whirl.c index 24ad7c9..da7db9c 100644 --- a/src/ltc/hashes/whirl/whirl.c +++ b/src/ltc/hashes/whirl/whirl.c @@ -29,7 +29,7 @@ }; /* the sboxes */ -#define __LTC_WHIRLTAB_C__ +#define LTC_WHIRLTAB_C #include "whirltab.c" /* get a_{i,j} */ @@ -47,9 +47,9 @@ SB7(GB(a, i-7, 0))) #ifdef LTC_CLEAN_STACK -static int _whirlpool_compress(hash_state *md, const unsigned char *buf) +static int ss_whirlpool_compress(hash_state *md, const unsigned char *buf) #else -static int whirlpool_compress(hash_state *md, const unsigned char *buf) +static int s_whirlpool_compress(hash_state *md, const unsigned char *buf) #endif { ulong64 K[2][8], T[3][8]; @@ -103,10 +103,10 @@ #ifdef LTC_CLEAN_STACK -static int whirlpool_compress(hash_state *md, const unsigned char *buf) +static int s_whirlpool_compress(hash_state *md, const unsigned char *buf) { int err; - err = _whirlpool_compress(md, buf); + err = ss_whirlpool_compress(md, buf); burn_stack((5 * 8 * sizeof(ulong64)) + (2 * sizeof(int))); return err; } @@ -132,7 +132,7 @@ @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -HASH_PROCESS(whirlpool_process, whirlpool_compress, whirlpool, 64) +HASH_PROCESS(whirlpool_process, s_whirlpool_compress, whirlpool, 64) /** Terminate the hash to get the digest @@ -165,7 +165,7 @@ while (md->whirlpool.curlen < 64) { md->whirlpool.buf[md->whirlpool.curlen++] = (unsigned char)0; } - whirlpool_compress(md, md->whirlpool.buf); + s_whirlpool_compress(md, md->whirlpool.buf); md->whirlpool.curlen = 0; } @@ -176,7 +176,7 @@ /* store length */ STORE64H(md->whirlpool.length, md->whirlpool.buf+56); - whirlpool_compress(md, md->whirlpool.buf); + s_whirlpool_compress(md, md->whirlpool.buf); /* copy output */ for (i = 0; i < 8; i++) { diff --git a/src/ltc/hashes/whirl/whirltab.c b/src/ltc/hashes/whirl/whirltab.c index bd31d02..42ecae4 100644 --- a/src/ltc/hashes/whirl/whirltab.c +++ b/src/ltc/hashes/whirl/whirltab.c @@ -6,7 +6,7 @@ LTC_WHIRLPOOL tables, Tom St Denis */ -#ifdef __LTC_WHIRLTAB_C__ +#ifdef LTC_WHIRLTAB_C static const ulong64 sbox0[] = { CONST64(0x18186018c07830d8), CONST64(0x23238c2305af4626), CONST64(0xc6c63fc67ef991b8), CONST64(0xe8e887e8136fcdfb), @@ -583,4 +583,4 @@ CONST64(0x6302aa71c81949d9), }; -#endif /* __LTC_WHIRLTAB_C__ */ +#endif /* LTC_WHIRLTAB_C */ diff --git a/src/ltc/headers/tomcrypt_custom.h b/src/ltc/headers/tomcrypt_custom.h index fef71d2..b13c2e0 100644 --- a/src/ltc/headers/tomcrypt_custom.h +++ b/src/ltc/headers/tomcrypt_custom.h @@ -585,6 +585,27 @@ #define LTC_PBES #endif +#if defined(LTC_CLEAN_STACK) +/* if you're sure that you want to use it, remove the line below */ + #error LTC_CLEAN_STACK is considered as broken +#endif + +#if defined(LTC_PBES) && !defined(LTC_PKCS_5) + #error LTC_PBES requires LTC_PKCS_5 +#endif + +#if defined(LTC_PBES) && !defined(LTC_PKCS_12) + #error LTC_PBES requires LTC_PKCS_12 +#endif + +#if defined(LTC_PKCS_5) && !defined(LTC_HMAC) + #error LTC_PKCS_5 requires LTC_HMAC +#endif + +#if defined(LTC_PKCS_5) && !defined(LTC_HASH_HELPERS) + #error LTC_PKCS_5 requires LTC_HASH_HELPERS +#endif + #if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL) #error Pelican-MAC requires LTC_RIJNDAEL #endif diff --git a/src/ltc/headers/tomcrypt_macros.h b/src/ltc/headers/tomcrypt_macros.h index fc428cb..94aa7c3 100644 --- a/src/ltc/headers/tomcrypt_macros.h +++ b/src/ltc/headers/tomcrypt_macros.h @@ -54,8 +54,8 @@ #ifdef LTC_HAVE_BSWAP_BUILTIN #define STORE32H(x, y) \ -do { ulong32 __t = __builtin_bswap32 ((x)); \ - XMEMCPY ((y), &__t, 4); } while(0) +do { ulong32 ttt = __builtin_bswap32 ((x)); \ + XMEMCPY ((y), &ttt, 4); } while(0) #define LOAD32H(x, y) \ do { XMEMCPY (&(x), (y), 4); \ @@ -93,8 +93,8 @@ #ifdef LTC_HAVE_BSWAP_BUILTIN #define STORE64H(x, y) \ -do { ulong64 __t = __builtin_bswap64 ((x)); \ - XMEMCPY ((y), &__t, 8); } while(0) +do { ulong64 ttt = __builtin_bswap64 ((x)); \ + XMEMCPY ((y), &ttt, 8); } while(0) #define LOAD64H(x, y) \ do { XMEMCPY (&(x), (y), 8); \ @@ -135,7 +135,7 @@ #ifdef ENDIAN_32BITWORD #define STORE32L(x, y) \ - do { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } while(0) + do { ulong32 ttt = (x); XMEMCPY(y, &ttt, 4); } while(0) #define LOAD32L(x, y) \ do { XMEMCPY(&(x), y, 4); } while(0) @@ -155,13 +155,13 @@ #else /* 64-bit words then */ #define STORE32L(x, y) \ - do { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } while(0) + do { ulong32 ttt = (x); XMEMCPY(y, &ttt, 4); } while(0) #define LOAD32L(x, y) \ do { XMEMCPY(&(x), y, 4); x &= 0xFFFFFFFF; } while(0) #define STORE64L(x, y) \ - do { ulong64 __t = (x); XMEMCPY(y, &__t, 8); } while(0) + do { ulong64 ttt = (x); XMEMCPY(y, &ttt, 8); } while(0) #define LOAD64L(x, y) \ do { XMEMCPY(&(x), y, 8); } while(0) @@ -195,7 +195,7 @@ #ifdef ENDIAN_32BITWORD #define STORE32H(x, y) \ - do { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } while(0) + do { ulong32 ttt = (x); XMEMCPY(y, &ttt, 4); } while(0) #define LOAD32H(x, y) \ do { XMEMCPY(&(x), y, 4); } while(0) @@ -215,13 +215,13 @@ #else /* 64-bit words then */ #define STORE32H(x, y) \ - do { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } while(0) + do { ulong32 ttt = (x); XMEMCPY(y, &ttt, 4); } while(0) #define LOAD32H(x, y) \ do { XMEMCPY(&(x), y, 4); x &= 0xFFFFFFFF; } while(0) #define STORE64H(x, y) \ - do { ulong64 __t = (x); XMEMCPY(y, &__t, 8); } while(0) + do { ulong64 ttt = (x); XMEMCPY(y, &ttt, 8); } while(0) #define LOAD64H(x, y) \ do { XMEMCPY(&(x), y, 8); } while(0) @@ -275,20 +275,20 @@ #ifndef LTC_NO_ROLC #define ROLc(word,i) ({ \ - ulong32 __ROLc_tmp = (word); \ + ulong32 ROLc_tmp = (word); \ __asm__ ("roll %2, %0" : \ - "=r" (__ROLc_tmp) : \ - "0" (__ROLc_tmp), \ + "=r" (ROLc_tmp) : \ + "0" (ROLc_tmp), \ "I" (i)); \ - __ROLc_tmp; \ + ROLc_tmp; \ }) #define RORc(word,i) ({ \ - ulong32 __RORc_tmp = (word); \ + ulong32 RORc_tmp = (word); \ __asm__ ("rorl %2, %0" : \ - "=r" (__RORc_tmp) : \ - "0" (__RORc_tmp), \ + "=r" (RORc_tmp) : \ + "0" (RORc_tmp), \ "I" (i)); \ - __RORc_tmp; \ + RORc_tmp; \ }) #else @@ -393,20 +393,20 @@ #ifndef LTC_NO_ROLC #define ROL64c(word,i) ({ \ - ulong64 __ROL64c_tmp = word; \ + ulong64 ROL64c_tmp = word; \ __asm__ ("rolq %2, %0" : \ - "=r" (__ROL64c_tmp) : \ - "0" (__ROL64c_tmp), \ + "=r" (ROL64c_tmp) : \ + "0" (ROL64c_tmp), \ "J" (i)); \ - __ROL64c_tmp; \ + ROL64c_tmp; \ }) #define ROR64c(word,i) ({ \ - ulong64 __ROR64c_tmp = word; \ + ulong64 ROR64c_tmp = word; \ __asm__ ("rorq %2, %0" : \ - "=r" (__ROR64c_tmp) : \ - "0" (__ROR64c_tmp), \ + "=r" (ROR64c_tmp) : \ + "0" (ROR64c_tmp), \ "J" (i)); \ - __ROR64c_tmp; \ + ROR64c_tmp; \ }) #else /* LTC_NO_ROLC */ diff --git a/src/ltc/headers/tomcrypt_misc.h b/src/ltc/headers/tomcrypt_misc.h index 41f1800..ae861fe 100644 --- a/src/ltc/headers/tomcrypt_misc.h +++ b/src/ltc/headers/tomcrypt_misc.h @@ -146,6 +146,9 @@ LTC_PAD_ISO_10126 = 0x1000U, #endif LTC_PAD_ANSI_X923 = 0x2000U, + /* The following padding modes don't contain the padding + * length as last byte of the padding. + */ LTC_PAD_ONE_AND_ZERO = 0x8000U, LTC_PAD_ZERO = 0x9000U, LTC_PAD_ZERO_ALWAYS = 0xA000U, diff --git a/src/ltc/headers/tomcrypt_pk.h b/src/ltc/headers/tomcrypt_pk.h index 55523e8..01b8126 100644 --- a/src/ltc/headers/tomcrypt_pk.h +++ b/src/ltc/headers/tomcrypt_pk.h @@ -55,20 +55,20 @@ void rsa_free(rsa_key *key); /* These use PKCS #1 v2.0 padding */ -#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \ - rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_PKCS_1_OAEP, _key) - -#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _stat, _key) \ - rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_PKCS_1_OAEP, _stat, _key) - -#define rsa_sign_hash(_in, _inlen, _out, _outlen, _prng, _prng_idx, _hash_idx, _saltlen, _key) \ - rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_PKCS_1_PSS, _prng, _prng_idx, _hash_idx, _saltlen, _key) - -#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \ - rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key) - -#define rsa_sign_saltlen_get_max(_hash_idx, _key) \ - rsa_sign_saltlen_get_max_ex(LTC_PKCS_1_PSS, _hash_idx, _key) +#define rsa_encrypt_key(in, inlen, out, outlen, lparam, lparamlen, prng, prng_idx, hash_idx, key) \ + rsa_encrypt_key_ex(in, inlen, out, outlen, lparam, lparamlen, prng, prng_idx, hash_idx, LTC_PKCS_1_OAEP, key) + +#define rsa_decrypt_key(in, inlen, out, outlen, lparam, lparamlen, hash_idx, stat, key) \ + rsa_decrypt_key_ex(in, inlen, out, outlen, lparam, lparamlen, hash_idx, LTC_PKCS_1_OAEP, stat, key) + +#define rsa_sign_hash(in, inlen, out, outlen, prng, prng_idx, hash_idx, saltlen, key) \ + rsa_sign_hash_ex(in, inlen, out, outlen, LTC_PKCS_1_PSS, prng, prng_idx, hash_idx, saltlen, key) + +#define rsa_verify_hash(sig, siglen, hash, hashlen, hash_idx, saltlen, stat, key) \ + rsa_verify_hash_ex(sig, siglen, hash, hashlen, LTC_PKCS_1_PSS, hash_idx, saltlen, stat, key) + +#define rsa_sign_saltlen_get_max(hash_idx, key) \ + rsa_sign_saltlen_get_max_ex(LTC_PKCS_1_PSS, hash_idx, key) /* These can be switched between PKCS #1 v2.x and PKCS #1 v1.5 paddings */ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen, @@ -540,7 +540,7 @@ LTC_MACRO_list[LTC_MACRO_temp].tag = 0; \ } while (0) -#define __LTC_SET_ASN1_IDENTIFIER(list, index, Class, Pc, Tag) \ +#define LTC_SET_ASN1_IDENTIFIER(list, index, Class, Pc, Tag) \ do { \ int LTC_MACRO_temp = (index); \ ltc_asn1_list *LTC_MACRO_list = (list); \ @@ -554,14 +554,14 @@ do { \ int LTC_MACRO_temp##__LINE__ = (index); \ LTC_SET_ASN1(list, LTC_MACRO_temp##__LINE__, LTC_ASN1_CUSTOM_TYPE, Data, 1); \ - __LTC_SET_ASN1_IDENTIFIER(list, LTC_MACRO_temp##__LINE__, Class, LTC_ASN1_PC_CONSTRUCTED, Tag); \ + LTC_SET_ASN1_IDENTIFIER(list, LTC_MACRO_temp##__LINE__, Class, LTC_ASN1_PC_CONSTRUCTED, Tag); \ } while (0) #define LTC_SET_ASN1_CUSTOM_PRIMITIVE(list, index, Class, Tag, Type, Data, Size) \ do { \ int LTC_MACRO_temp##__LINE__ = (index); \ LTC_SET_ASN1(list, LTC_MACRO_temp##__LINE__, LTC_ASN1_CUSTOM_TYPE, Data, Size); \ - __LTC_SET_ASN1_IDENTIFIER(list, LTC_MACRO_temp##__LINE__, Class, LTC_ASN1_PC_PRIMITIVE, Tag); \ + LTC_SET_ASN1_IDENTIFIER(list, LTC_MACRO_temp##__LINE__, Class, LTC_ASN1_PC_PRIMITIVE, Tag); \ list[LTC_MACRO_temp##__LINE__].used = (int)(Type); \ } while (0) diff --git a/src/ltc/headers/tomcrypt_private.h b/src/ltc/headers/tomcrypt_private.h index 589323d..4c3ea9f 100644 --- a/src/ltc/headers/tomcrypt_private.h +++ b/src/ltc/headers/tomcrypt_private.h @@ -90,7 +90,7 @@ if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ return CRYPT_INVALID_ARG; \ } \ - if ((md-> state_var .length + inlen) < md-> state_var .length) { \ + if ((md-> state_var .length + inlen * 8) < md-> state_var .length) { \ return CRYPT_HASH_OVERFLOW; \ } \ while (inlen > 0) { \ @@ -417,7 +417,7 @@ /* tomcrypt_prng.h */ -#define _LTC_PRNG_EXPORT(which) \ +#define LTC_PRNG_EXPORT(which) \ int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng) \ { \ unsigned long len = which ## _desc.export_size; \ diff --git a/src/ltc/mac/pelican/pelican.c b/src/ltc/mac/pelican/pelican.c index 31f6de1..25592cc 100644 --- a/src/ltc/mac/pelican/pelican.c +++ b/src/ltc/mac/pelican/pelican.c @@ -9,7 +9,7 @@ #ifdef LTC_PELICAN -#define __LTC_AES_TAB_C__ +#define LTC_AES_TAB_C #define ENCRYPT_ONLY #define PELI_TAB #include "../../ciphers/aes/aes_tab.c" @@ -45,7 +45,7 @@ return CRYPT_OK; } -static void _four_rounds(pelican_state *pelmac) +static void s_four_rounds(pelican_state *pelmac) { ulong32 s0, s1, s2, s3, t0, t1, t2, t3; int r; @@ -108,7 +108,7 @@ for (x = 0; x < 16; x += sizeof(LTC_FAST_TYPE)) { *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pelmac->state + x)) ^= *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)in + x)); } - _four_rounds(pelmac); + s_four_rounds(pelmac); in += 16; inlen -= 16; } @@ -118,7 +118,7 @@ while (inlen--) { pelmac->state[pelmac->buflen++] ^= *in++; if (pelmac->buflen == 16) { - _four_rounds(pelmac); + s_four_rounds(pelmac); pelmac->buflen = 0; } } @@ -142,7 +142,7 @@ } if (pelmac->buflen == 16) { - _four_rounds(pelmac); + s_four_rounds(pelmac); pelmac->buflen = 0; } pelmac->state[pelmac->buflen++] ^= 0x80; diff --git a/src/ltc/mac/poly1305/poly1305.c b/src/ltc/mac/poly1305/poly1305.c index 9af2500..32cdb55 100644 --- a/src/ltc/mac/poly1305/poly1305.c +++ b/src/ltc/mac/poly1305/poly1305.c @@ -11,7 +11,7 @@ #ifdef LTC_POLY1305 /* internal only */ -static void _poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen) +static void s_poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen) { const unsigned long hibit = (st->final) ? 0 : (1UL << 24); /* 1 << 128 */ ulong32 r0,r1,r2,r3,r4; @@ -135,14 +135,14 @@ in += want; st->leftover += want; if (st->leftover < 16) return CRYPT_OK; - _poly1305_block(st, st->buffer, 16); + s_poly1305_block(st, st->buffer, 16); st->leftover = 0; } /* process full blocks */ if (inlen >= 16) { unsigned long want = (inlen & ~(16 - 1)); - _poly1305_block(st, in, want); + s_poly1305_block(st, in, want); in += want; inlen -= want; } @@ -180,7 +180,7 @@ st->buffer[i++] = 1; for (; i < 16; i++) st->buffer[i] = 0; st->final = 1; - _poly1305_block(st, st->buffer, 16); + s_poly1305_block(st, st->buffer, 16); } /* fully carry h */ diff --git a/src/ltc/math/fp/ltc_ecc_fp_mulmod.c b/src/ltc/math/fp/ltc_ecc_fp_mulmod.c index cb18386..180b1e2 100644 --- a/src/ltc/math/fp/ltc_ecc_fp_mulmod.c +++ b/src/ltc/math/fp/ltc_ecc_fp_mulmod.c @@ -566,7 +566,7 @@ }; /* find a hole and free as required, return -1 if no hole found */ -static int _find_hole(void) +static int s_find_hole(void) { unsigned x; int y, z; @@ -602,7 +602,7 @@ } /* determine if a base is already in the cache and if so, where */ -static int _find_base(ecc_point *g) +static int s_find_base(ecc_point *g) { int x; for (x = 0; x < FP_ENTRIES; x++) { @@ -620,7 +620,7 @@ } /* add a new base to the cache */ -static int _add_entry(int idx, ecc_point *g) +static int s_add_entry(int idx, ecc_point *g) { unsigned x, y; @@ -662,7 +662,7 @@ * The algorithm builds patterns in increasing bit order by first making all * single bit input patterns, then all two bit input patterns and so on */ -static int _build_lut(int idx, void *a, void *modulus, void *mp, void *mu) +static int s_build_lut(int idx, void *a, void *modulus, void *mp, void *mu) { unsigned x, y, err, bitlen, lut_gap; void *tmp; @@ -769,7 +769,7 @@ } /* perform a fixed point ECC mulmod */ -static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus, void *mp, int map) +static int s_accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus, void *mp, int map) { unsigned char kb[128]; int x; @@ -892,7 +892,7 @@ #ifdef LTC_ECC_SHAMIR /* perform a fixed point ECC mulmod */ -static int _accel_fp_mul2add(int idx1, int idx2, +static int ss_accel_fp_mul2add(int idx1, int idx2, void *kA, void *kB, ecc_point *R, void *a, void *modulus, void *mp) { @@ -1115,13 +1115,13 @@ mu = NULL; LTC_MUTEX_LOCK(<c_ecc_fp_lock); /* find point */ - idx1 = _find_base(A); + idx1 = s_find_base(A); /* no entry? */ if (idx1 == -1) { /* find hole and add it */ - if ((idx1 = _find_hole()) >= 0) { - if ((err = _add_entry(idx1, A)) != CRYPT_OK) { + if ((idx1 = s_find_hole()) >= 0) { + if ((err = s_add_entry(idx1, A)) != CRYPT_OK) { goto LBL_ERR; } } @@ -1132,13 +1132,13 @@ } /* find point */ - idx2 = _find_base(B); + idx2 = s_find_base(B); /* no entry? */ if (idx2 == -1) { /* find hole and add it */ - if ((idx2 = _find_hole()) >= 0) { - if ((err = _add_entry(idx2, B)) != CRYPT_OK) { + if ((idx2 = s_find_hole()) >= 0) { + if ((err = s_add_entry(idx2, B)) != CRYPT_OK) { goto LBL_ERR; } } @@ -1162,7 +1162,7 @@ } /* build the LUT */ - if ((err = _build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) { + if ((err = s_build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) { goto LBL_ERR;; } } @@ -1183,7 +1183,7 @@ } /* build the LUT */ - if ((err = _build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) { + if ((err = s_build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) { goto LBL_ERR;; } } @@ -1194,7 +1194,7 @@ /* compute mp */ if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; } } - err = _accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp); + err = ss_accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp); } else { err = ltc_ecc_mul2add(A, kA, B, kB, C, a, modulus); } @@ -1228,15 +1228,15 @@ mu = NULL; LTC_MUTEX_LOCK(<c_ecc_fp_lock); /* find point */ - idx = _find_base(G); + idx = s_find_base(G); /* no entry? */ if (idx == -1) { /* find hole and add it */ - idx = _find_hole(); + idx = s_find_hole(); if (idx >= 0) { - if ((err = _add_entry(idx, G)) != CRYPT_OK) { + if ((err = s_add_entry(idx, G)) != CRYPT_OK) { goto LBL_ERR; } } @@ -1261,7 +1261,7 @@ } /* build the LUT */ - if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) { + if ((err = s_build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) { goto LBL_ERR;; } } @@ -1271,7 +1271,7 @@ /* compute mp */ if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; } } - err = _accel_fp_mul(idx, k, R, a, modulus, mp, map); + err = s_accel_fp_mul(idx, k, R, a, modulus, mp, map); } else { err = ltc_ecc_mulmod(k, G, R, a, modulus, map); } @@ -1287,7 +1287,7 @@ } /* helper function for freeing the cache ... must be called with the cache mutex locked */ -static void _ltc_ecc_fp_free_cache(void) +static void s_ltc_ecc_fp_free_cache(void) { unsigned x, y; for (x = 0; x < FP_ENTRIES; x++) { @@ -1312,7 +1312,7 @@ void ltc_ecc_fp_free(void) { LTC_MUTEX_LOCK(<c_ecc_fp_lock); - _ltc_ecc_fp_free_cache(); + s_ltc_ecc_fp_free_cache(); LTC_MUTEX_UNLOCK(<c_ecc_fp_lock); } @@ -1331,7 +1331,7 @@ void *mu = NULL; LTC_MUTEX_LOCK(<c_ecc_fp_lock); - if ((idx = _find_base(g)) >= 0) { + if ((idx = s_find_base(g)) >= 0) { /* it is already in the cache ... just check that the LUT is initialized */ if(fp_cache[idx].lru_count >= 2) { LTC_MUTEX_UNLOCK(<c_ecc_fp_lock); @@ -1339,11 +1339,11 @@ } } - if(idx == -1 && (idx = _find_hole()) == -1) { + if(idx == -1 && (idx = s_find_hole()) == -1) { err = CRYPT_BUFFER_OVERFLOW; goto LBL_ERR; } - if ((err = _add_entry(idx, g)) != CRYPT_OK) { + if ((err = s_add_entry(idx, g)) != CRYPT_OK) { goto LBL_ERR; } /* compute mp */ @@ -1360,7 +1360,7 @@ } /* build the LUT */ - if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) { + if ((err = s_build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) { goto LBL_ERR; } fp_cache[idx].lru_count = 2; @@ -1498,7 +1498,7 @@ /* * start with an empty cache */ - _ltc_ecc_fp_free_cache(); + s_ltc_ecc_fp_free_cache(); /* * decode the input packet: It consists of a sequence with a few @@ -1568,7 +1568,7 @@ ERR_OUT: if(asn1_list) XFREE(asn1_list); - _ltc_ecc_fp_free_cache(); + s_ltc_ecc_fp_free_cache(); LTC_MUTEX_UNLOCK(<c_ecc_fp_lock); return err; } diff --git a/src/ltc/math/rand_bn.c b/src/ltc/math/rand_bn.c index c7edbd1..03a81b7 100644 --- a/src/ltc/math/rand_bn.c +++ b/src/ltc/math/rand_bn.c @@ -19,7 +19,7 @@ if ((res = prng_is_valid(wprng)) != CRYPT_OK) return res; bytes = (bits+7) >> 3; - mask = 0xff << (8 - bits % 8); + mask = 0xff >> (bits % 8 == 0 ? 0 : 8 - bits % 8); /* allocate buffer */ if ((buf = XCALLOC(1, bytes)) == NULL) return CRYPT_MEM; @@ -30,7 +30,7 @@ goto cleanup; } /* mask bits */ - buf[0] &= ~mask; + buf[0] &= mask; /* load value */ if ((res = mp_read_unsigned_bin(N, buf, bytes)) != CRYPT_OK) goto cleanup; diff --git a/src/ltc/misc/adler32.c b/src/ltc/misc/adler32.c index c1fb5ec..8c2953d 100644 --- a/src/ltc/misc/adler32.c +++ b/src/ltc/misc/adler32.c @@ -10,7 +10,7 @@ */ #ifdef LTC_ADLER32 -static const unsigned long _adler32_base = 65521; +static const unsigned long s_adler32_base = 65521; void adler32_init(adler32_state *ctx) { @@ -35,10 +35,10 @@ length--; } while (length % 8 != 0); - if (s1 >= _adler32_base) { - s1 -= _adler32_base; + if (s1 >= s_adler32_base) { + s1 -= s_adler32_base; } - s2 %= _adler32_base; + s2 %= s_adler32_base; } while (length > 0) { @@ -62,14 +62,14 @@ length -= 8; input += 8; - if (s1 >= _adler32_base) { - s1 -= _adler32_base; + if (s1 >= s_adler32_base) { + s1 -= s_adler32_base; } - s2 %= _adler32_base; + s2 %= s_adler32_base; } - LTC_ARGCHKVD(s1 < _adler32_base); - LTC_ARGCHKVD(s2 < _adler32_base); + LTC_ARGCHKVD(s1 < s_adler32_base); + LTC_ARGCHKVD(s2 < s_adler32_base); ctx->s[0] = (unsigned short)s1; ctx->s[1] = (unsigned short)s2; diff --git a/src/ltc/misc/base64/base64_decode.c b/src/ltc/misc/base64/base64_decode.c index f97c1d3..5859111 100644 --- a/src/ltc/misc/base64/base64_decode.c +++ b/src/ltc/misc/base64/base64_decode.c @@ -75,7 +75,7 @@ relaxed = 2 }; -static int _base64_decode_internal(const char *in, unsigned long inlen, +static int s_base64_decode_internal(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen, const unsigned char *map, int mode) { @@ -149,7 +149,7 @@ int base64_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) { - return _base64_decode_internal(in, inlen, out, outlen, map_base64, insane); + return s_base64_decode_internal(in, inlen, out, outlen, map_base64, insane); } /** @@ -163,7 +163,7 @@ int base64_strict_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) { - return _base64_decode_internal(in, inlen, out, outlen, map_base64, strict); + return s_base64_decode_internal(in, inlen, out, outlen, map_base64, strict); } /** @@ -177,7 +177,7 @@ int base64_sane_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) { - return _base64_decode_internal(in, inlen, out, outlen, map_base64, relaxed); + return s_base64_decode_internal(in, inlen, out, outlen, map_base64, relaxed); } #endif /* LTC_BASE64 */ @@ -193,7 +193,7 @@ int base64url_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) { - return _base64_decode_internal(in, inlen, out, outlen, map_base64url, insane); + return s_base64_decode_internal(in, inlen, out, outlen, map_base64url, insane); } /** @@ -207,7 +207,7 @@ int base64url_strict_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) { - return _base64_decode_internal(in, inlen, out, outlen, map_base64url, strict); + return s_base64_decode_internal(in, inlen, out, outlen, map_base64url, strict); } /** @@ -221,7 +221,7 @@ int base64url_sane_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) { - return _base64_decode_internal(in, inlen, out, outlen, map_base64url, relaxed); + return s_base64_decode_internal(in, inlen, out, outlen, map_base64url, relaxed); } #endif /* LTC_BASE64_URL */ diff --git a/src/ltc/misc/base64/base64_encode.c b/src/ltc/misc/base64/base64_encode.c index d55a6ba..ad512d8 100644 --- a/src/ltc/misc/base64/base64_encode.c +++ b/src/ltc/misc/base64/base64_encode.c @@ -21,7 +21,7 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; #endif /* LTC_BASE64_URL */ -static int _base64_encode_internal(const unsigned char *in, unsigned long inlen, +static int s_base64_encode_internal(const unsigned char *in, unsigned long inlen, char *out, unsigned long *outlen, const char *codes, int pad) { @@ -83,7 +83,7 @@ int base64_encode(const unsigned char *in, unsigned long inlen, char *out, unsigned long *outlen) { - return _base64_encode_internal(in, inlen, out, outlen, codes_base64, 1); + return s_base64_encode_internal(in, inlen, out, outlen, codes_base64, 1); } #endif /* LTC_BASE64 */ @@ -100,13 +100,13 @@ int base64url_encode(const unsigned char *in, unsigned long inlen, char *out, unsigned long *outlen) { - return _base64_encode_internal(in, inlen, out, outlen, codes_base64url, 0); + return s_base64_encode_internal(in, inlen, out, outlen, codes_base64url, 0); } int base64url_strict_encode(const unsigned char *in, unsigned long inlen, char *out, unsigned long *outlen) { - return _base64_encode_internal(in, inlen, out, outlen, codes_base64url, 1); + return s_base64_encode_internal(in, inlen, out, outlen, codes_base64url, 1); } #endif /* LTC_BASE64_URL */ diff --git a/src/ltc/misc/bcrypt/bcrypt.c b/src/ltc/misc/bcrypt/bcrypt.c index ddce4b9..e1974f6 100644 --- a/src/ltc/misc/bcrypt/bcrypt.c +++ b/src/ltc/misc/bcrypt/bcrypt.c @@ -11,7 +11,7 @@ #define BCRYPT_WORDS 8 #define BCRYPT_HASHSIZE (BCRYPT_WORDS * 4) -static int _bcrypt_hash(const unsigned char *pt, +static int s_bcrypt_hash(const unsigned char *pt, const unsigned char *pass, unsigned long passlen, const unsigned char *salt, unsigned long saltlen, unsigned char *out, unsigned long *outlen) @@ -52,12 +52,12 @@ return CRYPT_OK; } -static int _bcrypt_pbkdf_hash(const unsigned char *pass, unsigned long passlen, +static int s_bcrypt_pbkdf_hash(const unsigned char *pass, unsigned long passlen, const unsigned char *salt, unsigned long saltlen, unsigned char *out, unsigned long *outlen) { const unsigned char pt[] = "OxychromaticBlowfishSwatDynamite"; - return _bcrypt_hash(pt, pass, passlen, salt, saltlen, out, outlen); + return s_bcrypt_hash(pt, pass, passlen, salt, saltlen, out, outlen); } /** @@ -143,7 +143,7 @@ goto LBL_ERR; } y = MAXBLOCKSIZE; - if ((err = _bcrypt_pbkdf_hash(hashed_pass, hashed_pass_len, buf[0], x, buf[1], &y)) != CRYPT_OK) { + if ((err = s_bcrypt_pbkdf_hash(hashed_pass, hashed_pass_len, buf[0], x, buf[1], &y)) != CRYPT_OK) { goto LBL_ERR; } XMEMCPY(buf[2], buf[1], y); @@ -155,7 +155,7 @@ goto LBL_ERR; } y = MAXBLOCKSIZE; - if ((err = _bcrypt_pbkdf_hash(hashed_pass, hashed_pass_len, buf[0], x, buf[1], &y)) != CRYPT_OK) { + if ((err = s_bcrypt_pbkdf_hash(hashed_pass, hashed_pass_len, buf[0], x, buf[1], &y)) != CRYPT_OK) { goto LBL_ERR; } for (x = 0; x < y; x++) { diff --git a/src/ltc/misc/compare_testvector.c b/src/ltc/misc/compare_testvector.c index 8c5af5b..3e0f6c4 100644 --- a/src/ltc/misc/compare_testvector.c +++ b/src/ltc/misc/compare_testvector.c @@ -9,7 +9,7 @@ */ #if defined(LTC_TEST) && defined(LTC_TEST_DBG) -static void _print_hex(const char* what, const void* v, const unsigned long l) +static void s_print_hex(const char* what, const void* v, const unsigned long l) { const unsigned char* p = v; unsigned long x, y = 0, z; @@ -65,8 +65,8 @@ #if defined(LTC_TEST) && defined(LTC_TEST_DBG) if (res != 0) { fprintf(stderr, "Testvector #%i of %s failed:\n", which, what); - _print_hex("SHOULD", should, should_len); - _print_hex("IS ", is, is_len); + s_print_hex("SHOULD", should, should_len); + s_print_hex("IS ", is, is_len); #if LTC_TEST_DBG > 1 } else { fprintf(stderr, "Testvector #%i of %s passed!\n", which, what); diff --git a/src/ltc/misc/crc32.c b/src/ltc/misc/crc32.c index c04c8e5..d90e830 100644 --- a/src/ltc/misc/crc32.c +++ b/src/ltc/misc/crc32.c @@ -10,7 +10,7 @@ */ #ifdef LTC_CRC32 -static const ulong32 _CRC32_NEGL = 0xffffffffUL; +static const ulong32 CRC32_NEGL = 0xffffffffUL; #if defined(ENDIAN_LITTLE) #define CRC32_INDEX(c) (c & 0xff) @@ -137,7 +137,7 @@ void crc32_init(crc32_state *ctx) { LTC_ARGCHKVD(ctx != NULL); - ctx->crc = _CRC32_NEGL; + ctx->crc = CRC32_NEGL; } void crc32_update(crc32_state *ctx, const unsigned char *input, unsigned long length) @@ -164,7 +164,7 @@ h = hash; crc = ctx->crc; - crc ^= _CRC32_NEGL; + crc ^= CRC32_NEGL; if (size > 4) size = 4; for (i = 0; i < size; i++) { diff --git a/src/ltc/misc/crypt/crypt_constants.c b/src/ltc/misc/crypt/crypt_constants.c index 4468201..9c1ed83 100644 --- a/src/ltc/misc/crypt/crypt_constants.c +++ b/src/ltc/misc/crypt/crypt_constants.c @@ -17,54 +17,54 @@ const int value; } crypt_constant; -#define _C_STRINGIFY(s) { #s, s } - -static const crypt_constant _crypt_constants[] = { - - _C_STRINGIFY(CRYPT_OK), - _C_STRINGIFY(CRYPT_ERROR), - _C_STRINGIFY(CRYPT_NOP), - _C_STRINGIFY(CRYPT_INVALID_KEYSIZE), - _C_STRINGIFY(CRYPT_INVALID_ROUNDS), - _C_STRINGIFY(CRYPT_FAIL_TESTVECTOR), - _C_STRINGIFY(CRYPT_BUFFER_OVERFLOW), - _C_STRINGIFY(CRYPT_INVALID_PACKET), - _C_STRINGIFY(CRYPT_INVALID_PRNGSIZE), - _C_STRINGIFY(CRYPT_ERROR_READPRNG), - _C_STRINGIFY(CRYPT_INVALID_CIPHER), - _C_STRINGIFY(CRYPT_INVALID_HASH), - _C_STRINGIFY(CRYPT_INVALID_PRNG), - _C_STRINGIFY(CRYPT_MEM), - _C_STRINGIFY(CRYPT_PK_TYPE_MISMATCH), - _C_STRINGIFY(CRYPT_PK_NOT_PRIVATE), - _C_STRINGIFY(CRYPT_INVALID_ARG), - _C_STRINGIFY(CRYPT_FILE_NOTFOUND), - _C_STRINGIFY(CRYPT_PK_INVALID_TYPE), - _C_STRINGIFY(CRYPT_OVERFLOW), - _C_STRINGIFY(CRYPT_PK_ASN1_ERROR), - _C_STRINGIFY(CRYPT_INPUT_TOO_LONG), - _C_STRINGIFY(CRYPT_PK_INVALID_SIZE), - _C_STRINGIFY(CRYPT_INVALID_PRIME_SIZE), - _C_STRINGIFY(CRYPT_PK_INVALID_PADDING), - _C_STRINGIFY(CRYPT_HASH_OVERFLOW), - - _C_STRINGIFY(PK_PUBLIC), - _C_STRINGIFY(PK_PRIVATE), - - _C_STRINGIFY(LTC_ENCRYPT), - _C_STRINGIFY(LTC_DECRYPT), +#define C_STRINGIFY(s) { #s, s } + +static const crypt_constant s_crypt_constants[] = { + + C_STRINGIFY(CRYPT_OK), + C_STRINGIFY(CRYPT_ERROR), + C_STRINGIFY(CRYPT_NOP), + C_STRINGIFY(CRYPT_INVALID_KEYSIZE), + C_STRINGIFY(CRYPT_INVALID_ROUNDS), + C_STRINGIFY(CRYPT_FAIL_TESTVECTOR), + C_STRINGIFY(CRYPT_BUFFER_OVERFLOW), + C_STRINGIFY(CRYPT_INVALID_PACKET), + C_STRINGIFY(CRYPT_INVALID_PRNGSIZE), + C_STRINGIFY(CRYPT_ERROR_READPRNG), + C_STRINGIFY(CRYPT_INVALID_CIPHER), + C_STRINGIFY(CRYPT_INVALID_HASH), + C_STRINGIFY(CRYPT_INVALID_PRNG), + C_STRINGIFY(CRYPT_MEM), + C_STRINGIFY(CRYPT_PK_TYPE_MISMATCH), + C_STRINGIFY(CRYPT_PK_NOT_PRIVATE), + C_STRINGIFY(CRYPT_INVALID_ARG), + C_STRINGIFY(CRYPT_FILE_NOTFOUND), + C_STRINGIFY(CRYPT_PK_INVALID_TYPE), + C_STRINGIFY(CRYPT_OVERFLOW), + C_STRINGIFY(CRYPT_PK_ASN1_ERROR), + C_STRINGIFY(CRYPT_INPUT_TOO_LONG), + C_STRINGIFY(CRYPT_PK_INVALID_SIZE), + C_STRINGIFY(CRYPT_INVALID_PRIME_SIZE), + C_STRINGIFY(CRYPT_PK_INVALID_PADDING), + C_STRINGIFY(CRYPT_HASH_OVERFLOW), + + C_STRINGIFY(PK_PUBLIC), + C_STRINGIFY(PK_PRIVATE), + + C_STRINGIFY(LTC_ENCRYPT), + C_STRINGIFY(LTC_DECRYPT), #ifdef LTC_PKCS_1 {"LTC_PKCS_1", 1}, /* Block types */ - _C_STRINGIFY(LTC_PKCS_1_EMSA), - _C_STRINGIFY(LTC_PKCS_1_EME), + C_STRINGIFY(LTC_PKCS_1_EMSA), + C_STRINGIFY(LTC_PKCS_1_EME), /* Padding types */ - _C_STRINGIFY(LTC_PKCS_1_V1_5), - _C_STRINGIFY(LTC_PKCS_1_OAEP), - _C_STRINGIFY(LTC_PKCS_1_PSS), - _C_STRINGIFY(LTC_PKCS_1_V1_5_NA1), + C_STRINGIFY(LTC_PKCS_1_V1_5), + C_STRINGIFY(LTC_PKCS_1_OAEP), + C_STRINGIFY(LTC_PKCS_1_PSS), + C_STRINGIFY(LTC_PKCS_1_V1_5_NA1), #else {"LTC_PKCS_1", 0}, #endif @@ -72,14 +72,14 @@ #ifdef LTC_PADDING {"LTC_PADDING", 1}, - _C_STRINGIFY(LTC_PAD_PKCS7), + C_STRINGIFY(LTC_PAD_PKCS7), #ifdef LTC_RNG_GET_BYTES - _C_STRINGIFY(LTC_PAD_ISO_10126), -#endif - _C_STRINGIFY(LTC_PAD_ANSI_X923), - _C_STRINGIFY(LTC_PAD_ONE_AND_ZERO), - _C_STRINGIFY(LTC_PAD_ZERO), - _C_STRINGIFY(LTC_PAD_ZERO_ALWAYS), + C_STRINGIFY(LTC_PAD_ISO_10126), +#endif + C_STRINGIFY(LTC_PAD_ANSI_X923), + C_STRINGIFY(LTC_PAD_ONE_AND_ZERO), + C_STRINGIFY(LTC_PAD_ZERO), + C_STRINGIFY(LTC_PAD_ZERO_ALWAYS), #else {"LTC_PADDING", 0}, #endif @@ -92,76 +92,76 @@ #ifdef LTC_MECC {"LTC_MECC", 1}, - _C_STRINGIFY(ECC_BUF_SIZE), - _C_STRINGIFY(ECC_MAXSIZE), + C_STRINGIFY(ECC_BUF_SIZE), + C_STRINGIFY(ECC_MAXSIZE), #else {"LTC_MECC", 0}, #endif #ifdef LTC_MDSA {"LTC_MDSA", 1}, - _C_STRINGIFY(LTC_MDSA_DELTA), - _C_STRINGIFY(LTC_MDSA_MAX_GROUP), + C_STRINGIFY(LTC_MDSA_DELTA), + C_STRINGIFY(LTC_MDSA_MAX_GROUP), #else {"LTC_MDSA", 0}, #endif #ifdef LTC_MILLER_RABIN_REPS - _C_STRINGIFY(LTC_MILLER_RABIN_REPS), + C_STRINGIFY(LTC_MILLER_RABIN_REPS), #endif #ifdef LTC_DER /* DER handling */ {"LTC_DER", 1}, - _C_STRINGIFY(LTC_ASN1_EOL), - _C_STRINGIFY(LTC_ASN1_BOOLEAN), - _C_STRINGIFY(LTC_ASN1_INTEGER), - _C_STRINGIFY(LTC_ASN1_SHORT_INTEGER), - _C_STRINGIFY(LTC_ASN1_BIT_STRING), - _C_STRINGIFY(LTC_ASN1_OCTET_STRING), - _C_STRINGIFY(LTC_ASN1_NULL), - _C_STRINGIFY(LTC_ASN1_OBJECT_IDENTIFIER), - _C_STRINGIFY(LTC_ASN1_IA5_STRING), - _C_STRINGIFY(LTC_ASN1_PRINTABLE_STRING), - _C_STRINGIFY(LTC_ASN1_UTF8_STRING), - _C_STRINGIFY(LTC_ASN1_UTCTIME), - _C_STRINGIFY(LTC_ASN1_CHOICE), - _C_STRINGIFY(LTC_ASN1_SEQUENCE), - _C_STRINGIFY(LTC_ASN1_SET), - _C_STRINGIFY(LTC_ASN1_SETOF), - _C_STRINGIFY(LTC_ASN1_RAW_BIT_STRING), - _C_STRINGIFY(LTC_ASN1_TELETEX_STRING), - _C_STRINGIFY(LTC_ASN1_GENERALIZEDTIME), - _C_STRINGIFY(LTC_ASN1_CUSTOM_TYPE), - _C_STRINGIFY(LTC_DER_MAX_RECURSION), + C_STRINGIFY(LTC_ASN1_EOL), + C_STRINGIFY(LTC_ASN1_BOOLEAN), + C_STRINGIFY(LTC_ASN1_INTEGER), + C_STRINGIFY(LTC_ASN1_SHORT_INTEGER), + C_STRINGIFY(LTC_ASN1_BIT_STRING), + C_STRINGIFY(LTC_ASN1_OCTET_STRING), + C_STRINGIFY(LTC_ASN1_NULL), + C_STRINGIFY(LTC_ASN1_OBJECT_IDENTIFIER), + C_STRINGIFY(LTC_ASN1_IA5_STRING), + C_STRINGIFY(LTC_ASN1_PRINTABLE_STRING), + C_STRINGIFY(LTC_ASN1_UTF8_STRING), + C_STRINGIFY(LTC_ASN1_UTCTIME), + C_STRINGIFY(LTC_ASN1_CHOICE), + C_STRINGIFY(LTC_ASN1_SEQUENCE), + C_STRINGIFY(LTC_ASN1_SET), + C_STRINGIFY(LTC_ASN1_SETOF), + C_STRINGIFY(LTC_ASN1_RAW_BIT_STRING), + C_STRINGIFY(LTC_ASN1_TELETEX_STRING), + C_STRINGIFY(LTC_ASN1_GENERALIZEDTIME), + C_STRINGIFY(LTC_ASN1_CUSTOM_TYPE), + C_STRINGIFY(LTC_DER_MAX_RECURSION), #else {"LTC_DER", 0}, #endif #ifdef LTC_CTR_MODE {"LTC_CTR_MODE", 1}, - _C_STRINGIFY(CTR_COUNTER_LITTLE_ENDIAN), - _C_STRINGIFY(CTR_COUNTER_BIG_ENDIAN), - _C_STRINGIFY(LTC_CTR_RFC3686), + C_STRINGIFY(CTR_COUNTER_LITTLE_ENDIAN), + C_STRINGIFY(CTR_COUNTER_BIG_ENDIAN), + C_STRINGIFY(LTC_CTR_RFC3686), #else {"LTC_CTR_MODE", 0}, #endif #ifdef LTC_GCM_MODE - _C_STRINGIFY(LTC_GCM_MODE_IV), - _C_STRINGIFY(LTC_GCM_MODE_AAD), - _C_STRINGIFY(LTC_GCM_MODE_TEXT), -#endif - - _C_STRINGIFY(LTC_MP_LT), - _C_STRINGIFY(LTC_MP_EQ), - _C_STRINGIFY(LTC_MP_GT), - - _C_STRINGIFY(LTC_MP_NO), - _C_STRINGIFY(LTC_MP_YES), - - _C_STRINGIFY(MAXBLOCKSIZE), - _C_STRINGIFY(TAB_SIZE), - _C_STRINGIFY(ARGTYPE), + C_STRINGIFY(LTC_GCM_MODE_IV), + C_STRINGIFY(LTC_GCM_MODE_AAD), + C_STRINGIFY(LTC_GCM_MODE_TEXT), +#endif + + C_STRINGIFY(LTC_MP_LT), + C_STRINGIFY(LTC_MP_EQ), + C_STRINGIFY(LTC_MP_GT), + + C_STRINGIFY(LTC_MP_NO), + C_STRINGIFY(LTC_MP_YES), + + C_STRINGIFY(MAXBLOCKSIZE), + C_STRINGIFY(TAB_SIZE), + C_STRINGIFY(ARGTYPE), #ifdef LTM_DESC {"LTM_DESC", 1}, @@ -229,10 +229,10 @@ */ int crypt_get_constant(const char* namein, int *valueout) { int i; - int _crypt_constants_len = sizeof(_crypt_constants) / sizeof(_crypt_constants[0]); - for (i=0; i<_crypt_constants_len; i++) { - if (XSTRCMP(_crypt_constants[i].name, namein) == 0) { - *valueout = _crypt_constants[i].value; + int count = sizeof(s_crypt_constants) / sizeof(s_crypt_constants[0]); + for (i=0; i total_len) return -1; total_len -= number_len; diff --git a/src/ltc/misc/crypt/crypt_sizes.c b/src/ltc/misc/crypt/crypt_sizes.c index 39b02ab..7545aa8 100644 --- a/src/ltc/misc/crypt/crypt_sizes.c +++ b/src/ltc/misc/crypt/crypt_sizes.c @@ -17,270 +17,270 @@ const unsigned int size; } crypt_size; -#define _SZ_STRINGIFY_S(s) { #s, sizeof(struct s) } -#define _SZ_STRINGIFY_T(s) { #s, sizeof(s) } - -static const crypt_size _crypt_sizes[] = { +#define SZ_STRINGIFY_S(s) { #s, sizeof(struct s) } +#define SZ_STRINGIFY_T(s) { #s, sizeof(s) } + +static const crypt_size s_crypt_sizes[] = { /* hash state sizes */ - _SZ_STRINGIFY_S(ltc_hash_descriptor), - _SZ_STRINGIFY_T(hash_state), + SZ_STRINGIFY_S(ltc_hash_descriptor), + SZ_STRINGIFY_T(hash_state), #ifdef LTC_CHC_HASH - _SZ_STRINGIFY_S(chc_state), + SZ_STRINGIFY_S(chc_state), #endif #ifdef LTC_WHIRLPOOL - _SZ_STRINGIFY_S(whirlpool_state), + SZ_STRINGIFY_S(whirlpool_state), #endif #ifdef LTC_SHA3 - _SZ_STRINGIFY_S(sha3_state), + SZ_STRINGIFY_S(sha3_state), #endif #ifdef LTC_SHA512 - _SZ_STRINGIFY_S(sha512_state), + SZ_STRINGIFY_S(sha512_state), #endif #ifdef LTC_SHA256 - _SZ_STRINGIFY_S(sha256_state), + SZ_STRINGIFY_S(sha256_state), #endif #ifdef LTC_SHA1 - _SZ_STRINGIFY_S(sha1_state), + SZ_STRINGIFY_S(sha1_state), #endif #ifdef LTC_MD5 - _SZ_STRINGIFY_S(md5_state), + SZ_STRINGIFY_S(md5_state), #endif #ifdef LTC_MD4 - _SZ_STRINGIFY_S(md4_state), + SZ_STRINGIFY_S(md4_state), #endif #ifdef LTC_MD2 - _SZ_STRINGIFY_S(md2_state), + SZ_STRINGIFY_S(md2_state), #endif #ifdef LTC_TIGER - _SZ_STRINGIFY_S(tiger_state), + SZ_STRINGIFY_S(tiger_state), #endif #ifdef LTC_RIPEMD128 - _SZ_STRINGIFY_S(rmd128_state), + SZ_STRINGIFY_S(rmd128_state), #endif #ifdef LTC_RIPEMD160 - _SZ_STRINGIFY_S(rmd160_state), + SZ_STRINGIFY_S(rmd160_state), #endif #ifdef LTC_RIPEMD256 - _SZ_STRINGIFY_S(rmd256_state), + SZ_STRINGIFY_S(rmd256_state), #endif #ifdef LTC_RIPEMD320 - _SZ_STRINGIFY_S(rmd320_state), + SZ_STRINGIFY_S(rmd320_state), #endif #ifdef LTC_BLAKE2S - _SZ_STRINGIFY_S(blake2s_state), + SZ_STRINGIFY_S(blake2s_state), #endif #ifdef LTC_BLAKE2B - _SZ_STRINGIFY_S(blake2b_state), + SZ_STRINGIFY_S(blake2b_state), #endif /* block cipher key sizes */ - _SZ_STRINGIFY_S(ltc_cipher_descriptor), - _SZ_STRINGIFY_T(symmetric_key), + SZ_STRINGIFY_S(ltc_cipher_descriptor), + SZ_STRINGIFY_T(symmetric_key), #ifdef LTC_ANUBIS - _SZ_STRINGIFY_S(anubis_key), + SZ_STRINGIFY_S(anubis_key), #endif #ifdef LTC_CAMELLIA - _SZ_STRINGIFY_S(camellia_key), + SZ_STRINGIFY_S(camellia_key), #endif #ifdef LTC_BLOWFISH - _SZ_STRINGIFY_S(blowfish_key), + SZ_STRINGIFY_S(blowfish_key), #endif #ifdef LTC_CAST5 - _SZ_STRINGIFY_S(cast5_key), + SZ_STRINGIFY_S(cast5_key), #endif #ifdef LTC_DES - _SZ_STRINGIFY_S(des_key), - _SZ_STRINGIFY_S(des3_key), + SZ_STRINGIFY_S(des_key), + SZ_STRINGIFY_S(des3_key), #endif #ifdef LTC_IDEA - _SZ_STRINGIFY_S(idea_key), + SZ_STRINGIFY_S(idea_key), #endif #ifdef LTC_KASUMI - _SZ_STRINGIFY_S(kasumi_key), + SZ_STRINGIFY_S(kasumi_key), #endif #ifdef LTC_KHAZAD - _SZ_STRINGIFY_S(khazad_key), + SZ_STRINGIFY_S(khazad_key), #endif #ifdef LTC_KSEED - _SZ_STRINGIFY_S(kseed_key), + SZ_STRINGIFY_S(kseed_key), #endif #ifdef LTC_MULTI2 - _SZ_STRINGIFY_S(multi2_key), + SZ_STRINGIFY_S(multi2_key), #endif #ifdef LTC_NOEKEON - _SZ_STRINGIFY_S(noekeon_key), + SZ_STRINGIFY_S(noekeon_key), #endif #ifdef LTC_RC2 - _SZ_STRINGIFY_S(rc2_key), + SZ_STRINGIFY_S(rc2_key), #endif #ifdef LTC_RC5 - _SZ_STRINGIFY_S(rc5_key), + SZ_STRINGIFY_S(rc5_key), #endif #ifdef LTC_RC6 - _SZ_STRINGIFY_S(rc6_key), + SZ_STRINGIFY_S(rc6_key), #endif #ifdef LTC_SERPENT - _SZ_STRINGIFY_S(serpent_key), + SZ_STRINGIFY_S(serpent_key), #endif #ifdef LTC_SKIPJACK - _SZ_STRINGIFY_S(skipjack_key), + SZ_STRINGIFY_S(skipjack_key), #endif #ifdef LTC_XTEA - _SZ_STRINGIFY_S(xtea_key), + SZ_STRINGIFY_S(xtea_key), #endif #ifdef LTC_RIJNDAEL - _SZ_STRINGIFY_S(rijndael_key), + SZ_STRINGIFY_S(rijndael_key), #endif #ifdef LTC_SAFER - _SZ_STRINGIFY_S(safer_key), + SZ_STRINGIFY_S(safer_key), #endif #ifdef LTC_SAFERP - _SZ_STRINGIFY_S(saferp_key), + SZ_STRINGIFY_S(saferp_key), #endif #ifdef LTC_TWOFISH - _SZ_STRINGIFY_S(twofish_key), + SZ_STRINGIFY_S(twofish_key), #endif /* mode sizes */ #ifdef LTC_ECB_MODE - _SZ_STRINGIFY_T(symmetric_ECB), + SZ_STRINGIFY_T(symmetric_ECB), #endif #ifdef LTC_CFB_MODE - _SZ_STRINGIFY_T(symmetric_CFB), + SZ_STRINGIFY_T(symmetric_CFB), #endif #ifdef LTC_OFB_MODE - _SZ_STRINGIFY_T(symmetric_OFB), + SZ_STRINGIFY_T(symmetric_OFB), #endif #ifdef LTC_CBC_MODE - _SZ_STRINGIFY_T(symmetric_CBC), + SZ_STRINGIFY_T(symmetric_CBC), #endif #ifdef LTC_CTR_MODE - _SZ_STRINGIFY_T(symmetric_CTR), + SZ_STRINGIFY_T(symmetric_CTR), #endif #ifdef LTC_LRW_MODE - _SZ_STRINGIFY_T(symmetric_LRW), + SZ_STRINGIFY_T(symmetric_LRW), #endif #ifdef LTC_F8_MODE - _SZ_STRINGIFY_T(symmetric_F8), + SZ_STRINGIFY_T(symmetric_F8), #endif #ifdef LTC_XTS_MODE - _SZ_STRINGIFY_T(symmetric_xts), + SZ_STRINGIFY_T(symmetric_xts), #endif /* stream cipher sizes */ #ifdef LTC_CHACHA - _SZ_STRINGIFY_T(chacha_state), + SZ_STRINGIFY_T(chacha_state), #endif #ifdef LTC_SALSA20 - _SZ_STRINGIFY_T(salsa20_state), + SZ_STRINGIFY_T(salsa20_state), #endif #ifdef LTC_SOSEMANUK - _SZ_STRINGIFY_T(sosemanuk_state), + SZ_STRINGIFY_T(sosemanuk_state), #endif #ifdef LTC_RABBIT - _SZ_STRINGIFY_T(rabbit_state), + SZ_STRINGIFY_T(rabbit_state), #endif #ifdef LTC_RC4_STREAM - _SZ_STRINGIFY_T(rc4_state), + SZ_STRINGIFY_T(rc4_state), #endif #ifdef LTC_SOBER128_STREAM - _SZ_STRINGIFY_T(sober128_state), + SZ_STRINGIFY_T(sober128_state), #endif /* MAC sizes -- no states for ccm, lrw */ #ifdef LTC_HMAC - _SZ_STRINGIFY_T(hmac_state), + SZ_STRINGIFY_T(hmac_state), #endif #ifdef LTC_OMAC - _SZ_STRINGIFY_T(omac_state), + SZ_STRINGIFY_T(omac_state), #endif #ifdef LTC_PMAC - _SZ_STRINGIFY_T(pmac_state), + SZ_STRINGIFY_T(pmac_state), #endif #ifdef LTC_POLY1305 - _SZ_STRINGIFY_T(poly1305_state), + SZ_STRINGIFY_T(poly1305_state), #endif #ifdef LTC_EAX_MODE - _SZ_STRINGIFY_T(eax_state), + SZ_STRINGIFY_T(eax_state), #endif #ifdef LTC_OCB_MODE - _SZ_STRINGIFY_T(ocb_state), + SZ_STRINGIFY_T(ocb_state), #endif #ifdef LTC_OCB3_MODE - _SZ_STRINGIFY_T(ocb3_state), + SZ_STRINGIFY_T(ocb3_state), #endif #ifdef LTC_CCM_MODE - _SZ_STRINGIFY_T(ccm_state), + SZ_STRINGIFY_T(ccm_state), #endif #ifdef LTC_GCM_MODE - _SZ_STRINGIFY_T(gcm_state), + SZ_STRINGIFY_T(gcm_state), #endif #ifdef LTC_PELICAN - _SZ_STRINGIFY_T(pelican_state), + SZ_STRINGIFY_T(pelican_state), #endif #ifdef LTC_XCBC - _SZ_STRINGIFY_T(xcbc_state), + SZ_STRINGIFY_T(xcbc_state), #endif #ifdef LTC_F9_MODE - _SZ_STRINGIFY_T(f9_state), + SZ_STRINGIFY_T(f9_state), #endif #ifdef LTC_CHACHA20POLY1305_MODE - _SZ_STRINGIFY_T(chacha20poly1305_state), + SZ_STRINGIFY_T(chacha20poly1305_state), #endif /* asymmetric keys */ #ifdef LTC_MRSA - _SZ_STRINGIFY_T(rsa_key), + SZ_STRINGIFY_T(rsa_key), #endif #ifdef LTC_MDSA - _SZ_STRINGIFY_T(dsa_key), + SZ_STRINGIFY_T(dsa_key), #endif #ifdef LTC_MDH - _SZ_STRINGIFY_T(dh_key), + SZ_STRINGIFY_T(dh_key), #endif #ifdef LTC_MECC - _SZ_STRINGIFY_T(ltc_ecc_curve), - _SZ_STRINGIFY_T(ecc_point), - _SZ_STRINGIFY_T(ecc_key), + SZ_STRINGIFY_T(ltc_ecc_curve), + SZ_STRINGIFY_T(ecc_point), + SZ_STRINGIFY_T(ecc_key), #endif /* DER handling */ #ifdef LTC_DER - _SZ_STRINGIFY_T(ltc_asn1_list), /* a list entry */ - _SZ_STRINGIFY_T(ltc_utctime), - _SZ_STRINGIFY_T(ltc_generalizedtime), + SZ_STRINGIFY_T(ltc_asn1_list), /* a list entry */ + SZ_STRINGIFY_T(ltc_utctime), + SZ_STRINGIFY_T(ltc_generalizedtime), #endif /* prng state sizes */ - _SZ_STRINGIFY_S(ltc_prng_descriptor), - _SZ_STRINGIFY_T(prng_state), + SZ_STRINGIFY_S(ltc_prng_descriptor), + SZ_STRINGIFY_T(prng_state), #ifdef LTC_FORTUNA - _SZ_STRINGIFY_S(fortuna_prng), + SZ_STRINGIFY_S(fortuna_prng), #endif #ifdef LTC_CHACHA20_PRNG - _SZ_STRINGIFY_S(chacha20_prng), + SZ_STRINGIFY_S(chacha20_prng), #endif #ifdef LTC_RC4 - _SZ_STRINGIFY_S(rc4_prng), + SZ_STRINGIFY_S(rc4_prng), #endif #ifdef LTC_SOBER128 - _SZ_STRINGIFY_S(sober128_prng), + SZ_STRINGIFY_S(sober128_prng), #endif #ifdef LTC_YARROW - _SZ_STRINGIFY_S(yarrow_prng), + SZ_STRINGIFY_S(yarrow_prng), #endif /* sprng has no state as it uses other potentially available sources */ /* like /dev/random. See Developers Guide for more info. */ #ifdef LTC_ADLER32 - _SZ_STRINGIFY_T(adler32_state), + SZ_STRINGIFY_T(adler32_state), #endif #ifdef LTC_CRC32 - _SZ_STRINGIFY_T(crc32_state), -#endif - - _SZ_STRINGIFY_T(ltc_mp_digit), - _SZ_STRINGIFY_T(ltc_math_descriptor) + SZ_STRINGIFY_T(crc32_state), +#endif + + SZ_STRINGIFY_T(ltc_mp_digit), + SZ_STRINGIFY_T(ltc_math_descriptor) }; @@ -290,10 +290,10 @@ */ int crypt_get_size(const char* namein, unsigned int *sizeout) { int i; - int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]); + int count = sizeof(s_crypt_sizes) / sizeof(s_crypt_sizes[0]); for (i=0; i total_len) return -1; total_len -= number_len; diff --git a/src/ltc/misc/padding/padding_pad.c b/src/ltc/misc/padding/padding_pad.c index 36c000e..8a775b3 100644 --- a/src/ltc/misc/padding/padding_pad.c +++ b/src/ltc/misc/padding/padding_pad.c @@ -11,7 +11,7 @@ @param mode Mask of (LTC_PAD_xxx | block_length) @return CRYPT_OK on success */ -static int _padding_padded_length(unsigned long *length, unsigned long mode) +static int s_padding_padded_length(unsigned long *length, unsigned long mode) { enum padding_type padding; unsigned char pad, block_length, r, t; @@ -87,7 +87,7 @@ LTC_ARGCHK(padded_length != NULL); l = length; - if ((err = _padding_padded_length(&l, mode)) != CRYPT_OK) { + if ((err = s_padding_padded_length(&l, mode)) != CRYPT_OK) { return err; } diff --git a/src/ltc/misc/pbes/pbes1.c b/src/ltc/misc/pbes/pbes1.c index 041486d..f33a009 100644 --- a/src/ltc/misc/pbes/pbes1.c +++ b/src/ltc/misc/pbes/pbes1.c @@ -4,7 +4,7 @@ #ifdef LTC_PBES -static int _pkcs_5_alg1_wrap(const unsigned char *password, unsigned long password_len, +static int s_pkcs_5_alg1_wrap(const unsigned char *password, unsigned long password_len, const unsigned char *salt, unsigned long salt_len, int iteration_count, int hash_idx, unsigned char *out, unsigned long *outlen) @@ -13,7 +13,7 @@ return pkcs_5_alg1(password, password_len, salt, iteration_count, hash_idx, out, outlen); } -static int _pkcs_12_wrap(const unsigned char *password, unsigned long password_len, +static int s_pkcs_12_wrap(const unsigned char *password, unsigned long password_len, const unsigned char *salt, unsigned long salt_len, int iteration_count, int hash_idx, unsigned char *out, unsigned long *outlen) @@ -40,14 +40,14 @@ return err; } -static const pbes_properties _pbes1_types[] = { - { _pkcs_5_alg1_wrap, "md2", "des", 8, 8 }, - { _pkcs_5_alg1_wrap, "md2", "rc2", 8, 8 }, - { _pkcs_5_alg1_wrap, "md5", "des", 8, 8 }, - { _pkcs_5_alg1_wrap, "md5", "rc2", 8, 8 }, - { _pkcs_5_alg1_wrap, "sha1", "des", 8, 8 }, - { _pkcs_5_alg1_wrap, "sha1", "rc2", 8, 8 }, - { _pkcs_12_wrap, "sha1", "3des", 24, 8 }, +static const pbes_properties s_pbes1_types[] = { + { s_pkcs_5_alg1_wrap, "md2", "des", 8, 8 }, + { s_pkcs_5_alg1_wrap, "md2", "rc2", 8, 8 }, + { s_pkcs_5_alg1_wrap, "md5", "des", 8, 8 }, + { s_pkcs_5_alg1_wrap, "md5", "rc2", 8, 8 }, + { s_pkcs_5_alg1_wrap, "sha1", "des", 8, 8 }, + { s_pkcs_5_alg1_wrap, "sha1", "rc2", 8, 8 }, + { s_pkcs_12_wrap, "sha1", "3des", 24, 8 }, }; typedef struct { @@ -55,23 +55,23 @@ const char *oid; } oid_to_pbes; -static const oid_to_pbes _pbes1_list[] = { - { &_pbes1_types[0], "1.2.840.113549.1.5.1" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.1 pbeWithMD2AndDES-CBC */ - { &_pbes1_types[1], "1.2.840.113549.1.5.4" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.4 pbeWithMD2AndRC2-CBC */ - { &_pbes1_types[2], "1.2.840.113549.1.5.3" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.3 pbeWithMD5AndDES-CBC */ - { &_pbes1_types[3], "1.2.840.113549.1.5.6" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.6 pbeWithMD5AndRC2-CBC */ - { &_pbes1_types[4], "1.2.840.113549.1.5.10" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.10 pbeWithSHA1AndDES-CBC */ - { &_pbes1_types[5], "1.2.840.113549.1.5.11" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.11 pbeWithSHA1AndRC2-CBC */ - { &_pbes1_types[6], "1.2.840.113549.1.12.1.3" }, /* http://www.oid-info.com/get/1.2.840.113549.1.12.1.3 pbeWithSHAAnd3-KeyTripleDES-CBC */ +static const oid_to_pbes s_pbes1_list[] = { + { &s_pbes1_types[0], "1.2.840.113549.1.5.1" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.1 pbeWithMD2AndDES-CBC */ + { &s_pbes1_types[1], "1.2.840.113549.1.5.4" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.4 pbeWithMD2AndRC2-CBC */ + { &s_pbes1_types[2], "1.2.840.113549.1.5.3" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.3 pbeWithMD5AndDES-CBC */ + { &s_pbes1_types[3], "1.2.840.113549.1.5.6" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.6 pbeWithMD5AndRC2-CBC */ + { &s_pbes1_types[4], "1.2.840.113549.1.5.10" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.10 pbeWithSHA1AndDES-CBC */ + { &s_pbes1_types[5], "1.2.840.113549.1.5.11" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.11 pbeWithSHA1AndRC2-CBC */ + { &s_pbes1_types[6], "1.2.840.113549.1.12.1.3" }, /* http://www.oid-info.com/get/1.2.840.113549.1.12.1.3 pbeWithSHAAnd3-KeyTripleDES-CBC */ { 0 }, }; -static int _pbes1_from_oid(const ltc_asn1_list *oid, pbes_properties *res) +static int s_pbes1_from_oid(const ltc_asn1_list *oid, pbes_properties *res) { unsigned int i; - for (i = 0; _pbes1_list[i].data != NULL; ++i) { - if (pk_oid_cmp_with_asn1(_pbes1_list[i].oid, oid) == CRYPT_OK) { - if (res != NULL) *res = *_pbes1_list[i].data; + for (i = 0; s_pbes1_list[i].data != NULL; ++i) { + if (pk_oid_cmp_with_asn1(s_pbes1_list[i].oid, oid) == CRYPT_OK) { + if (res != NULL) *res = *s_pbes1_list[i].data; return CRYPT_OK; } } @@ -92,7 +92,7 @@ LTC_ARGCHK(s != NULL); LTC_ARGCHK(res != NULL); - if ((err = _pbes1_from_oid(s, &res->type)) != CRYPT_OK) return err; + if ((err = s_pbes1_from_oid(s, &res->type)) != CRYPT_OK) return err; if (!LTC_ASN1_IS_TYPE(s->next, LTC_ASN1_SEQUENCE) || !LTC_ASN1_IS_TYPE(s->next->child, LTC_ASN1_OCTET_STRING) || diff --git a/src/ltc/misc/pbes/pbes2.c b/src/ltc/misc/pbes/pbes2.c index 6e9bb56..3378cd6 100644 --- a/src/ltc/misc/pbes/pbes2.c +++ b/src/ltc/misc/pbes/pbes2.c @@ -4,15 +4,15 @@ #ifdef LTC_PBES -static const char * const _oid_pbes2 = "1.2.840.113549.1.5.13"; -static const char * const _oid_pbkdf2 = "1.2.840.113549.1.5.12"; +static const char * const s_oid_pbes2 = "1.2.840.113549.1.5.13"; +static const char * const s_oid_pbkdf2 = "1.2.840.113549.1.5.12"; typedef struct { const char *oid; const char *id; } oid_id_st; -static const oid_id_st _hmac_oid_names[] = { +static const oid_id_st s_hmac_oid_names[] = { { "1.2.840.113549.2.7", "sha1" }, { "1.2.840.113549.2.8", "sha224" }, { "1.2.840.113549.2.9", "sha256" }, @@ -22,7 +22,7 @@ { "1.2.840.113549.2.13", "sha512-256" }, }; -static const pbes_properties _pbes2_default_types[] = { +static const pbes_properties s_pbes2_default_types[] = { { pkcs_5_alg2, "sha1", "des", 8, 0 }, { pkcs_5_alg2, "sha1", "rc2", 4, 0 }, { pkcs_5_alg2, "sha1", "3des", 24, 0 }, @@ -36,29 +36,29 @@ const char* oid; } oid_to_pbes; -static const oid_to_pbes _pbes2_list[] = { - { &_pbes2_default_types[0], "1.3.14.3.2.7" }, /* http://www.oid-info.com/get/1.3.14.3.2.7 desCBC */ - { &_pbes2_default_types[1], "1.2.840.113549.3.2" }, /* http://www.oid-info.com/get/1.2.840.113549.3.2 rc2CBC */ - { &_pbes2_default_types[2], "1.2.840.113549.3.7" }, /* http://www.oid-info.com/get/1.2.840.113549.3.7 des-EDE3-CBC */ - { &_pbes2_default_types[3], "2.16.840.1.101.3.4.1.2" }, /* http://www.oid-info.com/get/2.16.840.1.101.3.4.1.2 aes128-CBC */ - { &_pbes2_default_types[4], "2.16.840.1.101.3.4.1.22" }, /* http://www.oid-info.com/get/2.16.840.1.101.3.4.1.22 aes192-CBC */ - { &_pbes2_default_types[5], "2.16.840.1.101.3.4.1.42" }, /* http://www.oid-info.com/get/2.16.840.1.101.3.4.1.42 aes256-CBC */ +static const oid_to_pbes s_pbes2_list[] = { + { &s_pbes2_default_types[0], "1.3.14.3.2.7" }, /* http://www.oid-info.com/get/1.3.14.3.2.7 desCBC */ + { &s_pbes2_default_types[1], "1.2.840.113549.3.2" }, /* http://www.oid-info.com/get/1.2.840.113549.3.2 rc2CBC */ + { &s_pbes2_default_types[2], "1.2.840.113549.3.7" }, /* http://www.oid-info.com/get/1.2.840.113549.3.7 des-EDE3-CBC */ + { &s_pbes2_default_types[3], "2.16.840.1.101.3.4.1.2" }, /* http://www.oid-info.com/get/2.16.840.1.101.3.4.1.2 aes128-CBC */ + { &s_pbes2_default_types[4], "2.16.840.1.101.3.4.1.22" }, /* http://www.oid-info.com/get/2.16.840.1.101.3.4.1.22 aes192-CBC */ + { &s_pbes2_default_types[5], "2.16.840.1.101.3.4.1.42" }, /* http://www.oid-info.com/get/2.16.840.1.101.3.4.1.42 aes256-CBC */ }; -static int _pbes2_from_oid(const ltc_asn1_list *cipher_oid, const ltc_asn1_list *hmac_oid, pbes_properties *res) +static int s_pbes2_from_oid(const ltc_asn1_list *cipher_oid, const ltc_asn1_list *hmac_oid, pbes_properties *res) { unsigned int i; - for (i = 0; i < sizeof(_pbes2_list)/sizeof(_pbes2_list[0]); ++i) { - if (pk_oid_cmp_with_asn1(_pbes2_list[i].oid, cipher_oid) == CRYPT_OK) { - *res = *_pbes2_list[i].data; + for (i = 0; i < sizeof(s_pbes2_list)/sizeof(s_pbes2_list[0]); ++i) { + if (pk_oid_cmp_with_asn1(s_pbes2_list[i].oid, cipher_oid) == CRYPT_OK) { + *res = *s_pbes2_list[i].data; break; } } if (res->c == NULL) return CRYPT_INVALID_CIPHER; if (hmac_oid != NULL) { - for (i = 0; i < sizeof(_hmac_oid_names)/sizeof(_hmac_oid_names[0]); ++i) { - if (pk_oid_cmp_with_asn1(_hmac_oid_names[i].oid, hmac_oid) == CRYPT_OK) { - res->h = _hmac_oid_names[i].id; + for (i = 0; i < sizeof(s_hmac_oid_names)/sizeof(s_hmac_oid_names[0]); ++i) { + if (pk_oid_cmp_with_asn1(s_hmac_oid_names[i].oid, hmac_oid) == CRYPT_OK) { + res->h = s_hmac_oid_names[i].id; return CRYPT_OK; } } @@ -84,7 +84,7 @@ LTC_ARGCHK(s != NULL); LTC_ARGCHK(res != NULL); - if ((err = pk_oid_cmp_with_asn1(_oid_pbes2, s)) != CRYPT_OK) return err; + if ((err = pk_oid_cmp_with_asn1(s_oid_pbes2, s)) != CRYPT_OK) return err; if (!LTC_ASN1_IS_TYPE(s->next, LTC_ASN1_SEQUENCE) || !LTC_ASN1_IS_TYPE(s->next->child, LTC_ASN1_SEQUENCE) || @@ -115,7 +115,7 @@ lkdf = s->next->child->child; lenc = s->next->child->next->child; - if ((err = pk_oid_cmp_with_asn1(_oid_pbkdf2, lkdf)) != CRYPT_OK) return err; + if ((err = pk_oid_cmp_with_asn1(s_oid_pbkdf2, lkdf)) != CRYPT_OK) return err; if (!LTC_ASN1_IS_TYPE(lkdf->next, LTC_ASN1_SEQUENCE) || !LTC_ASN1_IS_TYPE(lkdf->next->child, LTC_ASN1_OCTET_STRING) || @@ -140,7 +140,7 @@ LTC_ASN1_IS_TYPE(loptseq->child, LTC_ASN1_OBJECT_IDENTIFIER)) { lhmac = loptseq->child; } - if ((err = _pbes2_from_oid(lenc, lhmac, &res->type)) != CRYPT_OK) return err; + if ((err = s_pbes2_from_oid(lenc, lhmac, &res->type)) != CRYPT_OK) return err; if (LTC_ASN1_IS_TYPE(lenc->next, LTC_ASN1_OCTET_STRING)) { /* 'NON-RC2'-CBC */ diff --git a/src/ltc/misc/pkcs5/pkcs_5_1.c b/src/ltc/misc/pkcs5/pkcs_5_1.c index c143af6..ea9c19c 100644 --- a/src/ltc/misc/pkcs5/pkcs_5_1.c +++ b/src/ltc/misc/pkcs5/pkcs_5_1.c @@ -29,7 +29,7 @@ @param openssl_compat [in] Whether or not to grow the key to the buffer size ala OpenSSL @return CRYPT_OK if successful */ -static int _pkcs_5_alg1_common(const unsigned char *password, +static int s_pkcs_5_alg1_common(const unsigned char *password, unsigned long password_len, const unsigned char *salt, int iteration_count, int hash_idx, @@ -49,6 +49,10 @@ LTC_ARGCHK(salt != NULL); LTC_ARGCHK(out != NULL); LTC_ARGCHK(outlen != NULL); + + if (iteration_count <= 0) { + return CRYPT_INVALID_ARG; + } /* test hash IDX */ if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { @@ -150,7 +154,7 @@ int iteration_count, int hash_idx, unsigned char *out, unsigned long *outlen) { - return _pkcs_5_alg1_common(password, password_len, salt, iteration_count, + return s_pkcs_5_alg1_common(password, password_len, salt, iteration_count, hash_idx, out, outlen, 0); } @@ -174,7 +178,7 @@ int iteration_count, int hash_idx, unsigned char *out, unsigned long *outlen) { - return _pkcs_5_alg1_common(password, password_len, salt, iteration_count, + return s_pkcs_5_alg1_common(password, password_len, salt, iteration_count, hash_idx, out, outlen, 1); } diff --git a/src/ltc/misc/pkcs5/pkcs_5_2.c b/src/ltc/misc/pkcs5/pkcs_5_2.c index 093e32e..61ebd00 100644 --- a/src/ltc/misc/pkcs5/pkcs_5_2.c +++ b/src/ltc/misc/pkcs5/pkcs_5_2.c @@ -35,6 +35,10 @@ LTC_ARGCHK(salt != NULL); LTC_ARGCHK(out != NULL); LTC_ARGCHK(outlen != NULL); + + if (iteration_count <= 0) { + return CRYPT_INVALID_ARG; + } /* test hash IDX */ if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { diff --git a/src/ltc/modes/ctr/ctr_encrypt.c b/src/ltc/modes/ctr/ctr_encrypt.c index b59194e..b8c08f7 100644 --- a/src/ltc/modes/ctr/ctr_encrypt.c +++ b/src/ltc/modes/ctr/ctr_encrypt.c @@ -18,7 +18,7 @@ @param ctr CTR state @return CRYPT_OK if successful */ -static int _ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr) +static int s_ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr) { int x, err; @@ -105,7 +105,7 @@ if ((cipher_descriptor[ctr->cipher].accel_ctr_encrypt != NULL) && (len >= (unsigned long)ctr->blocklen)) { if (ctr->padlen < ctr->blocklen) { fr = ctr->blocklen - ctr->padlen; - if ((err = _ctr_encrypt(pt, ct, fr, ctr)) != CRYPT_OK) { + if ((err = s_ctr_encrypt(pt, ct, fr, ctr)) != CRYPT_OK) { return err; } pt += fr; @@ -123,7 +123,7 @@ } } - return _ctr_encrypt(pt, ct, len, ctr); + return s_ctr_encrypt(pt, ct, len, ctr); } #endif diff --git a/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c b/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c index 9b6f5eb..7d2f296 100644 --- a/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c +++ b/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c @@ -10,7 +10,7 @@ #ifdef LTC_DER -static int _char_to_int(unsigned char x) +static int s_char_to_int(unsigned char x) { switch (x) { case '0': return 0; @@ -28,13 +28,13 @@ } #define DECODE_V(y, max) do {\ - y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \ + y = s_char_to_int(buf[x])*10 + s_char_to_int(buf[x+1]); \ if (y >= max) return CRYPT_INVALID_PACKET; \ x += 2; \ } while(0) #define DECODE_V4(y, max) do {\ - y = _char_to_int(buf[x])*1000 + _char_to_int(buf[x+1])*100 + _char_to_int(buf[x+2])*10 + _char_to_int(buf[x+3]); \ + y = s_char_to_int(buf[x])*1000 + s_char_to_int(buf[x+1])*100 + s_char_to_int(buf[x+2])*10 + s_char_to_int(buf[x+3]); \ if (y >= max) return CRYPT_INVALID_PACKET; \ x += 4; \ } while(0) @@ -113,7 +113,7 @@ unsigned fs = out->fs; if (x >= sizeof(buf)) return CRYPT_INVALID_PACKET; out->fs *= 10; - out->fs += _char_to_int(buf[x]); + out->fs += s_char_to_int(buf[x]); if (fs > out->fs) return CRYPT_OVERFLOW; x++; } diff --git a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c index 2e6f8a4..2a0841d 100644 --- a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c +++ b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c @@ -9,7 +9,7 @@ #ifdef LTC_DER -static int _new_element(ltc_asn1_list **l) +static int s_new_element(ltc_asn1_list **l) { /* alloc new link */ if (*l == NULL) { @@ -36,7 +36,7 @@ @param depth The depth/level of decoding recursion we've already reached @return CRYPT_OK on success. */ -static int _der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out, unsigned long depth) +static int s_der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out, unsigned long depth) { ltc_asn1_list *l; unsigned long err, identifier, len, totlen, data_offset, id_len, len_len; @@ -51,7 +51,7 @@ if (*inlen == 0) { /* alloc new link */ - if ((err = _new_element(&l)) != CRYPT_OK) { + if ((err = s_new_element(&l)) != CRYPT_OK) { goto error; } } @@ -59,7 +59,7 @@ /* scan the input and and get lengths and what not */ while (*inlen) { /* alloc new link */ - if ((err = _new_element(&l)) != CRYPT_OK) { + if ((err = s_new_element(&l)) != CRYPT_OK) { goto error; } @@ -447,7 +447,7 @@ len_len = len; /* Sequence elements go as child */ - if ((err = _der_decode_sequence_flexi(in, &len, &(l->child), depth+1)) != CRYPT_OK) { + if ((err = s_der_decode_sequence_flexi(in, &len, &(l->child), depth+1)) != CRYPT_OK) { goto error; } if (len_len != len) { @@ -534,7 +534,7 @@ */ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out) { - return _der_decode_sequence_flexi(in, inlen, out, 0); + return s_der_decode_sequence_flexi(in, inlen, out, 0); } #endif diff --git a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c index f3e5b29..8807e91 100644 --- a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c +++ b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c @@ -20,7 +20,7 @@ @param flags c.f. enum ltc_der_seq @return CRYPT_OK on success */ -static int _der_decode_sequence_va(const unsigned char *in, unsigned long inlen, va_list a1, va_list a2, unsigned int flags) +static int s_der_decode_sequence_va(const unsigned char *in, unsigned long inlen, va_list a1, va_list a2, unsigned int flags) { int err; ltc_asn1_type type; @@ -142,7 +142,7 @@ va_start(a1, inlen); va_start(a2, inlen); - err = _der_decode_sequence_va(in, inlen, a1, a2, LTC_DER_SEQ_SEQUENCE | LTC_DER_SEQ_RELAXED); + err = s_der_decode_sequence_va(in, inlen, a1, a2, LTC_DER_SEQ_SEQUENCE | LTC_DER_SEQ_RELAXED); va_end(a2); va_end(a1); @@ -168,7 +168,7 @@ va_start(a1, flags); va_start(a2, flags); - err = _der_decode_sequence_va(in, inlen, a1, a2, flags); + err = s_der_decode_sequence_va(in, inlen, a1, a2, flags); va_end(a2); va_end(a1); diff --git a/src/ltc/pk/asn1/der/set/der_encode_set.c b/src/ltc/pk/asn1/der/set/der_encode_set.c index 27cfd59..1e90a1f 100644 --- a/src/ltc/pk/asn1/der/set/der_encode_set.c +++ b/src/ltc/pk/asn1/der/set/der_encode_set.c @@ -10,18 +10,18 @@ #ifdef LTC_DER /* LTC define to ASN.1 TAG */ -static int _ltc_to_asn1(ltc_asn1_type v) +static int s_ltc_to_asn1(ltc_asn1_type v) { return der_asn1_type_to_identifier_map[v]; } -static int _qsort_helper(const void *a, const void *b) +static int s_qsort_helper(const void *a, const void *b) { ltc_asn1_list *A = (ltc_asn1_list *)a, *B = (ltc_asn1_list *)b; int r; - r = _ltc_to_asn1(A->type) - _ltc_to_asn1(B->type); + r = s_ltc_to_asn1(A->type) - s_ltc_to_asn1(B->type); /* for QSORT the order is UNDEFINED if they are "equal" which means it is NOT DETERMINISTIC. So we force it to be :-) */ if (r == 0) { @@ -59,7 +59,7 @@ } /* sort it by the "type" field */ - XQSORT(copy, inlen, sizeof(*copy), &_qsort_helper); + XQSORT(copy, inlen, sizeof(*copy), &s_qsort_helper); /* call der_encode_sequence_ex() */ err = der_encode_sequence_ex(copy, inlen, out, outlen, LTC_ASN1_SET); diff --git a/src/ltc/pk/asn1/der/set/der_encode_setof.c b/src/ltc/pk/asn1/der/set/der_encode_setof.c index c4ca64d..184b6ec 100644 --- a/src/ltc/pk/asn1/der/set/der_encode_setof.c +++ b/src/ltc/pk/asn1/der/set/der_encode_setof.c @@ -14,7 +14,7 @@ unsigned long size; }; -static int _qsort_helper(const void *a, const void *b) +static int s_qsort_helper(const void *a, const void *b) { struct edge *A = (struct edge *)a, *B = (struct edge *)b; int r; @@ -126,7 +126,7 @@ } /* sort based on contents (using edges) */ - XQSORT(edges, inlen, sizeof(*edges), &_qsort_helper); + XQSORT(edges, inlen, sizeof(*edges), &s_qsort_helper); /* copy static header */ XMEMCPY(out, buf, hdrlen); diff --git a/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c b/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c index 294417a..6149bfe 100644 --- a/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c +++ b/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c @@ -9,7 +9,7 @@ #ifdef LTC_DER -static int _char_to_int(unsigned char x) +static int s_char_to_int(unsigned char x) { switch (x) { case '0': return 0; @@ -27,7 +27,7 @@ } #define DECODE_V(y, max) \ - y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \ + y = s_char_to_int(buf[x])*10 + s_char_to_int(buf[x+1]); \ if (y >= max) return CRYPT_INVALID_PACKET; \ x += 2; diff --git a/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c b/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c index 2e40645..93a5e5e 100644 --- a/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c +++ b/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c @@ -11,11 +11,11 @@ #ifdef LTC_DER /** - Store a UTF8 STRING + Decode a UTF8 STRING and recover an array of unicode characters. @param in The DER encoded UTF8 STRING @param inlen The size of the DER UTF8 STRING - @param out [out] The array of utf8s stored (one per char) - @param outlen [in/out] The number of utf8s stored + @param out [out] The array of unicode characters (wchar_t*) + @param outlen [in/out] The number of unicode characters in the array @return CRYPT_OK if successful */ int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, @@ -51,23 +51,47 @@ return CRYPT_INVALID_PACKET; } - /* proceed to decode */ + /* proceed to recover unicode characters from utf8 data. + for reference see Section 3 of RFC 3629: + + https://tools.ietf.org/html/rfc3629#section-3 + */ for (y = 0; x < inlen; ) { - /* get first byte */ + /* read first byte */ tmp = in[x++]; - /* count number of bytes */ + /* a unicode character is recovered from a sequence of 1 to 4 utf8 bytes. + the form of those bytes must match a row in the following table: + + 0xxxxxxx + 110xxxxx 10xxxxxx + 1110xxxx 10xxxxxx 10xxxxxx + 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + + the number of leading ones in the first byte (0,2,3,4) determines the + number of remaining bytes to read (0,1,2,3) + */ + + /* determine z, the number of leading ones. + this is done by left-shifting tmp, which clears the ms-bits */ for (z = 0; (tmp & 0x80) && (z <= 4); z++, tmp = (tmp << 1) & 0xFF); - if (z == 1 || z > 4 || (x + (z - 1) > inlen)) { + /* z should be in {0,2,3,4} */ + if (z == 1 || z > 4) { return CRYPT_INVALID_PACKET; } - /* decode, grab upper bits */ + /* right-shift tmp to restore least-sig bits */ tmp >>= z; - /* grab remaining bytes */ - if (z > 1) { --z; } + /* now update z so it equals the number of additional bytes to read */ + if (z > 0) { --z; } + + if (x + z > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* read remaining bytes */ while (z-- != 0) { if ((in[x] & 0xC0) != 0x80) { return CRYPT_INVALID_PACKET; diff --git a/src/ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.c b/src/ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.c index 0c3c4fa..2382226 100644 --- a/src/ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.c +++ b/src/ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.c @@ -39,8 +39,9 @@ unsigned long tmpbuf_len, tmp_inlen; ltc_asn1_list *decoded_list = NULL, *l; - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(inlen != 0); + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(inlen != 0); + LTC_ARGCHK(callback != NULL); tmpbuf_len = inlen; tmpbuf = XCALLOC(1, tmpbuf_len); @@ -81,7 +82,7 @@ && (l->data != NULL) && LOOKS_LIKE_SPKI(l->child)) { if (algorithm == PKA_EC) { - err = ecc_import_subject_public_key_info(l->data, l->size, ctx); + err = callback(l->data, l->size, ctx); } else { err = x509_decode_subject_public_key_info(l->data, l->size, algorithm, tmpbuf, &tmpbuf_len, diff --git a/src/ltc/pk/dh/dh_generate_key.c b/src/ltc/pk/dh/dh_generate_key.c index c24f376..39ef8e1 100644 --- a/src/ltc/pk/dh/dh_generate_key.c +++ b/src/ltc/pk/dh/dh_generate_key.c @@ -5,7 +5,7 @@ #ifdef LTC_MDH -static int _dh_groupsize_to_keysize(int groupsize) +static int s_dh_groupsize_to_keysize(int groupsize) { /* The strength estimates from https://tools.ietf.org/html/rfc3526#section-8 * We use "Estimate 2" to get an appropriate private key (exponent) size. @@ -48,7 +48,7 @@ return err; } - keysize = _dh_groupsize_to_keysize(mp_unsigned_bin_size(key->prime)); + keysize = s_dh_groupsize_to_keysize(mp_unsigned_bin_size(key->prime)); if (keysize == 0) { err = CRYPT_INVALID_KEYSIZE; goto freemp; diff --git a/src/ltc/pk/dsa/dsa_generate_pqg.c b/src/ltc/pk/dsa/dsa_generate_pqg.c index 1b7359c..af1b202 100644 --- a/src/ltc/pk/dsa/dsa_generate_pqg.c +++ b/src/ltc/pk/dsa/dsa_generate_pqg.c @@ -20,7 +20,7 @@ @param g [out] bignum where generated 'g' is stored (must be initialized by caller) @return CRYPT_OK if successful, upon error this function will free all allocated memory */ -static int _dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g) +static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g) { unsigned long L, N, n, outbytes, seedbytes, counter, j, i; int err, res, mr_tests_q, mr_tests_p, found_p, found_q, hash; @@ -217,7 +217,7 @@ return err; } /* generate params */ - err = _dsa_make_params(prng, wprng, group_size, modulus_size, key->p, key->q, key->g); + err = s_dsa_make_params(prng, wprng, group_size, modulus_size, key->p, key->q, key->g); if (err != CRYPT_OK) { goto cleanup; } diff --git a/src/ltc/pk/ec25519/tweetnacl.c b/src/ltc/pk/ec25519/tweetnacl.c index 82f0a70..fc5aad7 100644 --- a/src/ltc/pk/ec25519/tweetnacl.c +++ b/src/ltc/pk/ec25519/tweetnacl.c @@ -14,11 +14,11 @@ typedef i64 gf[16]; static const u8 - _9[32] = {9}; + nine[32] = {9}; static const gf gf0, gf1 = {1}, - _121665 = {0xDB41,1}, + gf121665 = {0xDB41,1}, D = {0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203}, D2 = {0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406}, X = {0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169}, @@ -195,7 +195,7 @@ Z(a,a,c); S(b,a); Z(c,d,f); - M(a,c,_121665); + M(a,c,gf121665); A(a,a,d); M(c,c,a); M(a,d,f); @@ -218,7 +218,7 @@ int tweetnacl_crypto_scalarmult_base(u8 *q,const u8 *n) { - return tweetnacl_crypto_scalarmult(q,n,_9); + return tweetnacl_crypto_scalarmult(q,n,nine); } static int tweetnacl_crypto_hash(u8 *out,const u8 *m,u64 n) diff --git a/src/ltc/pk/ecc/ecc_find_curve.c b/src/ltc/pk/ecc/ecc_find_curve.c index d3dba91..0279c7a 100644 --- a/src/ltc/pk/ecc/ecc_find_curve.c +++ b/src/ltc/pk/ecc/ecc_find_curve.c @@ -8,7 +8,7 @@ static const struct { const char *OID; const char *names[6]; -} _curve_names[] = { +} s_curve_names[] = { #ifdef LTC_ECC_SECP112R1 { "1.3.132.0.6", { "SECP112R1", "ECC-112", NULL } @@ -185,7 +185,7 @@ }; /* case-insensitive match + ignore '-', '_', ' ' */ -static int _name_match(const char *left, const char *right) +static int s_name_match(const char *left, const char *right) { char lc_r, lc_l; @@ -216,13 +216,13 @@ *cu = NULL; - for (i = 0; _curve_names[i].OID != NULL && !OID; i++) { - if (XSTRCMP(_curve_names[i].OID, name_or_oid) == 0) { - OID = _curve_names[i].OID; + for (i = 0; s_curve_names[i].OID != NULL && !OID; i++) { + if (XSTRCMP(s_curve_names[i].OID, name_or_oid) == 0) { + OID = s_curve_names[i].OID; } - for (j = 0; _curve_names[i].names[j] != NULL && !OID; j++) { - if (_name_match(_curve_names[i].names[j], name_or_oid)) { - OID = _curve_names[i].OID; + for (j = 0; s_curve_names[i].names[j] != NULL && !OID; j++) { + if (s_name_match(s_curve_names[i].names[j], name_or_oid)) { + OID = s_curve_names[i].OID; } } } diff --git a/src/ltc/pk/ecc/ecc_import_openssl.c b/src/ltc/pk/ecc/ecc_import_openssl.c index 4d8cfa3..e3a6f61 100644 --- a/src/ltc/pk/ecc/ecc_import_openssl.c +++ b/src/ltc/pk/ecc/ecc_import_openssl.c @@ -5,7 +5,7 @@ #ifdef LTC_MECC -static int _ecc_import_private_with_oid(const unsigned char *in, unsigned long inlen, ecc_key *key) +static int s_ecc_import_private_with_oid(const unsigned char *in, unsigned long inlen, ecc_key *key) { ltc_asn1_list seq_priv[4], custom[2]; unsigned char bin_xy[2*ECC_MAXSIZE+2], bin_k[ECC_MAXSIZE]; @@ -39,7 +39,7 @@ return err; } -static int _ecc_import_private_with_curve(const unsigned char *in, unsigned long inlen, ecc_key *key) +static int s_ecc_import_private_with_curve(const unsigned char *in, unsigned long inlen, ecc_key *key) { void *prime, *order, *a, *b, *gx, *gy; ltc_asn1_list seq_fieldid[2], seq_curve[3], seq_ecparams[6], seq_priv[4], custom[2]; @@ -107,11 +107,11 @@ goto success; } - if ((err = _ecc_import_private_with_oid(in, inlen, key)) == CRYPT_OK) { + if ((err = s_ecc_import_private_with_oid(in, inlen, key)) == CRYPT_OK) { goto success; } - err = _ecc_import_private_with_curve(in, inlen, key); + err = s_ecc_import_private_with_curve(in, inlen, key); success: return err; diff --git a/src/ltc/pk/ecc/ecc_import_pkcs8.c b/src/ltc/pk/ecc/ecc_import_pkcs8.c index 7093fc4..0461db0 100644 --- a/src/ltc/pk/ecc/ecc_import_pkcs8.c +++ b/src/ltc/pk/ecc/ecc_import_pkcs8.c @@ -17,7 +17,7 @@ list[LTC_SDFC_temp##__LINE__].pp = P; \ } while (0) -static int _der_flexi_sequence_cmp(const ltc_asn1_list *flexi, der_flexi_check *check) +static int s_der_flexi_sequence_cmp(const ltc_asn1_list *flexi, der_flexi_check *check) { const ltc_asn1_list *cur; if (flexi->type != LTC_ASN1_SEQUENCE) { @@ -35,7 +35,7 @@ return CRYPT_OK; } -/* NOTE: _der_decode_pkcs8_flexi & related stuff can be shared with rsa_import_pkcs8() */ +/* NOTE: s_der_decode_pkcs8_flexi & related stuff can be shared with rsa_import_pkcs8() */ int ecc_import_pkcs8(const unsigned char *in, unsigned long inlen, const void *pwd, unsigned long pwdlen, @@ -73,7 +73,7 @@ LTC_SET_DER_FLEXI_CHECK(flexi_should, n++, LTC_ASN1_OCTET_STRING, &priv_key); LTC_SET_DER_FLEXI_CHECK(flexi_should, n, LTC_ASN1_EOL, NULL); - if (((err = _der_flexi_sequence_cmp(l, flexi_should)) == CRYPT_OK) && + if (((err = s_der_flexi_sequence_cmp(l, flexi_should)) == CRYPT_OK) && (pk_oid_cmp_with_asn1(pka_ec_oid, seq->child) == CRYPT_OK)) { ltc_asn1_list *version, *field, *point, *point_g, *order, *p_cofactor; @@ -102,7 +102,7 @@ if ((err = ecc_find_curve(OID, &curve)) != CRYPT_OK) { goto LBL_DONE; } if ((err = ecc_set_curve(curve, key)) != CRYPT_OK) { goto LBL_DONE; } } - else if ((err = _der_flexi_sequence_cmp(seq->child->next, flexi_should)) == CRYPT_OK) { + else if ((err = s_der_flexi_sequence_cmp(seq->child->next, flexi_should)) == CRYPT_OK) { /* CASE 2: explicit curve parameters (AKA long variant): * 0:d=0 hl=3 l= 227 cons: SEQUENCE * 3:d=1 hl=2 l= 1 prim: INTEGER :00 diff --git a/src/ltc/pk/ecc/ecc_import_x509.c b/src/ltc/pk/ecc/ecc_import_x509.c index 699ad4b..7d64c63 100644 --- a/src/ltc/pk/ecc/ecc_import_x509.c +++ b/src/ltc/pk/ecc/ecc_import_x509.c @@ -4,7 +4,7 @@ #ifdef LTC_MECC -static int _ecc_import_x509_with_oid(const unsigned char *in, unsigned long inlen, ecc_key *key) +static int s_ecc_import_x509_with_oid(const unsigned char *in, unsigned long inlen, ecc_key *key) { unsigned char bin_xy[2*ECC_MAXSIZE+2]; unsigned long curveoid[16]; @@ -30,7 +30,7 @@ return err; } -static int _ecc_import_x509_with_curve(const unsigned char *in, unsigned long inlen, ecc_key *key) +static int s_ecc_import_x509_with_curve(const unsigned char *in, unsigned long inlen, ecc_key *key) { void *prime, *order, *a, *b, *gx, *gy; ltc_asn1_list seq_fieldid[2], seq_curve[3], seq_ecparams[6]; @@ -87,11 +87,11 @@ { int err; - if ((err = _ecc_import_x509_with_oid(in, inlen, key)) == CRYPT_OK) { + if ((err = s_ecc_import_x509_with_oid(in, inlen, key)) == CRYPT_OK) { goto success; } - err = _ecc_import_x509_with_curve(in, inlen, key); + err = s_ecc_import_x509_with_curve(in, inlen, key); success: return err; @@ -106,7 +106,10 @@ */ int ecc_import_x509(const unsigned char *in, unsigned long inlen, ecc_key *key) { - return x509_decode_public_key_from_certificate(in, inlen, PKA_EC, LTC_ASN1_EOL, NULL, NULL, NULL, key); + return x509_decode_public_key_from_certificate(in, inlen, + PKA_EC, + LTC_ASN1_EOL, NULL, NULL, + (public_key_decode_cb)ecc_import_subject_public_key_info, key); } #endif /* LTC_MECC */ diff --git a/src/ltc/pk/ecc/ecc_set_curve_internal.c b/src/ltc/pk/ecc/ecc_set_curve_internal.c index 24b8135..4f43914 100644 --- a/src/ltc/pk/ecc/ecc_set_curve_internal.c +++ b/src/ltc/pk/ecc/ecc_set_curve_internal.c @@ -5,14 +5,14 @@ #ifdef LTC_MECC -static int _ecc_cmp_hex_bn(const char *left_hex, void *right_bn, void *tmp_bn) +static int s_ecc_cmp_hex_bn(const char *left_hex, void *right_bn, void *tmp_bn) { if (mp_read_radix(tmp_bn, left_hex, 16) != CRYPT_OK) return 0; if (mp_cmp(tmp_bn, right_bn) != LTC_MP_EQ) return 0; return 1; } -static void _ecc_oid_lookup(ecc_key *key) +static void s_ecc_oid_lookup(ecc_key *key) { void *bn; const ltc_ecc_curve *curve; @@ -20,12 +20,12 @@ key->dp.oidlen = 0; if (mp_init(&bn) != CRYPT_OK) return; for (curve = ltc_ecc_curves; curve->prime != NULL; curve++) { - if (_ecc_cmp_hex_bn(curve->prime, key->dp.prime, bn) != 1) continue; - if (_ecc_cmp_hex_bn(curve->order, key->dp.order, bn) != 1) continue; - if (_ecc_cmp_hex_bn(curve->A, key->dp.A, bn) != 1) continue; - if (_ecc_cmp_hex_bn(curve->B, key->dp.B, bn) != 1) continue; - if (_ecc_cmp_hex_bn(curve->Gx, key->dp.base.x, bn) != 1) continue; - if (_ecc_cmp_hex_bn(curve->Gy, key->dp.base.y, bn) != 1) continue; + if (s_ecc_cmp_hex_bn(curve->prime, key->dp.prime, bn) != 1) continue; + if (s_ecc_cmp_hex_bn(curve->order, key->dp.order, bn) != 1) continue; + if (s_ecc_cmp_hex_bn(curve->A, key->dp.A, bn) != 1) continue; + if (s_ecc_cmp_hex_bn(curve->B, key->dp.B, bn) != 1) continue; + if (s_ecc_cmp_hex_bn(curve->Gx, key->dp.base.x, bn) != 1) continue; + if (s_ecc_cmp_hex_bn(curve->Gy, key->dp.base.y, bn) != 1) continue; if (key->dp.cofactor != curve->cofactor) continue; break; /* found */ } @@ -66,7 +66,7 @@ for (i = 0; i < key->dp.oidlen; i++) key->dp.oid[i] = srckey->dp.oid[i]; } else { - _ecc_oid_lookup(key); /* try to find OID in ltc_ecc_curves */ + s_ecc_oid_lookup(key); /* try to find OID in ltc_ecc_curves */ } /* success */ return CRYPT_OK; @@ -107,7 +107,7 @@ key->dp.cofactor = cofactor; key->dp.size = mp_unsigned_bin_size(prime); /* try to find OID in ltc_ecc_curves */ - _ecc_oid_lookup(key); + s_ecc_oid_lookup(key); /* success */ return CRYPT_OK; diff --git a/src/ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.c b/src/ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.c index fef49e3..09c8d64 100644 --- a/src/ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.c +++ b/src/ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.c @@ -7,6 +7,8 @@ Curve/OID to SSH+ECDSA name string mapping per RFC5656 Russ Williams */ + +#ifdef LTC_SSH /** Curve/OID to SSH+ECDSA name string mapping @@ -60,3 +62,4 @@ return err; } +#endif diff --git a/src/ltc/pk/ed25519/ed25519_import_x509.c b/src/ltc/pk/ed25519/ed25519_import_x509.c index 9654b04..451c470 100644 --- a/src/ltc/pk/ed25519/ed25519_import_x509.c +++ b/src/ltc/pk/ed25519/ed25519_import_x509.c @@ -9,7 +9,7 @@ #ifdef LTC_CURVE25519 -static int _ed25519_decode(const unsigned char *in, unsigned long inlen, curve25519_key *key) +static int s_ed25519_decode(const unsigned char *in, unsigned long inlen, curve25519_key *key) { if (inlen != sizeof(key->pub)) return CRYPT_PK_INVALID_SIZE; XMEMCPY(key->pub, in, sizeof(key->pub)); @@ -33,7 +33,7 @@ if ((err = x509_decode_public_key_from_certificate(in, inlen, PKA_ED25519, LTC_ASN1_EOL, NULL, NULL, - (public_key_decode_cb)_ed25519_decode, key)) != CRYPT_OK) { + (public_key_decode_cb)s_ed25519_decode, key)) != CRYPT_OK) { return err; } key->type = PK_PUBLIC; diff --git a/src/ltc/pk/rsa/rsa_import_x509.c b/src/ltc/pk/rsa/rsa_import_x509.c index 265e1a5..a66a267 100644 --- a/src/ltc/pk/rsa/rsa_import_x509.c +++ b/src/ltc/pk/rsa/rsa_import_x509.c @@ -9,7 +9,7 @@ #ifdef LTC_MRSA -static int _rsa_decode(const unsigned char *in, unsigned long inlen, rsa_key *key) +static int s_rsa_decode(const unsigned char *in, unsigned long inlen, rsa_key *key) { /* now it should be SEQUENCE { INTEGER, INTEGER } */ return der_decode_sequence_multi(in, inlen, @@ -41,7 +41,7 @@ if ((err = x509_decode_public_key_from_certificate(in, inlen, PKA_RSA, LTC_ASN1_NULL, NULL, NULL, - (public_key_decode_cb)_rsa_decode, key)) != CRYPT_OK) { + (public_key_decode_cb)s_rsa_decode, key)) != CRYPT_OK) { rsa_free(key); } else { key->type = PK_PUBLIC; diff --git a/src/ltc/pk/rsa/rsa_key.c b/src/ltc/pk/rsa/rsa_key.c index e7a50b7..48a1d8f 100644 --- a/src/ltc/pk/rsa/rsa_key.c +++ b/src/ltc/pk/rsa/rsa_key.c @@ -11,7 +11,7 @@ #ifdef LTC_MRSA #include -static void _mpi_shrink_multi(void **a, ...) +static void s_mpi_shrink_multi(void **a, ...) { void **cur; unsigned n; @@ -76,7 +76,7 @@ void rsa_shrink_key(rsa_key *key) { LTC_ARGCHKVD(key != NULL); - _mpi_shrink_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, NULL); + s_mpi_shrink_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, NULL); } /** diff --git a/src/ltc/pk/x25519/x25519_import_x509.c b/src/ltc/pk/x25519/x25519_import_x509.c index 4694352..18e0b67 100644 --- a/src/ltc/pk/x25519/x25519_import_x509.c +++ b/src/ltc/pk/x25519/x25519_import_x509.c @@ -9,7 +9,7 @@ #ifdef LTC_CURVE25519 -static int _x25519_decode(const unsigned char *in, unsigned long inlen, curve25519_key *key) +static int s_x25519_decode(const unsigned char *in, unsigned long inlen, curve25519_key *key) { if (inlen != sizeof(key->pub)) return CRYPT_PK_INVALID_SIZE; XMEMCPY(key->pub, in, sizeof(key->pub)); @@ -33,7 +33,7 @@ if ((err = x509_decode_public_key_from_certificate(in, inlen, PKA_X25519, LTC_ASN1_EOL, NULL, NULL, - (public_key_decode_cb)_x25519_decode, key)) != CRYPT_OK) { + (public_key_decode_cb)s_x25519_decode, key)) != CRYPT_OK) { return err; } key->type = PK_PUBLIC; diff --git a/src/ltc/prngs/chacha20.c b/src/ltc/prngs/chacha20.c index 862c952..d9bd7b0 100644 --- a/src/ltc/prngs/chacha20.c +++ b/src/ltc/prngs/chacha20.c @@ -144,7 +144,7 @@ @param prng The PRNG to export @return CRYPT_OK if successful */ -_LTC_PRNG_EXPORT(chacha20_prng) +LTC_PRNG_EXPORT(chacha20_prng) /** Import a PRNG state diff --git a/src/ltc/prngs/fortuna.c b/src/ltc/prngs/fortuna.c index daaee17..6f50098 100644 --- a/src/ltc/prngs/fortuna.c +++ b/src/ltc/prngs/fortuna.c @@ -53,7 +53,7 @@ }; /* update the IV */ -static void _fortuna_update_iv(prng_state *prng) +static void s_fortuna_update_iv(prng_state *prng) { int x; unsigned char *IV; @@ -67,7 +67,7 @@ #ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED /* get the current time in 100ms steps */ -static ulong64 _fortuna_current_time(void) +static ulong64 s_fortuna_current_time(void) { ulong64 cur_time; #if defined(_WIN32) @@ -93,7 +93,7 @@ #endif /* reseed the PRNG */ -static int _fortuna_reseed(prng_state *prng) +static int s_fortuna_reseed(prng_state *prng) { unsigned char tmp[MAXBLOCKSIZE]; hash_state md; @@ -101,7 +101,7 @@ int err, x; #ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED - ulong64 now = _fortuna_current_time(); + ulong64 now = s_fortuna_current_time(); if (now == prng->u.fortuna.wd) { return CRYPT_OK; } @@ -149,7 +149,7 @@ if ((err = rijndael_setup(prng->u.fortuna.K, 32, 0, &prng->u.fortuna.skey)) != CRYPT_OK) { return err; } - _fortuna_update_iv(prng); + s_fortuna_update_iv(prng); /* reset/update internals */ prng->u.fortuna.pool0_len = 0; @@ -198,7 +198,7 @@ if ((err = sha256_done(&md, prng->u.fortuna.K)) != CRYPT_OK) { goto LBL_UNLOCK; } - _fortuna_update_iv(prng); + s_fortuna_update_iv(prng); LBL_UNLOCK: LTC_MUTEX_UNLOCK(&prng->lock); @@ -249,7 +249,7 @@ return CRYPT_OK; } -static int _fortuna_add(unsigned long source, unsigned long pool, const unsigned char *in, unsigned long inlen, prng_state *prng) +static int s_fortuna_add(unsigned long source, unsigned long pool, const unsigned char *in, unsigned long inlen, prng_state *prng) { unsigned char tmp[2]; int err; @@ -296,7 +296,7 @@ LTC_MUTEX_LOCK(&prng->lock); - err = _fortuna_add(source, pool, in, inlen, prng); + err = s_fortuna_add(source, pool, in, inlen, prng); LTC_MUTEX_UNLOCK(&prng->lock); @@ -320,7 +320,7 @@ LTC_MUTEX_LOCK(&prng->lock); - err = _fortuna_add(0, prng->u.fortuna.pool_idx, in, inlen, prng); + err = s_fortuna_add(0, prng->u.fortuna.pool_idx, in, inlen, prng); if (err == CRYPT_OK) { ++(prng->u.fortuna.pool_idx); @@ -346,11 +346,11 @@ /* make sure the reseed doesn't fail because * of the chosen rate limit */ #ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED - prng->u.fortuna.wd = _fortuna_current_time() - 1; + prng->u.fortuna.wd = s_fortuna_current_time() - 1; #else prng->u.fortuna.wd = LTC_FORTUNA_WD; #endif - err = _fortuna_reseed(prng); + err = s_fortuna_reseed(prng); prng->ready = (err == CRYPT_OK) ? 1 : 0; LTC_MUTEX_UNLOCK(&prng->lock); @@ -379,7 +379,7 @@ /* do we have to reseed? */ if (prng->u.fortuna.pool0_len >= 64) { - if (_fortuna_reseed(prng) != CRYPT_OK) { + if (s_fortuna_reseed(prng) != CRYPT_OK) { goto LBL_UNLOCK; } } @@ -398,22 +398,22 @@ rijndael_ecb_encrypt(prng->u.fortuna.IV, out, &prng->u.fortuna.skey); out += 16; outlen -= 16; - _fortuna_update_iv(prng); + s_fortuna_update_iv(prng); } /* left over bytes? */ if (outlen > 0) { rijndael_ecb_encrypt(prng->u.fortuna.IV, tmp, &prng->u.fortuna.skey); XMEMCPY(out, tmp, outlen); - _fortuna_update_iv(prng); + s_fortuna_update_iv(prng); } /* generate new key */ rijndael_ecb_encrypt(prng->u.fortuna.IV, prng->u.fortuna.K , &prng->u.fortuna.skey); - _fortuna_update_iv(prng); + s_fortuna_update_iv(prng); rijndael_ecb_encrypt(prng->u.fortuna.IV, prng->u.fortuna.K+16, &prng->u.fortuna.skey); - _fortuna_update_iv(prng); + s_fortuna_update_iv(prng); if (rijndael_setup(prng->u.fortuna.K, 32, 0, &prng->u.fortuna.skey) != CRYPT_OK) { tlen = 0; @@ -467,7 +467,7 @@ @param prng The PRNG to export @return CRYPT_OK if successful */ -_LTC_PRNG_EXPORT(fortuna) +LTC_PRNG_EXPORT(fortuna) /** Import a PRNG state diff --git a/src/ltc/prngs/rc4.c b/src/ltc/prngs/rc4.c index d2b297b..edcd73f 100644 --- a/src/ltc/prngs/rc4.c +++ b/src/ltc/prngs/rc4.c @@ -147,7 +147,7 @@ @param prng The PRNG to export @return CRYPT_OK if successful */ -_LTC_PRNG_EXPORT(rc4) +LTC_PRNG_EXPORT(rc4) /** Import a PRNG state diff --git a/src/ltc/prngs/rng_get_bytes.c b/src/ltc/prngs/rng_get_bytes.c index 8b14215..b07238e 100644 --- a/src/ltc/prngs/rng_get_bytes.c +++ b/src/ltc/prngs/rng_get_bytes.c @@ -10,7 +10,7 @@ #if defined(LTC_DEVRANDOM) && !defined(_WIN32) /* on *NIX read /dev/random */ -static unsigned long _rng_nix(unsigned char *buf, unsigned long len, +static unsigned long s_rng_nix(unsigned char *buf, unsigned long len, void (*callback)(void)) { #ifdef LTC_NO_FILE @@ -53,7 +53,7 @@ #define ANSI_RNG -static unsigned long _rng_ansic(unsigned char *buf, unsigned long len, +static unsigned long s_rng_ansic(unsigned char *buf, unsigned long len, void (*callback)(void)) { clock_t t1; @@ -94,7 +94,7 @@ #include #include -static unsigned long _rng_win32(unsigned char *buf, unsigned long len, +static unsigned long s_rng_win32(unsigned char *buf, unsigned long len, void (*callback)(void)) { HCRYPTPROV hProv = 0; @@ -140,12 +140,12 @@ #endif #if defined(_WIN32) || defined(_WIN32_WCE) - x = _rng_win32(out, outlen, callback); if (x != 0) { return x; } + x = s_rng_win32(out, outlen, callback); if (x != 0) { return x; } #elif defined(LTC_DEVRANDOM) - x = _rng_nix(out, outlen, callback); if (x != 0) { return x; } + x = s_rng_nix(out, outlen, callback); if (x != 0) { return x; } #endif #ifdef ANSI_RNG - x = _rng_ansic(out, outlen, callback); if (x != 0) { return x; } + x = s_rng_ansic(out, outlen, callback); if (x != 0) { return x; } #endif return 0; } diff --git a/src/ltc/prngs/sober128.c b/src/ltc/prngs/sober128.c index e2a074e..6454578 100644 --- a/src/ltc/prngs/sober128.c +++ b/src/ltc/prngs/sober128.c @@ -146,7 +146,7 @@ @param prng The PRNG to export @return CRYPT_OK if successful */ -_LTC_PRNG_EXPORT(sober128) +LTC_PRNG_EXPORT(sober128) /** Import a PRNG state diff --git a/src/ltc/prngs/yarrow.c b/src/ltc/prngs/yarrow.c index d293d61..40cb46a 100644 --- a/src/ltc/prngs/yarrow.c +++ b/src/ltc/prngs/yarrow.c @@ -267,7 +267,7 @@ @param prng The PRNG to export @return CRYPT_OK if successful */ -_LTC_PRNG_EXPORT(yarrow) +LTC_PRNG_EXPORT(yarrow) /** Import a PRNG state diff --git a/src/ltc/stream/chacha/chacha_crypt.c b/src/ltc/stream/chacha/chacha_crypt.c index 719f3d2..2798800 100644 --- a/src/ltc/stream/chacha/chacha_crypt.c +++ b/src/ltc/stream/chacha/chacha_crypt.c @@ -16,7 +16,7 @@ x[a] += x[b]; x[d] = ROL(x[d] ^ x[a], 8); \ x[c] += x[d]; x[b] = ROL(x[b] ^ x[c], 7); -static void _chacha_block(unsigned char *output, const ulong32 *input, int rounds) +static void s_chacha_block(unsigned char *output, const ulong32 *input, int rounds) { ulong32 x[16]; int i; @@ -66,7 +66,7 @@ in += j; } for (;;) { - _chacha_block(buf, st->input, st->rounds); + s_chacha_block(buf, st->input, st->rounds); if (st->ivlen == 8) { /* IV-64bit, increment 64bit counter */ if (0 == ++st->input[12] && 0 == ++st->input[13]) return CRYPT_OVERFLOW; diff --git a/src/ltc/stream/rabbit/rabbit.c b/src/ltc/stream/rabbit/rabbit.c index 202d6d2..075f4c0 100644 --- a/src/ltc/stream/rabbit/rabbit.c +++ b/src/ltc/stream/rabbit/rabbit.c @@ -61,15 +61,15 @@ #ifdef LTC_RABBIT /* local/private prototypes (NB: rabbit_ctx and rabbit_state are different) */ -static LTC_INLINE ulong32 _rabbit_g_func(ulong32 x); -static LTC_INLINE void _rabbit_next_state(rabbit_ctx *p_instance); -static LTC_INLINE void _rabbit_gen_1_block(rabbit_state* st, unsigned char *out); +static LTC_INLINE ulong32 ss_rabbit_g_func(ulong32 x); +static LTC_INLINE void ss_rabbit_next_state(rabbit_ctx *p_instance); +static LTC_INLINE void ss_rabbit_gen_1_block(rabbit_state* st, unsigned char *out); /* -------------------------------------------------------------------------- */ /* Square a 32-bit unsigned integer to obtain the 64-bit result and return */ /* the upper 32 bits XOR the lower 32 bits */ -static LTC_INLINE ulong32 _rabbit_g_func(ulong32 x) +static LTC_INLINE ulong32 ss_rabbit_g_func(ulong32 x) { ulong32 a, b, h, l; @@ -88,7 +88,7 @@ /* -------------------------------------------------------------------------- */ /* Calculate the next internal state */ -static LTC_INLINE void _rabbit_next_state(rabbit_ctx *p_instance) +static LTC_INLINE void ss_rabbit_next_state(rabbit_ctx *p_instance) { ulong32 g[8], c_old[8], i; @@ -110,7 +110,7 @@ /* Calculate the g-values */ for (i=0;i<8;i++) { - g[i] = _rabbit_g_func((ulong32)(p_instance->x[i] + p_instance->c[i])); + g[i] = ss_rabbit_g_func((ulong32)(p_instance->x[i] + p_instance->c[i])); } /* Calculate new state values */ @@ -126,12 +126,12 @@ /* ------------------------------------------------------------------------- */ -static LTC_INLINE void _rabbit_gen_1_block(rabbit_state* st, unsigned char *out) +static LTC_INLINE void ss_rabbit_gen_1_block(rabbit_state* st, unsigned char *out) { ulong32 *ptr; /* Iterate the work context once */ - _rabbit_next_state(&(st->work_ctx)); + ss_rabbit_next_state(&(st->work_ctx)); /* Generate 16 bytes of pseudo-random data */ ptr = (ulong32*)&(st->work_ctx.x); @@ -195,7 +195,7 @@ /* Iterate the master context four times */ for (i=0; i<4; i++) { - _rabbit_next_state(&(st->master_ctx)); + ss_rabbit_next_state(&(st->master_ctx)); } /* Modify the counters */ @@ -255,7 +255,7 @@ /* Iterate the work context four times */ for (i=0; i<4; i++) { - _rabbit_next_state(&(st->work_ctx)); + ss_rabbit_next_state(&(st->work_ctx)); } /* reset keystream buffer and unused count */ @@ -289,7 +289,7 @@ } for (;;) { /* gen a block for buf */ - _rabbit_gen_1_block(st, buf); + ss_rabbit_gen_1_block(st, buf); if (inlen <= 16) { /* XOR and send to out */ for (i = 0; i < inlen; ++i) out[i] = in[i] ^ buf[i]; diff --git a/src/ltc/stream/salsa20/salsa20_crypt.c b/src/ltc/stream/salsa20/salsa20_crypt.c index f4c17b5..3058372 100644 --- a/src/ltc/stream/salsa20/salsa20_crypt.c +++ b/src/ltc/stream/salsa20/salsa20_crypt.c @@ -17,7 +17,7 @@ x[d] ^= (ROL((x[c] + x[b]), 13)); \ x[a] ^= (ROL((x[d] + x[c]), 18)); -static void _salsa20_block(unsigned char *output, const ulong32 *input, int rounds) +static void s_salsa20_block(unsigned char *output, const ulong32 *input, int rounds) { ulong32 x[16]; int i; @@ -67,7 +67,7 @@ in += j; } for (;;) { - _salsa20_block(buf, st->input, st->rounds); + s_salsa20_block(buf, st->input, st->rounds); /* Salsa20: 64-bit IV, increment 64-bit counter */ if (0 == ++st->input[8] && 0 == ++st->input[9]) return CRYPT_OVERFLOW; if (inlen <= 64) { diff --git a/src/ltc/stream/salsa20/xsalsa20_setup.c b/src/ltc/stream/salsa20/xsalsa20_setup.c index d4cf00d..6bfac09 100644 --- a/src/ltc/stream/salsa20/xsalsa20_setup.c +++ b/src/ltc/stream/salsa20/xsalsa20_setup.c @@ -21,7 +21,7 @@ x[a] ^= (ROL((x[d] + x[c]), 18)); /* use modified salsa20 doubleround (no final addition as in salsa20) */ -static void _xsalsa20_doubleround(ulong32 *x, int rounds) +static void s_xsalsa20_doubleround(ulong32 *x, int rounds) { int i; @@ -87,7 +87,7 @@ LOAD32L(x[ 9], nonce + 12); /* use modified salsa20 doubleround (no final addition) */ - _xsalsa20_doubleround(x, rounds); + s_xsalsa20_doubleround(x, rounds); /* extract the subkey */ for (i = 0; i < 8; ++i) { diff --git a/src/ltc/stream/sober128/sober128_stream.c b/src/ltc/stream/sober128/sober128_stream.c index e8853eb..4445151 100644 --- a/src/ltc/stream/sober128/sober128_stream.c +++ b/src/ltc/stream/sober128/sober128_stream.c @@ -10,7 +10,7 @@ #ifdef LTC_SOBER128 -#define __LTC_SOBER128TAB_C__ +#define LTC_SOBER128TAB_C #include "sober128tab.c" /* don't change these... */ diff --git a/src/ltc/stream/sober128/sober128tab.c b/src/ltc/stream/sober128/sober128tab.c index bbde70c..e067bb6 100644 --- a/src/ltc/stream/sober128/sober128tab.c +++ b/src/ltc/stream/sober128/sober128tab.c @@ -6,7 +6,7 @@ SOBER-128 Tables */ -#ifdef __LTC_SOBER128TAB_C__ +#ifdef LTC_SOBER128TAB_C /* $ID$ */ /* @(#)TuringMultab.h 1.3 (QUALCOMM) 02/09/03 */ @@ -163,4 +163,4 @@ 0xf9e6053f, 0xa4b0d300, 0xd499cbcc, 0xb95e3d40, }; -#endif /* __LTC_SOBER128TAB_C__ */ +#endif /* LTC_SOBER128TAB_C */ diff --git a/src/ltc/stream/sosemanuk/sosemanuk.c b/src/ltc/stream/sosemanuk/sosemanuk.c index 2fd7198..6733450 100644 --- a/src/ltc/stream/sosemanuk/sosemanuk.c +++ b/src/ltc/stream/sosemanuk/sosemanuk.c @@ -579,7 +579,7 @@ * Compute the next block of bits of output stream. This is equivalent * to one full rotation of the shift register. */ -static LTC_INLINE void _sosemanuk_internal(sosemanuk_state *st) +static LTC_INLINE void s_sosemanuk_internal(sosemanuk_state *st) { /* * MUL_A(x) computes alpha * x (in F_{2^32}). @@ -717,7 +717,7 @@ * or in2[] is not allowed. Total overlap (out == in1 and/or out == in2) * is allowed. */ -static LTC_INLINE void _xorbuf(const unsigned char *in1, const unsigned char *in2, +static LTC_INLINE void s_xorbuf(const unsigned char *in1, const unsigned char *in2, unsigned char *out, unsigned long datalen) { while (datalen -- > 0) { @@ -750,21 +750,21 @@ if (rlen > inlen) { rlen = inlen; } - _xorbuf(st->buf + st->ptr, in, out, rlen); + s_xorbuf(st->buf + st->ptr, in, out, rlen); in += rlen; out += rlen; inlen -= rlen; st->ptr += rlen; } while (inlen > 0) { - _sosemanuk_internal(st); + s_sosemanuk_internal(st); if (inlen >= sizeof(st->buf)) { - _xorbuf(st->buf, in, out, sizeof(st->buf)); + s_xorbuf(st->buf, in, out, sizeof(st->buf)); in += sizeof(st->buf); out += sizeof(st->buf); inlen -= sizeof(st->buf); } else { - _xorbuf(st->buf, in, out, inlen); + s_xorbuf(st->buf, in, out, inlen); st->ptr = inlen; inlen = 0; }