Commit Graph

388 Commits

Author SHA1 Message Date
Steffen Jaeckel
16f397d55c prevent segfault in case we hit an empty sequence 2015-09-10 19:17:42 +02:00
Steffen Jaeckel
d4945ac521 add (nearly) all defines from tomcrypt_custom.h to crypt_build_settings
... and provide a new make target to check if something is missing
2015-09-08 21:09:49 +02:00
Steffen Jaeckel
733c52aa00 add LTC_RSA_CRT_HARDENING to crypt_build_settings 2015-09-08 21:04:33 +02:00
Steffen Jaeckel
01f1845402 harden RSA CRT by implementing the proposed countermeasure
... from ch. 1.3 of [1]

[1] https://people.redhat.com/~fweimer/rsa-crt-leaks.pdf
2015-09-08 02:44:17 +02:00
Steffen Jaeckel
6ec93afa3c clean-up test-build and extend tomcrypt_custom.h
added LTC_MINIMAL to be able do a build without nearly any
functionality :)
make sure timing resistant RSA & ECC are enabled if not said otherwise
2015-09-01 17:36:43 +02:00
Steffen Jaeckel
8cb20e6059 add more DES test vectors 2015-08-31 15:09:36 +02:00
Sebastian Verschoor
75b114517a make sure no cache-based timing attack is possible
instead of two different buffers, there is just one buffer. Based upon the verification result, a mask is applied to the buffer before it is written to the output buffer.
2015-08-26 00:08:38 +02:00
Steffen Jaeckel
09e4b0ec9b don't reveal plaintext if authentication failed
Create two buffers of the same size as the input data.
Copy the input data to the first one and work with that version to hold the
decrypted data, zeroize the second one.
Copy depending on the verification result, either the zero-buffer or the
real plaintext to the output buffer.
2015-08-26 00:08:38 +02:00
Steffen Jaeckel
6c11ca771b fix compile error of tests 2015-08-26 00:08:38 +02:00
Sebastian Verschoor
25af184cd5 Quickfix for issue #73
The API of the function is changed (for decryption, tag is now an input
parameter). With the old API it is impossible to confirm to the NIST
specification and a timing sidechannel leak is inevitable.
2015-08-26 00:08:38 +02:00
Steffen Jaeckel
f9c8c9c229 also test XTS accelerators 2015-08-26 00:05:07 +02:00
Steffen Jaeckel
181d2f2df7 auto-format xts code 2015-08-26 00:02:50 +02:00
Steffen Jaeckel
b25d04ed94 fix pointer check 2015-08-25 23:58:22 +02:00
Jerome Forissier
5c3f177b34 Add function pointers for accelerated XTS to ltc_cipher_descriptor
Similar to what already exists for other modes.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2015-08-25 23:58:22 +02:00
Steffen Jaeckel
a13257094e handle LTC_NO_FAST before handling LTC_FAST 2015-08-23 22:59:15 +02:00
Steffen Jaeckel
ee03c97cde add crc32 2015-08-23 22:59:14 +02:00
Steffen Jaeckel
9585faca2b re-work debug output of some tests 2015-08-23 22:59:14 +02:00
Steffen Jaeckel
1987a2f975 add adler32 checksum algorithm 2015-08-23 22:59:14 +02:00
Pascal Brand
3605983f09 Introduce ECC raw algorithms for sign and verify
As it is performed on dsa, raw sign and verify on ECC
are introduced.

Signed-off-by: Pascal Brand <pascal.brand@st.com>
2015-08-21 22:14:03 +02:00
Sebastian Verschoor
67973b04ae fix #74 2015-08-21 21:29:56 +02:00
Steffen Jaeckel
c28cc9e3e9 crypt_build_settings: remove build date and time 2015-05-07 10:32:12 +02:00
Karel Miko
aeaa6d4a51 cygwin related fix - variable name B0 changed to B_0 (part 2) 2015-04-17 08:59:35 +02:00
Karel Miko
6a257e15cd cygwin related fix - variable name B0 changed to B_0 as it caused collision when compiling libtomcrypt as a perl module (for some reason only on cygwin) 2015-04-17 08:56:42 +02:00
Karel Miko
a8e91afb16 cygwin/64bit related fix - added !defined(__x86_64__) 2015-04-17 08:50:38 +02:00
Uli Köhler
d24e9cd32d Fix config file reference 2015-03-27 21:41:51 +01:00
Pascal Brand
f20b5daf39 Use XMEM_NEQ instead of mem_neq
mem_neq is no more used directly. XMEM_NEQ is used instead,
in the same way XMEMCMP, XMEMCPY,... are.

