Commit Graph

2157 Commits

Author SHA1 Message Date
Steffen Jaeckel
d016615d0b migrate from travis CI to GitHub actions
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
6ee927a3e2 improve pk_oid_num_to_str()
* allow `OID` to be `NULL` until you want to write it ...
* make sure we don't overflow the `int i`

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
39c44e14fe prevent UB
This prevents incrementing `adata`, which can be a NULL pointer at this
point.

Fixes #583

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
c2a6b1a9fb add (private) rsa_import_pkcs1()
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
832e66c102 signal a potential overflow when decoding a LTC_ASN1_SHORT_INTEGER
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
c4b30b61dc slightly improve base64 encoding
* ensure base64 encode in&out buffers aren't the same
* allow calling any of the encode functions with `out` being a
  NULL-pointer, to be able to determine the size for storing
  the output.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
8f9d80f171 correctly prefix enum ltc_oid_id members
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
4499b5cdb7 fix typo
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Steffen Jaeckel
39f9cd9420 re-order code a bit
... so only relevant parts are executed

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
Steffen Jaeckel
c450bf4912 annotate some and fix un-aligned #endif
This fixes #572

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-02-18 17:02:07 +00:00
Cedric Neveux
4cd4761284 documentation: add new rsa generate key API
Add rsa_make_key_ubin_e api documentation.

Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com>
2024-02-18 17:02:06 +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
Cedric Neveux
16d422ee86 rsa: add rsa key generate with public exponent upto 256 bits
Function rsa_make_key() limits the RSA key generates to a public
exponent of type long (32 bits or 64 bits).
RSA standard specify that public exponent e can be between 65537 (included)
and 2^256 (excluded).

Add function rsa_make_key_ubin_e to use a hexadecimal public exponent.
Add function rsa_make_key_bn_e to use a bignumber public exponent
(op-tee).

Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com>
2024-02-18 17:02:06 +00:00
Karel Miko
8a46b4cd71 DSA gen params: fixed check group_size vs LTC_MDSA_MAX_GROUP, updated LTC_MDSA_DELTA, new LTC_MDSA_MAX_MODULUS 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
1a97b0f78d don't undermine hash-registry concept
This allows registering an own implementation with a different
descriptor name.
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
8f8a4e3c68 use sha3 if available 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
b49a26dd4b fix dependency to sha2
DSA had a hard dependency to the basic sha2 operations.
In case one wanted to compile e.g. only with sha256 this lead to a
compilation error.
2024-02-18 17:02:06 +00:00
David Cantrell
8aca6a351c m68k platforms are big endian
The endianness fallback in tomcrypt_cfg.h lacked a check for the gcc
define for m68k.  I discovered this while building dropbear on A/UX
3.1.1 on a Macintosh Quadra 700 (yes, in 2021).  Adding the check for
the gcc __m68k__ define gets everything building.

Signed-off-by: David Cantrell <david.l.cantrell@gmail.com>
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
db3ee5ae3e add comment indicating supported platforms of makefile.shared 2024-02-18 17:02:06 +00:00
Karel Miko
a1c1e0e96a missing endif 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
5ce220fe02 fix unbalanced #ifdef for MIPS R5900
This fixes #562

[skip ci]
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
3e6ddfdcbd review CCM
* improve some comments
* harden some arguments
* fix the overflow warning

fixes #555, fixes #544
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
9ffae6720c make sure that CTR->pad[] is aligned to 16 bytes
Fixes #549
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
b2da51b518 clarify LTC_PAD_PKCS7 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
489ca2699c add LTC_ALIGN() macro 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
Biswapriyo Nath
115a689650 Makefile: Fix shared library build in MinGW.
This enables -no-undefined linker flag in mingw toolchain.
Previous related commit 9c2c9f8af4
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
2a4c731676 don't allow LTC_CLEAN_STACK to be enabled until fixed
As discussed in issue #486 [1] the current behavior shouldn't be used
anymore.

[1] https://github.com/libtom/libtomcrypt/issues/486
2024-02-18 17:02:06 +00:00
Steffen Jaeckel
bbeedb0751 update TEA testvectors 2024-02-18 17:02:06 +00:00
Steffen Jaeckel
49d6722fc3 fix tea_ecb_encrypt()
This fixes #553
2024-02-18 17:02:05 +00:00
Steffen Jaeckel
b48a724ba4 fix tea_test() 2024-02-18 17:02:05 +00:00
Steffen Jaeckel
6e3dc3379a make sure PKCS#5 iteration count is a "positive integer"
This fixes #552
2024-02-18 17:02:05 +00:00
Steffen Jaeckel
783b9f706d add check maketarget 2024-02-18 17:02:05 +00:00
Steffen Jaeckel
bff9a84ddd Exclude tests/test.key from potential crlf conversion
This closes #521
2024-02-18 17:02:05 +00:00
Steffen Jaeckel
64018dd683 add comment about padding types 2024-02-18 17:02:05 +00:00
Steffen Jaeckel
083ba719cf read system timer on AARCH64 2024-02-18 17:02:05 +00:00
Steffen Jaeckel
802907ba3f recent aesgcm versions have shorter iv/key strings 2024-02-18 17:02:05 +00:00
Steffen Jaeckel
5a31486a47 Fix returning too many or too few bits
original patch by @friedrichsenm

This closes #543
2024-02-18 17:02:05 +00:00
Tim Gates
f912a3ea3b docs: fix simple typo, succes -> success
There is a small typo in src/mac/f9/f9_test.c, src/mac/xcbc/xcbc_test.c.

Should read `success` rather than `succes`.
2024-02-18 17:02:05 +00:00
d059ecbbcb [*] LTC bug fixes. PR to upstream 2021-01-06 03:29:17 +00:00
20801f76d5 [+] Enable LTM
[-] Remove platform RNG
2021-01-06 01:09:19 +00:00
Steffen Jaeckel
cfbd7f8d36
Merge pull request #545 from libtom/pattop/fixes
Minor fix & cleanup
2020-08-29 11:30:23 +02:00
Patrick Oppenlander
d63d6faf22 sha256: minor undef cleanup
RND is #defined in both the #if and #else case, so move the #undef after
the #endif.
2020-08-17 09:54:14 +10:00