fb94702762
Add catch for alloc error x509_oid_from_numericoid
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
4294ccc608
Use mbedtls_calloc instead of calloc
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
55d93192b1
Fix oid memory leak
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
f826d1113e
Reject null bytes in DER encoded values in DNs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
eb55867520
Fix code style
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
af3e548c77
Make MBEDTLS_ASN1_IS_STRING_TAG to take signed int
...
Since mbedtls_asn1_buf uses a signed int for tags.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
ea3e83f36a
Amend test in test_suite_x509write
...
Needed since we now reject escaped null hexpairs in strings
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
9caaa6d967
Reject escaped null hexpairs in DNs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
01e9392c3f
Add malformatted DER test for string_to_names
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
bdf20a0d55
Alter MBEDTLS_ASN1_IS_STRING_TAG macro
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
cab79188ca
Remove redundant tests in test_suite_x509write
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
a0ba8aab2e
Add test for non ascii x509 subject name
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
a953f8ab36
Remove duplicate test in test_suite_x509write
...
The test for outputing a hexstring representation is actually
testing dn_gets, and is tested in test_suite_x509parse.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
957ca0595d
Accept short name/ber encoded data in DNs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
17984874af
Change error from unknown oid to invalid name
...
Since the implementation no longer needs to know the oid, it makes more
sense for the error message to be an invalid name.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
afdb187bbc
Add more comprehensive string to name tests
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
e59dedbce2
Add test reject null characters in string to names
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
f88bd5ac86
Accept any valid oid in string_to_names
...
Instead of using x509_attrs, use generic oid conversion.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
af70c7dce7
Write numeric oid directly to buffer
...
mbedtls_oid_get_numeric_string now points to output buffer in dn_gets
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
a7f9630925
Remove duplicate '+' in comparison string
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
5ca9848513
Reword test in test_suite_x509write
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
5adffb2488
Refactor dn_gets use library function to write tag
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
2bf09a61a3
Fix style on left shift operations
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
e18a1789fd
Use MBEDTLS_X509_MAX_DN_NAME_SIZE for buffer size
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
ee642d93a8
Format preprocessor conditionals
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
ed88eefe8e
Rename in_tag to in_attr_type
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
97178f231f
Fix code style in mbedtls_x509_string_to_names
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
7f639fc7ab
Fix Windows x64 build errors with type conversions
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
39ba121d3a
Fix memory leak in alternative code route
...
If no oid is found, and x509_attr_descr_from_numericoid returns NULL,
previously the memory allocated for the oid wasn't freed.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
f818e01edb
FIx memory leak in x509_attr_descr_from_numericoid;
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
a1f5c2d06f
Move declaration of variables in dn_gets to top
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
0a4b6d88d0
Alter conditions on hexstring output dn_gets
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
47cc76f070
Update x509 test for numericoid/hexstring output
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
4987c8fcb0
Fix code style on x509.c and x509_create.c
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
c9d74f3109
Refactor AttributeType in mbedtls_x509_dn_gets
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
0eb6673a80
Add preprocessor config guards
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
6cbfae591a
Parse DER tag mbedtls_x509_string_to_names
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
ddc720d209
Add mbedtls_x509_dn_gets hexstring output
...
If the data is a bitstring or an octet string, instead use the hexstring
of the BER encoding (RFC 4514 Section 2.4)
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
ef299d6735
Add more tests for RFC 4514
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
b73778d8f9
Implement parse_attribute_value_ber_encoded
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
e119f3c0ea
Refactor mbedtls_x509_string_to_names
...
This refactor is to accomodate future support of numericoid/hexstring
attributetype value pairs.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
404b4bb9ab
Add x509 tests for upper and lowercase hexpairs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
f0e1ac59d8
Rewrite nibble_to_hex_digit for readability
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
9d2507c81d
Rename x509_int_to_hexdigit to nibble_to_hex_digit
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:56 +01:00
dba8a641fe
Add and update tests for x509write and x509parse
...
Due to change in handling non-ascii characters, existing tests had to be
updated to handle the new implementation. New tests and certificates
are added to test the escaping functionality in edge cases.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:39:52 +01:00
ef2decbe4a
Escape hexpairs characters RFC 4514
...
Converts none ascii to escaped hexpairs in mbedtls_x509_dn_gets and
interprets hexpairs in mbedtls_x509_string_to_names.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:38:16 +01:00
48513b8639
Escape special characters RFC 4514
...
This escapes special characters according to RFC 4514 in
mbedtls_x509_dn_gets and de-escapes in mbedtls_x509_string_to_names.
This commit does not handle hexpairs.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-08-22 10:38:16 +01:00
30b0378008
Fix off-by-one error
...
The value of p after adding the last entry in the gap table is not used.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-08-22 11:06:47 +02:00
5022311c9d
Tidy up allow list definition
...
* Don't break string literals in the allow list definition
* Comment each test that belongs to the allow list is there.
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com >
2023-08-22 09:54:28 +01:00
7ebb18fbd6
Make non-executed tests that are not in the allow list an error
...
* Turn the warnings produced when finding non-executed tests that
are not in the allow list into errors.
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com >
2023-08-22 09:47:49 +01:00