Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSA compliance tests suite #9312

Merged
merged 13 commits into from
Mar 7, 2019
Merged

PSA compliance tests suite #9312

merged 13 commits into from
Mar 7, 2019

Conversation

orenc17
Copy link
Contributor

@orenc17 orenc17 commented Jan 9, 2019

Description

Add PSA compliance tests suite.
Note: this PR has been expanded to contain the entire suite.
This PR include tests for:

  1. PSA internal-trusted-storage.
  2. PSA Crypto
  3. PSA Attestation

Relies on PRs
#9708 (merged)
#9795 (merged)
#9668 (merged)
#9822 (merged)
upcoming mbedTLS release
Note: this PR will not build without these PRs

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[X] Test update
[ ] Breaking change

Reviewers

@alzix @jaypit02 @dreemkiller

Copy link

@jaypit02 jaypit02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added review comments


const psa_api_t psa_api = {
.framework_version = pal_ipc_framework_version,
.version = pal_ipc_version,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These structures are common to all tests. Therefore, these can be moved to a common file. Moving to common file is more scalable to consume any addition/deletion of an element.

Also you may want add copyright header to such files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to generate the structure for each test
That way it won't mistakenly compiled to an mbed-app and waste flash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after a check I've moved the struct to the framework directory

size_t in_len,
const psa_outvec_t *out_vec,
const psa_outvec *out_vec,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the latest PSA FF spec, out_vec parameter is no more "const". It is now:

Suggested change
const psa_outvec *out_vec,
psa_outvec *out_vec,

@@ -0,0 +1,26 @@
{
"name": "psa-compliance",
"config": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI- These macros definition will be available in pal_config.h in PSA compliance test suite release. Once you have pal_config.h, this json may not be required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "mbed way" for configuration
We could add platform specific configuration in the future through this file

* See the License for the specific language governing permissions and
* limitations under the License.
**/
#define ITS_TEST
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is possible to maintain test specific mbed_lib.json to pass ITS_TEST macro?
Idea is to avoid test editing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

Copy link
Contributor

@alzix alzix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_s001 name does not describe it actually tests PSA ITS implementation.
please rename TESTS/psa-compliance/test_s001 to TESTS/psa-compliance/psa-ist-s001 and fix the importer

@alzix
Copy link
Contributor

alzix commented Jan 31, 2019

@orenc17 - ping

@cmonr
Copy link
Contributor

cmonr commented Jan 31, 2019

Making a note here. I think this now relies on #9192 instead.

@mikisch81
Copy link
Contributor

@cmonr actually like many others, it depends on #9529

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 13, 2019

@orenc17 What is the status for this PR? The dependencies were integrated, weren't they?

@orenc17
Copy link
Contributor Author

orenc17 commented Feb 13, 2019

the porting is being continued by another team.. i believe they use this PR as a base

@cmonr
Copy link
Contributor

cmonr commented Feb 13, 2019

@orenc17 They'll still hit the same problem once they introduce a PR.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 19, 2019

the porting is being continued by another team.. i believe they use this PR as a base

Shall this be closed?

@cmonr
Copy link
Contributor

cmonr commented Feb 19, 2019

@orenc17 This became unblocked once #9529 came in.

Any updates?

@amiraloosh
Copy link

Yes, we will continue with this PR. The PSA team will update tomorrow.

@NirSonnenschein
Copy link
Contributor

Hi @cmonr , @jaypit02 @alzix,
This PR has been forced pushed with multiple changes (multiple additional tests added for attestation and crypto modules as well as its), please re-review the new version.

@NirSonnenschein
Copy link
Contributor

FYI @netanelgonen

@cmonr
Copy link
Contributor

cmonr commented Feb 22, 2019

Checking in, this is still waiting on two other PRs before it can progress, correct?

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 28, 2019

Very last dependency here: #9668 - is now in CI. Will this fix also astyle issues in Travis?

@NirSonnenschein
Copy link
Contributor

@0xc0170 , this should fix most of the issues, I'm adding an astyle ignore rule to ignore the style of the imported compliance tests shortly.

@alekla01
Copy link
Contributor

alekla01 commented Mar 6, 2019

exporter likely needs to be restarted, as it probably has incorrectly status as pending after the license issues.

@cmonr
Copy link
Contributor

cmonr commented Mar 6, 2019

CI job restarted: jenkins-ci/mbed-os-ci_exporter

@cmonr
Copy link
Contributor

cmonr commented Mar 6, 2019

Restarted CI.

Was getting odd null pointer exception issue when restarting single job.

@cmonr cmonr mentioned this pull request Mar 6, 2019
@mbed-ci
Copy link

mbed-ci commented Mar 6, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 8
Build artifacts

{
#ifndef PSA_ATTESTATION_DISABLED
const uint8_t private_key_data[] = {
0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56,

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hard-coded attestation key used for testing the attestation feature. it was randomly generated.
The specific key chosen shouldn't matter to the test it just needs a key to be injected before it is run (in practice each decide is expected to have it's own randomly generated key).

if (IS_TEST_FAIL(status) || IS_TEST_SKIP(status))
{
GREENTEA_TESTSUITE_RESULT(false);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems odd that this was needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you mean the explicit return, you are right, it should not be needed.
It is likely an artifact from the previous implementation of the function. - Fixed

bool continue_test = true;

test_info.test_num = test_num;
if (boot.state == BOOT_NOT_EXPECTED || boot.state == BOOT_EXPECTED_CRYPTO)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something, but how would this ever not be true?

boot_t boot isn't static.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point this check should be removed - fixed

mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call);
}

pal_ipc_close(*handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the handle be closed here instead of outside of the function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is called from a pointer to function in the original attestation test framework (prior to our adaptation to greentea) in the struct val_api_t. The original implementation had the calling semantic that this function frees the handle inside and we preserved this for future compatibility (had we implemented the test framework we would have done many things very differently).

}


}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} // extern "C"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, fixed