Signed-off-by: Pascal Brand <pascal.brand@st.com>
2015-02-27 08:54:30 +01:00
Steffen Jaeckel
dfa938a4f6 verify outcome when defining LTC_NOTHING
check that LTC_NOTHING really creates nothing but the libraries' basic
API functions
2015-02-15 17:25:45 +01:00
Steffen Jaeckel
90e968a202 der_decode_subject_public_key_info: fix compile error
also make it possible to define min/max RSA key sizes externally

This closes #59
2015-02-15 16:32:12 +01:00
Saleem Abdulrasool
62878de0c5 adjust inline asm requiring constants
In order to ensure that the shift is within range, convert the inline assembly
routines into macros with compound statements.
2015-01-20 22:36:07 +01:00
Steffen Jaeckel
0b6915740c saferp: enclose macros in do{}while(0) loop 2015-01-20 22:36:07 +01:00
Steffen Jaeckel
9782c09a3a use XMEM{CMP, CPY, SET} macros instead of standard versions 2015-01-20 22:36:06 +01:00
Steffen Jaeckel
1e9e98aa0d make pkcs#1 decode functions constant-time
as proposed in RFC 3447 only one error return code is used when there are
errors while decoding the pkcs#1 format.
also, all steps are executed and only the "output" is skipped if something
went wrong.

Sorry this could break backwards compatibility, since there's no more
BUFFER_OVERFLOW messaging.
Former error-handling code could also be affected because now there's only
OK as return code in cases where "res" is also set to '1'.
2014-11-13 22:26:59 +01:00
Steffen Jaeckel
e57c92fd23 replace calls to standard memcmp with constant memcmp where necessary 2014-11-13 22:09:45 +01:00
Steffen Jaeckel
26c5d54e5c add constant-time memcmp()
[skip ci]
2014-11-12 23:59:27 +01:00
Steffen Jaeckel
f2f8342c43 ccm test: add missing AAD 2014-11-02 17:01:56 +01:00
Steffen Jaeckel
943a858d6c also run testvectors on new CCM API
[skip ci]
2014-10-31 19:41:14 +01:00
Steffen Jaeckel
4efa27ead1 add missing pointer checks 2014-10-31 19:39:03 +01:00
Steffen Jaeckel
53917750d8 trim trailing spaces 2014-10-31 19:38:47 +01:00
Pascal Brand
992506cb49 Add incremental CCM authentication processing
CCM is only meant for packet mode where the length of the input is known in
advance. Since it is a packet mode function, CCM only had one function that
performs the protocol.

However, incremental authentication is usefull in some usecases. It also
ensure some kind of coherencies when processing with a given authentication
mode or another. To achieve this aim, this commit adds the following functions:
    ccm_init()
    ccm_add_aad()
    cm_add_nonce()
    ccm_process()
    ccm_done()
    ccm_reset()
as well as the data structure
    ccm_state

Change-Id: I5225a42bb098708c4af07518b561bb00f85bc243
2014-10-17 09:00:19 +02:00
Steffen Jaeckel
ed28703804 der_decode_sequence_multi: calm coverity 2014-10-10 01:07:58 +02:00
Steffen Jaeckel
ee1631f8b3 dsa import: no output on stderr please 2014-10-06 19:00:50 +02:00
Steffen Jaeckel
6bd6319fb0 der flexi decoder: implement decoding of context-specific data 2014-10-06 18:57:42 +02:00
Steffen Jaeckel
2d8933e4f1 der: add new enum element for context-specific encodings 2014-10-06 18:57:42 +02:00
Steffen Jaeckel
f0a1235614 der flexi decoder: remove duplicate code 2014-10-06 18:57:41 +02:00
Steffen Jaeckel
3d1231ab15 der flexi decoder: improve CONSTRUCTED type decoding
remove all teh flags
save the entire original identifier
2014-10-06 17:51:25 +02:00
Steffen Jaeckel
c1e81ad469 minor changes
print MP_DIGIT_BIT when running test
der_test: improve error output of 'short integer' test
2014-09-30 13:26:18 +02:00
Steffen Jaeckel
eea24fe2c0 bring back possibility to import/export old DSA key format 2014-09-29 23:44:47 +02:00
Steffen Jaeckel
f58c87866e add possibility to export RSA public key in SubjectPublicKeyInfo format 2014-09-29 23:44:47 +02:00
Steffen Jaeckel
7842e338bf fix API of dynamic language helpers
it is easier to handle 'int' than 'long' in the foreign language
2014-09-29 23:30:02 +02:00
Steffen Jaeckel
1924e6fd47 add sha512/224 and sha512/256 to tests and crypt_build_settings 2014-09-29 19:57:21 +02:00
Steffen Jaeckel
23fb224e19 add sha512/224 and sha512/256 2014-09-29 19:57:21 +02:00
Steffen Jaeckel
3d905ca178 add testcase for multiple XTS encryption/decryption 2014-09-29 19:47:18 +02:00
Pascal Brand
adc54d08d0 Enable multiple XTS encryption or decryption
multiple xts_encrypt() cannot be performed because the
tweak is not updated. That means that
  xts_encrypt(buffer1, tweak)
  xts_encrypt(buffer2, tweak)
