Commit Graph

8302 Commits

Author SHA1 Message Date
Jaeden Amero
9411db74c4 psa: driver: Wrap types and symbols for C/C++ use
Add extern "C" wrappers around type and function declarations to enable C++
interoperability of the driver header. This is done so that the driver
functions and types can be used or implmented by C++ code.
2018-10-26 13:39:43 +01:00
Jaeden Amero
20b8a4f2ff psa: driver: Convert struct types to typedefs
Convert PSA Crypto driver model structs to typedefs so that the `struct`
name doesn't need to be used and for consistent style with other PSA
structures.
2018-10-26 13:39:42 +01:00
Jaeden Amero
4155850dd9 psa: driver: Use header guard style consistently
The file crypto_driver.h was not using the header guard style as other PSA
Crypto header files. Remove the `__` prefix and suffix. Use C-style
comments for the end-of-guard comment.
2018-10-26 12:25:05 +01:00
Jaeden Amero
7632f628d7 psa: driver: Prefix "encrypt or decrypt" type
The driver model's "encrypt or decrypt" type, encrypt_or_decrypt_t, is
publicly exposed and needs to have a `psa_` prefix in order to properly
communicate that it is part of the PSA driver model.
2018-10-26 12:25:05 +01:00
Jaeden Amero
1acb2c4317 psa: driver: Replace pcd_ prefix with psa_drv_
The `pcd_` prefix is ambiguous and does not make it clear that the types
and symbols are standardized by PSA. Replace `pcd_` with a prefix that can
be shared with all PSA drivers, `psa_drv_`.
2018-10-26 12:25:05 +01:00
Jaeden Amero
e095d60d95 psa: driver: Use "Driver Model" terminology
"Driver APIs" can be interpreted to mean APIs used when you want to write a
driver, not the set of functions you implement to make a driver. See
https://www.kernel.org/doc/html/latest/driver-api/index.html "The kernel
offers a wide variety of interfaces to support the development of device
drivers."

