Test the PKCS#7 padding and unpadding functions to behave correctly
on various valid and invalid inputs.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Produce a PKCS#8 and SPKI encoding using OpenSSL and test if the ASN.1 routines
can decode that key and also if the round trip produces the exact same encoded data.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Correct the BER encoded data used for Edwards and Montgomery keys and add
tests for testing the legacy format still being accepted.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Add tests that checks if wrong AlgorithmIdentifier are detected, i.e.
cases where the OID is too short or too long, or invalid by other means.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
A CHOICE with an option value of 0x1f is invalid, it would indicate a
long form tag, which is not supported and is now rejected.
Change the test to check for rejection.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Refactor the code to encode and decode the BER primitives. There was lots of
duplicated code in these functions. This is now refactored out into separate
helper functions.
Also the TLV encoding and decoding in these helpers have been refactored to
use a more streamlined implementation without many similar looking if cases.
With this, encoding and decoding data with more than 3 length octets (16 MB)
is now supported.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
The use of liblber has been eliminated for most of the cases already.
The only leftover cases are in RSA, DSA, and DH public key encoding
functions for encoding BIT STRINGs.
Update these leftover places and use the already existing
ber_encode_BIT_STRING() function instead.
With this, '-lber' can be removed from the make files for most of
the tokens and tools. The ICSF token still requires liblber for its
LDAP communication.
Also adjust the configure script and example RPM spec accordingly.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Fix the following by removing the variable and its assignments entirely.
The function's actual pass/fail logic uses the global tests_failed counter.
testcases/unit/asn1fuzztest.c:846:9: warning: variable 'result' set but
not used [-Wunused-but-set-variable]
846 | int result = 0;
| ^
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Add unit tests for the basic BER encoding and decoding functions in asn1.c.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Assisted-by: IBM Bob: 1.0.1
AIX does not have any of the BSD's warnx and friends functions, and neither
does it have getopt_long. Both of these are included, sourced from a pool of
permissive licenses, with their license notices intact.
In an effort to preserve nativity, this code is not used on other platforms,
instead preferring to use the native behaviours available on respective
platforms.
Additionally, this commit also includes some changes that _removes_
platform-specificity for the Linux platform, setting the _GNU_SOURCE macro
once in autoconf, instead of duplicating that in every source file.
Signed-off-by: Akash Kulhalli <akash.kulhalli@ibm.com>
`random` returns a number within a range that includes 0; but the code does not
always handle that, leading to misleading error messages ("malloc failed" but
it was a request for a memory buffer of size 0) on test run. Those should now
be fixed.
The `ock_tests.sh.in` file has been slightly tweaked to account for some flags
that are not available on AIX. No functional differences expected across all
supported platforms.
On Linux, a null pointer is printed as "(null)", whereas on AIX nothing is
printed. Since this is only for tests, AIX now also prints the same string as
Linux when a nullptr is attempted to be printed.
Signed-off-by: Akash Kulhalli <akash.kulhalli@ibm.com>
The free_attr function might also need the private callback data, just
like the get_attr_val callback function.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Headers not specified either in xxx_SOURCES or noinst_HEADERS will not
be included for 'make dist', and will cause compile errors during
'make distcheck'. Also include several extra files into EXTRA_DIST to
make sure they are distributed as well.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
A bare quoted string can appear outside of a list or key value
pair and represents its own configuration element.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
This allows to parse the APQN_ALLOWLIST specification of an EP11 token
config file:
APQN_ALLOWLIST
<card-no> <domain-no>
...
END
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Only reference the .y and .l files in SOURCES, but not the generated .c
files.
Building the configuration parser requires own rules for yacc and lex.
Avoid automake target override warning using Wno-override.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Make use of mechanism table to translate between string and numeric format of
mechanisms. Remove duplicated code dealing with mechanism translations.
Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>