is not the same as
  xts_encrypt(concat(buffer1, buffer2), tweak)

Current patch enables such functionalities by
updating the tweak as output of the encryption.
Note that the tweak is no more constant.

The very same modification is performed
on xts_decrypt()

Signed-off-by: Pascal Brand <pascal.brand@st.com>
2014-09-28 22:55:02 +02:00
Pascal Brand
a6e89d58d4 RSA in CRT optimization parameters are empty 2014-09-28 22:48:21 +02:00
Pascal Brand
2bb3f0246f RSA in case CRT optimization parameters are not populated
rsa_exptmod(), ran on the private key, makes use of CRT optimization
parameters. In some use-cases, the given key does not include the
optimization parameters.

This patch allows rsa_exptmod() to run without the CRT parameters,
using directly mp_exptmod().

Signed-off-by: Pascal Brand <pascal.brand@st.com>
2014-09-28 22:45:46 +02:00
Steffen Jaeckel
afaef3993c fix compiler warning when compiling with GMP_DESC 2014-09-10 16:16:46 +02:00
Steffen Jaeckel
f597f29ece math: change get_digit() return value
unsigned long is 32bit wide when compiling with the compiler flag "-mx32"
but the digit size of the math libraries is still 64 bit which lead to
the buggy ecc code.

Therefore define a new type ltc_mp_digit with the correct width and use
that as return value of get_digit()

Has been tested with all three math providers
2014-09-10 16:15:35 +02:00
Steffen Jaeckel
67b9cd8a95 trim trailing spaces 2014-09-02 02:17:43 +02:00
Steffen Jaeckel
ee4c00b753 some more ASN.1 fixes
these should have been in #49
2014-08-31 18:26:14 +02:00
Steffen Jaeckel
7a5ea10e60 add missing ASN1 types in der_encode_set() 2014-08-28 14:02:57 +02:00
Steffen Jaeckel
ddede01d16 trim trailing spaces 2014-08-28 14:02:57 +02:00
Steffen Jaeckel
b06270645e add missing check of the OID 2014-08-28 14:02:57 +02:00
Steffen Jaeckel
6bba3a2a70 change the ASN1 type to be a typedef
replace all 'default' cases in the switch statements
2014-08-28 14:02:57 +02:00
Steffen Jaeckel
00c111b1c8 add missing types to decode routines 2014-08-28 14:02:57 +02:00
Steffen Jaeckel
800182338e unwind conditional expressions
I prefer readability
2014-08-28 14:02:57 +02:00
Christopher Brown
3cdb64eca6 bypass constructed type identification for sets / sequences 2014-08-28 14:02:56 +02:00
Christopher Brown
678b6d9641 fix constructed type identifier check 2014-08-28 14:02:56 +02:00
Steffen Jaeckel
171eae5378 asn1: use LTC_SET_ASN1 macro to access ltc_asn1_list elements 2014-08-28 14:02:56 +02:00
Steffen Jaeckel
8ce125f8a8 mp_rand() assumes the number of digits and not the bitsize as parameter 2014-08-28 13:30:26 +02:00
Steffen Jaeckel
d51715db72 pkcs#1 v1.5 decode: fix missing check of PS length in EMSA mode 2014-08-28 13:30:26 +02:00
Steffen Jaeckel
5eb9743410 rsa_verify_hash: fix possible bleichenbacher signature attack 2014-08-28 13:30:26 +02:00
Jonathan Herzog
3324da2601 Fixed small padding error in the PKCS#1 PSS code.
The existing LTC code for padding meassages for PSS signatures
contained a small error. In particular, the PSS-passing algorithms is
supposed to be given (bitlength of key - 1) as an argument. The LTC
code passes (bitlength of key), and subtracts 1 in the middle of the
PSS-padding. This subtraction unfortunately comes too late: a
calculation using that argument has already been made. Fortunately,
this bug only appeared if the bit-length of the key was 1 mod 8, and
so is unlikely to show up in practice. Still, this patch fixes the
problem.

