Commit Graph

183 Commits

Author SHA1 Message Date
Steffen Jaeckel
9a05c23516 Add Testcase for #627
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:03:01 +00:00
Steffen Jaeckel
c3a9a04c1b Add empty stub for s_der_tests_print_flexi()
So we don't have to `#ifdef` whether it's available or not.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
d8d99887b5 Add Testcase that UTF-8 decoding respects the ASN.1 length
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
71c93ed301 Add Testcase for #630
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
33a26c4959 introduce separate aes_desc
`aes_desc` and `aes_enc_desc` now do auto-detection of the best suitable
AES implementation for the platform.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
13fd324a3b add support for AES-NI instructions
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:10 +00:00
Steffen Jaeckel
bebf2ffd65 Calm scan-build static analyser
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
effe0e8e21 allow input-data pointer to be NULL
If we allow the length to be 0, we should also prepare for the case where
the user doesn't want to provide a valid input-data pointer.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
97d0f61491 port cmake integration changes from libtommath
... also enable building of tests.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:09 +00:00
Steffen Jaeckel
3c05f2b65a fix incompatibility issues with LLP64 data models
This is also a fixup of a921112fe32fce1d5cce386ab09d3edcaa004c51

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
df529c3cbc add test-case that uses LTC_NO_NULL_TERMINATION_CHECK
It's a compile-only test, but we run it anyways so we can finally get
`crypt_fsa()` included in the coverage report. It's not really useful but
also doesn't hurt.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
ae1c26842b use LTC_NULL in the library code
`NULL` as defined by the standard is not guaranteed to be of a pointer
type. In order to make sure that in vararg API's a pointer type is used,
define our own version and use that one internally.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
57c90507ae re-factor some parts of the Ed25519ctx and Ed25519ph implementation
* The RFC doesn't limit the context to be a string.
  It talks about `octets` which means it could be any binary data.
* Move the context-preprocessing function out of tweetnacl.c
* Fix potential segfaults when Ed25519 signature verification fails and
  `LTC_CLEAN_STACK` is enabled.
* Fix all the warnings.
* Update documentation.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Valerii Chubar
3f91f261ff Add ed25519ctx and ed25519ph support
Signed-off-by: Valerii Chubar <valerii_chubar@epam.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
2024-02-18 17:02:08 +00:00
Valerii Chubar
a37f4ca5df ed25519: Add testcase for segfault on verify
In case when the signature is not verified the "mlen" variable
is equal to ULONG_MAX. When LTC_CLEAN_STACK has been defined
this results in a segmentation fault.

Signed-off-by: Valerii Chubar <valerii_chubar@epam.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
142d5033f1 Ensure that hash overflow is detected
Previously it was not detected if `inlen` itself was too big and would
overflow the multiplication by 8.

Related to #592

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:08 +00:00
Steffen Jaeckel
8059e5a097 fix sporadically failing tests when built with pthreads support
... I hope ... :)

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
599d4861a3 make sure to check yarrow_read() return values
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
13f2ab092a better debug output
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
ee92fce094 fix/improve DER tests
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
48c5894d40 continue looping on NOP
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
deaa907a5c add base64_encode_pem()
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
71e54554ff add SSH-style padding
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Cedric Neveux
a7a81d63e1 test: add test rsa key generate with public exponent upto 256 bits
Add a RSA test generating a RSA key with a 256 bits public exponent.

Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com>
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
33542d0a83 cast away cast-align warnings 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
a0e47aac6b re-factor some tests 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
90f0e0df80 make sure basic types are marked as UNIVERSAL&PRIMITIVE
This fixes DCIT/perl-CryptX#69
2024-02-18 17:02:06 +00:00
James Muir
d5db9f1548 Add new utf8 test-vector, update comments explaining utf8 decoding
Description:
Minor changes to help test and clarify the way utf8 strings are
decoded.  This originated from my misunderstanding of the fix for
issue #507.  The new test-vector uses two bytes to encode each
wide-char.

The utf8 format is described here:

  https://tools.ietf.org/html/rfc3629#section-3

Testing:

  $ make clean
  $ make CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" test
  $ ./test

You can confirm that the new utf8 test data is correct using python:

  >>> s="\xD7\xA9\xD7\x9C\xD7\x95\xD7\x9D"
  >>> s.decode("utf-8")
  u'\u05e9\u05dc\u05d5\u05dd'
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
c5d7bfb2cc manually fix the remaining leading _'s 2020-07-16 10:38:33 +02:00
Steffen Jaeckel
9824af8e3b update header 2020-07-14 18:41:30 +02:00
Steffen Jaeckel
24765c30c5 remove footer 2020-07-14 18:41:29 +02:00
Steffen Jaeckel
cac400cf79 really implement DER decoding resursion limit
PR #373 did not really fix the issue of preventing a potential stack
overflow in case a lot of nested sequences have to be decoded.
Instead it only threw an error after successfully decoding all the nested
sequences.
This change fixes this and prevents the decoding.
2020-06-20 12:28:22 +02:00
Steffen Jaeckel
334876db78 rename x25519_set_key to x25519_import_raw 2019-10-19 16:30:18 +02:00
Steffen Jaeckel
44a18342ba rename ed25519_set_key to ed25519_import_raw 2019-10-19 16:30:18 +02:00
Steffen Jaeckel
3540fd713c fixup x25519_import()
bring x25519_import() in line with its ed25519 counterpart
2019-10-19 16:30:05 +02:00
Steffen Jaeckel
4e28b922a9 add rsa_shrink_key() 2019-10-17 22:27:54 +02:00
Steffen Jaeckel
68cc580602 use macros in more tests 2019-10-17 12:49:20 +02:00
Steffen Jaeckel
ef55d1335e fix some MSVC compiler warnings 2019-10-17 10:29:27 +02:00
Steffen Jaeckel
2a63adc1ab add XSTRLEN 2019-10-17 10:29:27 +02:00
Steffen Jaeckel
9b6bf32f88 use unsigned long for the length of a string 2019-10-13 14:05:41 +02:00
Steffen Jaeckel
27ec31d4f3 improve SSH decoding & doc 2019-10-13 14:05:41 +02:00
Steffen Jaeckel
58254f76e8 fix SSH string implementation 2019-10-13 14:05:41 +02:00
Steffen Jaeckel
f89909bd6c use macros in ssh_test() 2019-10-13 14:05:41 +02:00
Steffen Jaeckel
8b5ce8ba7e add ENSURE() macro 2019-10-13 14:05:41 +02:00
Steffen Jaeckel
9423f3b26d add bcrypt 2019-10-12 14:31:38 +02:00
Steffen Jaeckel
d2027d60eb add testcase for issue #507 2019-10-11 14:32:22 +02:00
Steffen Jaeckel
eaf2c7b6b9 fix build for msvc 2019-09-24 14:09:35 +02:00
Steffen Jaeckel
0b06979b10 prefix tweetnacl crypto_ API 2019-06-10 12:48:16 +02:00
Steffen Jaeckel
0392867678 use shared {ed,x}25519_export() implementation 2019-06-09 23:20:45 +02:00
Steffen Jaeckel
819656a12f add ed25519_make_key() testcase 2019-06-09 23:20:45 +02:00