As such, we are renaming "Driver API" to "Driver Model" and updating our
work so far to reflect this change.
2018-10-26 12:25:05 +01:00
Jaeden Amero
72244ae595 psa: driver: Fix names of AEAD functions
The driver AEAD functions had a `psa_` prefix. They should have had a
`pcd_` prefix like the other driver functions.
2018-10-26 12:12:49 +01:00
Jaeden Amero
0a09f77357 psa: driver: Fix comment whitespace format
Fix comment formatting whitespace issues in crypto_driver.h to match our
style.
2018-10-26 12:12:08 +01:00
Jaeden Amero
d3d26aa6b2 psa: driver: Fix trailing whitespace issues
Remove all trailing whitespace from crypto_driver.h. Ensure there is a new
line at the end of crypto_driver.h.
2018-10-26 12:04:14 +01:00
Jaeden Amero
00646883f1 visualc: Add crypto_driver.h to project
A new header file for crypto drivers has been added, so we need to ensure
that the Visual Studio project files reference the new header.
2018-10-26 10:04:44 +01:00
Nir Sonnenschein
b46e7ca16b add additional generator tests and generalize key derivation test
Key derivation test now uses an indirect way to test generator validity
as the direct way previously used isn't compatible with the PSA IPC
implementation. Additional bad path test for the generator added
to check basic bad-path scenarios.
2018-10-25 14:46:09 +03:00
Mohammad AboMokh
87576c5c5a Improve line coverage for asymmetric verify function by adding new bad scenarios 2018-10-25 13:49:59 +03:00
Mohammad AboMokh
8ffded300d Improve line coverage for asymmetric sign function by adding new bad scenarios 2018-10-25 13:49:38 +03:00
Jaeden Amero
ec57c5579a
Merge pull request #161 from ARMmbed/driver_api
Added the crypto driver API header file
2018-10-24 16:15:58 +01:00
Derek Miller
6f960ab063 Additional fixes per comments in PR#92 in psa-crypto 2018-10-23 15:58:06 -05:00
Derek Miller
81133a6f76 More changes due to PR feedback 2018-10-23 14:55:32 -05:00
Gilles Peskine
2d23af75da
Merge pull request #165 from ARMmbed/dev/dgreen-arm/windows_proj_wip
Windows build fixes (#165)
2018-10-23 13:15:01 +02:00
Darryl Green
6c0f94cbd0 Add better handling when deleting files on Windows
Windows complains if you try to delete a file that doesn't exist.
Makefiles now check if the files exist before trying to delete them.
2018-10-23 12:03:31 +01:00
Darryl Green
3b80ab93ce Add path handling for psa_constant_names on Windows 2018-10-23 12:03:31 +01:00
Darryl Green
608e091d9a Add pre Visual Studio 2015 support to psa_constant_names
snprintf was only added in Visual Studio 2015. This adds support
for building using Visual Studio versions prior to 2015.

This implementation of snprintf has been taken from platform.c
2018-10-23 12:02:37 +01:00
Derek Miller
765682cf09 Added detailed descriptions for modules. Additional small edits. 2018-10-22 15:27:27 -05:00
Gilles Peskine
9ba61d0ce5 Ignore generated files under crypto/ from crypto/.gitignore
In /crypto/.gitignore, list files that are generated by a build done
under /crypto/. In the outer /.gitignore, list files under /crypto/
only if they are created by the export process.

This commit slightly refines both lists and adds some build products
to /crypto/.gitignore.
2018-10-22 19:37:04 +02:00
Gilles Peskine
6dee5c9649 Add test_suite_psa_crypto_metadata to cmake builds
This test suite was run by make builds, but I had forgotten to add it
to CMakeLists.txt.
2018-10-22 19:37:04 +02:00
Nir Sonnenschein
e5204c94a1 add tests that increase key derivation code coverage slightly
added tests that increase code coverage for the key derivation functions slightly
by reaching error cases not covered before.
2018-10-22 17:24:55 +03:00
Darryl Green
1824696681 Fix integer conversion warnings in psa_constant_names 2018-10-22 09:05:33 +01:00
Gilles Peskine
a3678224b3
Merge pull request #167 from ARMmbed/mbedtls-psa-jenkinsfile
Add Jenkinsfile to run PR job testing
2018-10-19 18:17:05 +02:00
Darryl Green
ddb4f3bdf7 Add a Jenkinsfile for PR job testing 2018-10-19 16:41:54 +01:00
Derek Miller
f3d0a56841 Integrated mostly cosmetic feedback from Alex 2018-10-18 16:41:08 -05:00
Gilles Peskine
d004ffa59e
Merge pull request #138 from ARMmbed/truncated_mac
Truncated MAC and AEAD modes (#138)
2018-10-18 20:06:30 +02:00
Gilles Peskine
e0e9c7c417 New macro PSA_ALG_FULL_LENGTH_MAC
Provide a documented way of constructing the full-length MAC algorithm
from a truncated version.
2018-10-17 18:30:47 +02:00
Gilles Peskine
57fbdb1939 Use a public macro for AEAD tag length variations
Avoid depending on the encoding of algorithms inside psa_crypto.c.
2018-10-17 18:30:47 +02:00
Gilles Peskine
7fa99d90dd Add metadata tests for truncated MAC and short-tag AEAD 2018-10-17 18:30:47 +02:00
Gilles Peskine
f8a8fe60f8 Fix memory leak with AEAD with non-default tag lengths
When freeing the key context, choose the context format based on the
base algorithm value stored in the operation object.
2018-10-17 13:54:48 +02:00
Gilles Peskine
c26eae1a9d Clarify the description of a CCM truncated tag test 2018-10-17 13:54:48 +02:00
Gilles Peskine
85ea2b397c Add some negative tests of CCM and GCM with invalid tag lengths 2018-10-17 13:54:48 +02:00
Gilles Peskine
8cac2e628e Translate GCM_BAD_INPUT to INVALID_ARGUMENT, not NOT_SUPPORTED 2018-10-17 13:54:48 +02:00
Gilles Peskine
28dfea6bb9 Add test cases for truncated MAC with a too short/long length 2018-10-17 13:54:47 +02:00
Gilles Peskine
99b7d6b700 Wipe sensitive data in psa_mac_verify_finish
Wipe the whole MAC intermediate buffer, not just the requested MAC
size. With truncated MAC algorithms, the requested MAC size may be
smaller than what is written to the intermediate buffer.
2018-10-17 13:54:47 +02:00
Gilles Peskine
87b0ac49f8 Fix possible buffer overread in psa_mac_finish_internal (CMAC) 2018-10-17 13:54:47 +02:00
Gilles Peskine
6d72ff9e79 Document that the minimum truncated MAC length is implementation-defined 2018-10-17 13:54:47 +02:00
Gilles Peskine
e1f2d7d1ac Document and check the consistency of truncated MAC encodings
Add comments noting that the maximum length of a MAC must fit in
PSA_ALG_MAC_TRUNCATION_MASK. Add a unit test that verifies that the
maximum MAC size fits.
2018-10-17 13:54:47 +02:00
Derek Miller
16e72299cd Changed crypto_driver.h based on PR feedback 2018-10-15 16:14:24 -05:00
Derek Miller
5b3417a3d1 Added the crypto driver API header file 2018-10-10 17:55:03 -05:00
Gilles Peskine
3111981d94 Fix parameter name in Doxygen documentation 2018-10-08 14:45:35 +02:00
Gilles Peskine
38808fa094 psa_constant_names: fix some copypasta 2018-10-08 14:45:35 +02:00
Gilles Peskine
498c2a1ff5 psa_constant_names: support truncated MAC and AEAD 2018-10-08 14:45:35 +02:00
Gilles Peskine
0deaf3d8d7 psa_constant_names: new function append_integer
Factor repeated code into a new function append_integer.
2018-10-08 14:45:35 +02:00
Gilles Peskine
70f46e17e8 New macro PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH
Useful to analyze algorithm values.
2018-10-08 14:45:35 +02:00
Gilles Peskine
be00a71c90 Add tests for shorter-tag AEAD (CCM, GCM) 2018-10-08 14:45:35 +02:00
Gilles Peskine
23cc2ff9a8 Add support for non-default-tag-size AEAD (CCM and GCM) 2018-10-08 14:42:11 +02:00