Conflicts:
	src/pk/pkcs1/pkcs_1_pss_decode.c
2014-08-28 13:30:25 +02:00
Steffen Jaeckel
47b8ccc07c fix hash ID's of ripemd 256 & 320 2014-08-26 17:42:10 +02:00
Steffen Jaeckel
473b0319ad re-enable "unused-parameters" warning 2014-08-24 18:25:24 +02:00
Steffen Jaeckel
01c34dc236 trim trailing spaces 2014-08-24 18:25:24 +02:00
Steffen Jaeckel
1fb649d394 chc: don't execute tests if LTC_TEST is not defined 2014-08-07 01:36:03 +02:00
Steffen Jaeckel
f8449f55d9 trim trailing spaces 2014-08-07 01:36:03 +02:00
Jonathan Herzog
ff736a61bb Hash functions now check for input-length overflow.
Because many of the hash-functions implemented by LTC use the length
of the input when padding the input out to a block-length, LTC keeps
track of the input length in a 64-bit integer. However, it did not
previously test for overflow of this value. Since many of the
hash-functions implemented by LTC are defined for inputs of length
2^128 bits or more, this means that LTC was incorrectly implementing
these hash functions for extremely long inputs. Also, this might have
been a minor security problem: A clever attacker might have been able
to take a message with a known hash and find another message (longer
by 2^64 bits) that would be hashed to the same value by LTC.

Fortunately, LTC uses a pre-processor macro to make the actual code
for hashing, and so this problem could be fixed by adding an
overflow-check to that macro.
2014-08-06 19:06:00 +02:00
Steffen Jaeckel
a8598b0faf fix unregister_prng() where always the first prng would have been removed 2014-08-05 17:47:50 +02:00
Steffen Jaeckel
48bd6702aa uncomment argchk in camellia_setup() 2014-07-17 11:32:52 +02:00
Steffen Jaeckel
155a54ba40 add LTC prefix to most macros 2014-07-17 10:50:36 +02:00
Steffen Jaeckel
3c76dcdd29 fix compiler warning when enabling LTC_GCM_TABLES_SSE2 2014-07-17 10:50:35 +02:00
Steffen Jaeckel
1a61b42775 update output; remove unused define 2014-07-16 15:11:14 +02:00
Steffen Jaeckel
97256daeed remove surplus ';' 2014-07-15 20:26:40 +02:00
Steffen Jaeckel
542ba9995c update math inititializers
make math initializer functions dependant on the xxx_DESC macro instead
of the USE_xxx macro, which is only relevant when building tests etc.
2014-07-15 15:38:18 +02:00
Steffen Jaeckel
fc7eeac218 update/rework constants and sizes 2014-07-15 15:27:31 +02:00
Steffen Jaeckel
fd7b3cd875 use snprintf() instead of sprintf() 2014-07-15 14:09:50 +02:00
Steffen Jaeckel
e628fb9203 clean up/trim trailing spaces 2014-07-15 13:58:48 +02:00
Larry Bugbee
a6b6884982 minor editorial changes 2014-07-14 15:47:20 +02:00
Larry Bugbee
46b6e36ea6 to know if LTC compiled big/little endian, 32/64-bit word 2014-07-14 15:47:20 +02:00
Larry Bugbee
ef1fe79ca5 added missing signatures 2014-07-14 15:47:20 +02:00
Larry Bugbee
3f9144c9a7 added signatures to header file 2014-07-14 15:47:20 +02:00
Larry Bugbee
1b29ce896f include compiler defines and other minor refinements 2014-07-14 15:47:20 +02:00
Steffen Jaeckel
3c6a80525f current icc defines the same macros and functionset as gcc
as a result the special detection of icc has been removed
2014-07-12 17:28:54 +02:00
Steffen Jaeckel
6dfb080810 spit errors if 32- AND 64-bit wordsize is defined 2014-07-12 17:26:30 +02:00
Steffen Jaeckel
8c488289f0 improve some error and informational output 2014-07-12 16:44:28 +02:00
Steffen Jaeckel
98893c077b fix possible free of not yet allocated key parameters
There would have been a call to mp_clear_multi() of all the key parameters
that are not yet allocated, in the case where the calculations of p, q,
tmp1 or tmp2 created an error.