#endif

#if defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
inject_entropy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird that this and the following line of code are indented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, however this file has since been replaced (git move) with the file pal_mbed_os_intf.cpp which has been refactored and no longer contains this anomaly

@cmonr
Copy link
Contributor

cmonr commented Mar 7, 2019

@orenc17 A couple of questions/nits, but just looking for answers before merging.

@orenc17
Copy link
Contributor Author

orenc17 commented Mar 7, 2019

@cmonr i've handed over the PR to @NirSonnenschein
i'm no longer working on this PR, we kept it open for convenience

Copy link
Contributor

@NirSonnenschein NirSonnenschein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cmonr

#endif

#if defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
inject_entropy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, however this file has since been replaced (git move) with the file pal_mbed_os_intf.cpp which has been refactored and no longer contains this anomaly

if (IS_TEST_FAIL(status) || IS_TEST_SKIP(status))
{
GREENTEA_TESTSUITE_RESULT(false);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you mean the explicit return, you are right, it should not be needed.
It is likely an artifact from the previous implementation of the function. - Fixed

bool continue_test = true;

test_info.test_num = test_num;
if (boot.state == BOOT_NOT_EXPECTED || boot.state == BOOT_EXPECTED_CRYPTO)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point this check should be removed - fixed

{
#ifndef PSA_ATTESTATION_DISABLED
const uint8_t private_key_data[] = {
0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hard-coded attestation key used for testing the attestation feature. it was randomly generated.
The specific key chosen shouldn't matter to the test it just needs a key to be injected before it is run (in practice each decide is expected to have it's own randomly generated key).

mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call);
}

pal_ipc_close(*handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is called from a pointer to function in the original attestation test framework (prior to our adaptation to greentea) in the struct val_api_t. The original implementation had the calling semantic that this function frees the handle inside and we preserved this for future compatibility (had we implemented the test framework we would have done many things very differently).

}


}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, fixed

@NirSonnenschein
Copy link
Contributor

restarted CI on review fixes

@alekla01
Copy link
Contributor

alekla01 commented Mar 7, 2019

Restarted jenkins-ci/exporter

@mbed-ci
Copy link

mbed-ci commented Mar 7, 2019

Test run: FAILED

Summary: 1 of 13 test jobs failed
Build number : 10
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_exporter

@NirSonnenschein
Copy link
Contributor

CI has passed again on the CR changes, @cmonr please take a look, if all is ok we can proceed.

@cmonr
Copy link
Contributor

cmonr commented Mar 7, 2019

#9312 (comment)

@NirSonnenschein It would be good to capture this as a comment in the file, but that can be added in a seperate PR.

Not going to block the PR on that.

@cmonr cmonr merged commit a87c7c8 into ARMmbed:master Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.