This also includes a proposed improvement from the OLPC project to free
elements in the reverse order as they were allocated.
2014-07-11 16:44:43 +02:00
Steffen Jaeckel
30278d1121 fix possible missing free of rnd and rndi
There could have been a 'goto error', which misses the free of rnd and
rndi even if they were initialized.
This could happen in cases where a private key operation was done and
afterwards one of the operations like reading back or conversion, would
have failed (which is likely not to happen)

This also includes a proposed improvement from the OLPC project to free
elements in the reverse order as they were allocated.
2014-06-15 11:51:38 +02:00
Steffen Jaeckel
48f521688f ltc_init_multi: fix missing call to va_end() 2014-05-25 00:35:03 +02:00
Steffen Jaeckel
8652f33f35 pmac_init: prevent possible out of bounds access of polys[] 2014-05-25 00:35:03 +02:00
Steffen Jaeckel
ea9b2a858a der_encode_utf8_string: calm coverity 2014-05-25 00:35:03 +02:00
Steffen Jaeckel
4c8949e449 aes: calm coverity 2014-05-25 00:35:03 +02:00
Steffen Jaeckel
50d10790e3 trim trailing spaces 2014-05-25 00:35:03 +02:00
Steffen Jaeckel
03385a4419 rand_bn: fix call to zeromem() 2014-05-09 23:29:11 +02:00
Steffen Jaeckel
ca42862d52 math descriptor: add parameter "b" to isprime() 2014-05-09 23:07:41 +02:00
Steffen Jaeckel
5d2fe0da8c trim trailing spaces 2014-05-09 23:07:41 +02:00
Steffen Jaeckel
dc31ca545f dsa_make_key: fix free of wrong pointer resulting in double-free 2014-05-09 23:07:40 +02:00
Steffen Jaeckel
c9f93f6571 dsa_make_key: remove surplus semicolon 2014-05-09 22:43:29 +02:00
Karel Miko
e9a0a27917 DSA params+key generation according FIPS-186-4 (part 1) 2014-05-09 17:58:50 +02:00
Karel Miko
77b4b16030 dsa_make_key minor isuue 2014-05-09 17:58:50 +02:00
Karel Miko
a43bb0fda6 dsa_encrypt_key small correction 2014-05-09 17:58:50 +02:00
Karel Miko
655336f0cb tuning RSA interoperability + small fixes 2014-05-09 17:58:50 +02:00
Karel Miko
67a547086c DSA sign improvement 2014-05-09 17:58:50 +02:00
Karel Miko
3908c70d68 tuning DSA key generation 2014-05-09 17:58:50 +02:00
Karel Miko
e271b9fdbe ECC key pair generation according to FIPS-186-4 2014-05-09 17:58:39 +02:00
Karel Miko
e600ab9d35 dsa_sign_hash: testing k < q 2014-05-09 16:26:24 +02:00
Karel Miko
72022edb8d dsa_make_key: improved testing x < q 2014-05-09 16:26:24 +02:00
Steffen Jaeckel
c63c0433c1 enable timing resistant ECC calculations by default 2014-05-08 15:06:42 +02:00
Steffen Jaeckel
26743d0749 ecc_mulmod_timing: fix compiler warnings 2014-05-08 13:06:24 +02:00
Steffen Jaeckel
bbf278c779 anubis: fix left-shift
this has been brought up in #26
2014-05-01 23:02:21 +02:00
Steffen Jaeckel
ca1a1d18ab anubis: trim trailing spaces 2014-05-01 23:02:21 +02:00
Steffen Jaeckel
c211ce7f66 omac: fix accidentally reverted patch
introduced in 6816ac3f3f
reverted in 8e7777b554
2014-05-01 15:44:09 +02:00
Steffen Jaeckel
aa72cfe1d9 ccm: clarify pt and ct parameters in doc and API description
this fixes #42
[skip ci]
2014-04-30 20:19:11 +02:00
mudzot
3b7c6512ac Add #ifdef to make it easier to embed libtomcrypt with LTC_NOTHING
Restore LTC_NO_MATH and make rand_prime.c depend on LTC_NO_MATH & LTC_NO_PRNGS
2014-04-30 01:13:51 +02:00
Steffen Jaeckel
b895f13484 minor changes/clean-up sources 2014-04-30 01:10:22 +02:00
Steffen Jaeckel
b10c03aead flush content of CVS/SVN tags 2014-04-29 21:13:49 +02:00
Steffen Jaeckel
8a2bd89518 don't use assembler rotate when compiling for windows 64bit 2014-04-29 19:15:28 +02:00
karel-m
8afdb8831d ifdefs related to 64bit MS Windows build
Conflicts:
	src/headers/tomcrypt_cfg.h
	src/prngs/rng_get_bytes.c
2014-04-29 19:15:28 +02:00
Karel Miko
0bda0770d9 fix for ASM failures on freebsd/netbsd 2014-04-29 17:32:14 +02:00
Paul Howarth
445dfa67a6 des.c: Add support for two-key Triple-DES
Add two-key 3DES support, needed by pycrypto.

This commit is based on the one for the bundled libtomcrypt 1.16
code in pycrypto:

https://github.com/dlitz/pycrypto/commit/65085f16
2014-04-15 11:25:18 +01:00
Steffen Jaeckel
ae5cc35298 surround most macros with "do{}while(0)" 2014-04-04 01:03:54 +02:00
Steffen Jaeckel
2bdebb3932 dh: remove including of c-files 2014-04-04 00:38:08 +02:00
Steffen Jaeckel
71ccad06bd dh: remove unused variables 2014-04-04 00:38:07 +02:00
Steffen Jaeckel
f3cdac05ec sha2: remove including of c-files 2014-04-04 00:38:06 +02:00
Steffen Jaeckel
cbd59421bd protect all tables by an ifdef; adjust safer to the same concept 2014-04-04 00:38:05 +02:00
Steffen Jaeckel
ffeb70b48a fix typedef of LTC_FAST_TYPE on x86_64 2014-04-03 22:22:01 +02:00
Steffen Jaeckel
53f04b8e6b only use ulong32 or ulong64 in the macros 2014-04-03 15:06:56 +02:00
Steffen Jaeckel
1f7cf9dc0b move typedefs from tomcrypt_macros.h to tomcrypt_cfg.h 2014-04-03 15:05:56 +02:00
Steffen Jaeckel
561fe83532 fix strict-aliasing compiler warnings 2014-03-04 21:59:16 +01:00
Steffen Jaeckel
0aee5f3217 fix wrong spelled macros 2014-03-04 21:50:18 +01:00
Steffen Jaeckel
84298440f4 trim trailing spaces 2014-03-04 21:50:17 +01:00
Steffen Jaeckel
1d52f3b49b tomcrypt_custom.h: move dependency checks together 2014-03-04 18:09:12 +01:00
Michael Stapelberg
8d7e3d8216 fix typo: s/Endianess/Endianness/ 2014-02-25 10:38:29 +01:00
Steffen Jaeckel
65fd19c1fb dh: fix renamed macro 2014-02-25 10:09:35 +01:00
Steffen Jaeckel
77cca4175f ccm_memory_ex: disable until documented and fixed 2014-02-18 16:07:24 +01:00
Steffen Jaeckel
ed9940175d hmac test: add some more tests from RFC's 2014-02-16 18:55:24 +01:00
Steffen Jaeckel
ddb26a4276 hmac test: remove comments, prepare for extension 2014-02-16 18:41:33 +01:00
Steffen Jaeckel
2adca46735 pkcs#5: add tests for 'algo 2' 2014-02-16 18:41:33 +01:00
Steffen Jaeckel
e48838559b der_encode_setof: fix compiler warning when compiling for windows 64bit 2014-02-16 18:41:32 +01:00
Karel Miko
45dcbc654d fixing broken camellia 2014-02-16 18:41:31 +01:00
Steffen Jaeckel
d2c1329f77 camellia: add new testvector 2014-02-16 18:41:30 +01:00
karel-m
f3789b31b6 fixing warnings when compiling camellia.c with 64bit MS compiler 2014-02-16 18:41:30 +01:00
Steffen Jaeckel
3da9adc366 aes: remove compiler warning when compiled with ENCRYPT_ONLY 2014-02-16 18:41:29 +01:00
Steffen Jaeckel
8e7777b554 trim trailing spaces/clean up 2014-02-16 18:41:28 +01:00
Steffen Jaeckel
d78aa37c10 base64: add define LTC_BASE64_URL, make _internal functions static 2013-11-24 22:11:44 +01:00
Karel Miko
947fe41bbb Add URL safe base64 de-/encoding 2013-10-27 21:49:26 +02:00
Steffen Jaeckel
4f86ad7dcf hkdf: don't compile if not requested 2013-10-15 10:17:53 +02:00
Steffen Jaeckel
b1b15910ed fix rng_get_bytes() when compiling with mingw-gcc 2013-10-15 10:17:17 +02:00
Steffen Jaeckel
bf1ccb629b fix rsa_sign_saltlen_get_max_ex() 2013-10-14 14:16:44 +02:00
Steffen Jaeckel
aacfec441e add rsa_sign_saltlen_get_max_ex() 2013-10-14 14:16:42 +02:00
Steffen Jaeckel
73c201da1f add rsa_get_size() 2013-10-14 14:16:41 +02:00
Steffen Jaeckel
fb65cd0772 fix clang compiler warnings 2013-10-02 01:03:40 +02:00
Steffen Jaeckel
a667a93d52 trim trailing spaces 2013-10-02 01:02:58 +02:00
Steffen Jaeckel
031e551c57 tomcrypt_custom.h: improve and clean-up
Add the possibility to define LTC_NOTHING that disables everything
Remove LTC_NO_MATH as it didn't do anything at all
Enable RSA blinding by default
2013-08-14 16:12:56 +02:00
Steffen Jaeckel
c0b8774cc1 move hkdf to misc 2013-08-14 15:47:07 +02:00
Steffen Jaeckel
bfcf1eb200 trim trailing spaces in header files 2013-03-22 15:15:05 +02:00
Steffen Jaeckel
2526d5df8f xtea: use correct load and store macros 2013-03-22 15:15:04 +02:00
Steffen Jaeckel
0f0b182610 xtea: add new testvectors 2013-03-22 15:15:04 +02:00
Steffen Jaeckel
fa7051c21e xtea: trim trailing spaces 2013-03-22 15:15:02 +02:00
Steffen Jaeckel
e531af7add ecc: fix compiler warnings 2013-03-22 15:14:44 +02:00
Steffen Jaeckel
14b3a5290e include stddef.h per default 2013-03-22 15:14:44 +02:00
Steffen Jaeckel
9203472789 dsa: fix compiler warning 2013-03-22 15:14:43 +02:00
Steffen Jaeckel
2addbcf315 noekeon: fix compiler warning 2013-03-22 15:14:42 +02:00
Steffen Jaeckel
6b5b35e6cc ocb3: don't zero ocb3 context in ocb3_{de,en}crypt_last 2013-03-20 18:10:51 +02:00
Karel Miko
c5c067fd12 ocb_init fix (preventing index overflow) 2013-03-15 13:30:40 +02:00
Karel Miko
9c2193b722 ocb3_init fix (preventing index overflow) 2013-03-15 13:30:39 +02:00
karel-m
abab7089a3 OCBv3 according http://tools.ietf.org/html/draft-krovetz-ocb-03 2013-03-15 13:30:29 +02:00
Larry Bugbee
8e22b17a8e fix define LTC_YARROW_AES 2013-03-15 12:24:00 +02:00
RyanC
fe18c95e76 add the rest of the hkdf test cases 2013-03-15 11:16:17 +01:00
RyanC
11f50bfb3c fix hkdf_expand arguments 2013-03-15 11:16:17 +01:00
Steffen Jaeckel
1c779b88f1 moar debug output 2013-03-15 11:16:17 +01:00
Steffen Jaeckel
c1243feef2 hkdf: improve argument validation 2013-03-15 11:16:16 +01:00
Steffen Jaeckel
13c42a00f6 hkdf: fix compiler warning 2013-03-15 11:16:16 +01:00
Steffen Jaeckel
abeddd6c4b add hkdf_test() 2013-03-15 11:16:16 +01:00
RyanC
c98857a47e add hkdf impl 2013-03-15 11:16:16 +01:00
Christopher Brown
2cb8c44113 der fixes and additions 2013-02-13 10:01:20 +01:00
Steffen Jaeckel
7050bdb7c8 use corrected version of zeromem() from @dtrebbien 2012-11-23 00:53:54 +01:00
Steffen Jaeckel
21ddcf3568 fix multi2 as proposed by kmx 2012-11-18 18:44:14 +01:00
Steffen Jaeckel
8cda684a0e improved multi2_test() 2012-11-18 18:41:46 +01:00
Patrick Pelletier
5b662d6ed8 Fix some small typos in documentation 2012-11-18 15:24:15 +01:00
Patrick Pelletier
6dc089015a Fix LTC's bug in PI1/PI2 of Noekeon. Add vectors from BouncyCastle. 2012-11-18 15:24:13 +01:00
Patrick Pelletier
65254f65bf Fix camellia_keysize() to not change the keysize if it is correct.
It was rounding 32 down to 24, 24 down to 16, and claiming 16 was invalid.
2012-11-18 15:24:12 +01:00
Patrick Pelletier
e3acd4cabe Make GMP use uppercase to match LibTomMath. 2012-11-18 15:24:11 +01:00
Patrick Pelletier
3fbccfcb5c support base 64 for GMP 2012-11-18 15:24:11 +01:00
Patrick Pelletier
382c9d4d85 Some fixes necessary to support the Clang compiler
First of all, it had a failure in SEED:

LTC_KSEED failed for x=0, I got:
expected    actual   (ciphertext)
     5e  ==  5e
     ba  ==  ba
     c6  ==  c6
     e0  ==  e0
     05  !=  00
     4e  !=  00
     16  !=  00
     68  !=  00
     19  ==  19
     af  ==  af
     f1  ==  f1
     cc  ==  cc
     6d  !=  00
     34  !=  00
     6c  !=  00
     db  !=  00

Since SEED uses the 32H macros, this is really analogous to the
problem I saw with the 64H macros in Camellia with gcc.  Not sure why
gcc only had a problem with 64H and not 32H, but since this is an
interaction with the optimizer, it's not going to happen every time
the macro is used (hence why the store tests pass; only when you get
into the complexity of a real cipher do you start having problems) and
it makes sense it will vary from compiler to compiler.

Anyway, I went ahead and added the ability to use __builtin_bswap32,
in addition to __builtin_bswap64, which I already did in a previous
commit.  This solves the problem for clang, although I had to add new
logic to detect the bswap builtins in clang, since it has a different
way to detect them than gcc (see the comments in the code).  The
detection logic was complicated enough, and applied to both the 32H
and 64H macros, so I factored out the detection logic into
tomcrypt_cfg.h.
2012-11-18 15:20:12 +01:00
Patrick Pelletier
ad566e1b00 Use __builtin_bswap64 if it is available
This produces slightly better performance than the inline assembly,
and has the added benefit that it should be portable to other systems
that use gcc, not just x86-64.

Here are the results on my "AMD Athlon(tm) 7450 Dual-Core Processor"
with "gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3":

with portable 64H macros:

camellia            : Schedule at   1659
camellia            [ 23]: Encrypt at   431, Decrypt at   434
whirlpool           : Process at    55

with inline assembly (with "memory clobber" for correctness):

camellia            : Schedule at   1380
camellia            [ 23]: Encrypt at   406, Decrypt at   403
whirlpool           : Process at    50

with __builtin_bswap64:

camellia            : Schedule at   1352
camellia            [ 23]: Encrypt at   396, Decrypt at   391
whirlpool           : Process at    46
2012-11-18 15:20:12 +01:00
Patrick Pelletier
cefff85550 Add "memory" as a clobber for bswap inline assembly.
This had been causing Camellia (the only cipher that uses these
macros) to fail when compiling "out-of-the-box" with gcc version
"4.3.3-5ubuntu4".  I think because the compiler had no idea any memory
access was going on in these macros.

Adding "memory" as a clobber solves the problem, but is probably
overkill.  I suspect that if we specify the constraint for y
differently, we could get rid of both "memory" and __volatile__, which
would allow the compiler to optimize much more.

Also, in gcc versions that support it, we should probably use the
bswap builtins instead.
2012-11-18 15:20:11 +01:00
Patrick Pelletier
ee7c031ddf Added some code (commented out) to print details about Camellia test failure
(and ditto for SEED)

This is modeled after similar commented-out code in sober128_test(),
but slightly fancier.
2012-11-18 15:20:10 +01:00
Patrick Pelletier
d61c537a2a missing a comma 2012-11-18 15:20:08 +01:00
Patrick Pelletier
233f207c17 Use "GMP_DESC" instead of "GPM_DESC"
This seemed to be the only place in the code that was using this
particular transposition.  And, indeed, when compiling with
"GMP_DESC", it looks like it is necessary to disable Diffie-Hellman.
(Otherwise, the test fails for me.)
2012-11-18 15:20:07 +01:00