This repository contains an example demonstrating the compilation and use of Mbed Crypto on Mbed OS.
Revision 0:f34b7234a060, committed 2019-09-24
- Comitter:
- mbed_official
- Date:
- Tue Sep 24 12:02:20 2019 +0100
- Child:
- 1:59536a7f0430
- Commit message:
- Merge pull request #43 from dgreen-arm/remove-mbed-crypto-example
Remove mbed-crypto example
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-mbed-crypto
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.github/issue_template.md Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,44 @@ +<!-- + + ************************************** WARNING ************************************** + + The ciarcom bot parses this header automatically. Any deviation from the + template may cause the bot to automatically correct this header or may result in a + warning message, requesting updates. + + Please ensure that nothing follows the Issue request type section, all + issue details are within the Description section and no changes are made to the + template format (as detailed below). + + ************************************************************************************* + +--> + +### Description + +<!-- + Required + Add detailed description of what you are reporting. + Good example: https://os.mbed.com/docs/latest/reference/workflow.html + Things to consider sharing: + - What target does this relate to? + - What toolchain (name + version) are you using? + - What tools (name + version - is it mbed-cli, online compiler or IDE) are you using? + - What is the SHA of Mbed OS (git log -n1 --oneline)? + - Steps to reproduce. (Did you publish code or a test case that exhibits the problem?) +--> + + +### Issue request type + +<!-- + Required + Please add only one X to one of the following types. Do not fill multiple types (split the issue otherwise.) + Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front + of them would change the meaning incorrectly. The only changes to be made are to add a description text under the + description heading and to add a 'x' to the correct box. +--> + [ ] Question + [ ] Enhancement + [ ] Bug +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CONTRIBUTING.md Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,5 @@ +# Contributing to Mbed OS + +Mbed OS is an open-source, device software platform for the Internet of Things. Contributions are an important part of the platform, and our goal is to make it as simple as possible to become a contributor. + +To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set of guidelines for [contributing to Mbed OS](https://os.mbed.com/docs/mbed-os/latest/contributing/index.html).
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,55 @@ +# Running Mbed Crypto examples on Mbed OS +This repository contains a set of examples demonstrating the compilation and use of Mbed Crypto on Mbed OS. + +List of examples contained within this repository: +* Example code snippets for using the library, with [documentation](https://github.com/ARMmbed/mbed-crypto/blob/development/docs/getting_started.md). + +## Prerequisites +* Install <a href='https://github.com/ARMmbed/mbed-cli#installing-mbed-cli'>Mbed CLI</a> + +## Import +The following are the steps required to install the application: +* Clone the repository and deploy the Mbed OS project: `mbed import https://github.com/ARMmbed/mbed-os-example-mbed-crypto` +* Change your current directory: `cd mbed-os-example-mbed-crypto/getting-started` + +## Compile +To compile the example program use `mbed compile` while specifying the target platform and the compiler. +For example, in order to compile using the ARM GCC compiler and a K64F target platform use: `mbed compile -m K64F -t GCC_ARM`. + +Once the compilation is completed successfully a binary file will be created: `./BUILD/K64F/GCC_ARM/getting-started.bin` + +## Program your board +1. Connect your Mbed device to the computer over USB. +1. Copy the binary file (`getting-started.bin`) to the Mbed device. + +## Run +1. Connect to the Mbed Device using a serial client application of your choice. +1. Press the reset button on the Mbed device to run the program. + +The expected output from the first successful execution of the example program should be as follows: +``` +-- Begin Mbed Crypto Getting Started -- + +Import an AES key... Imported a key +Sign a message... Signed a message +Encrypt with cipher... Encrypted plaintext +Decrypt with cipher... Decrypted ciphertext +Hash a message... Hashed a message +Verify a hash... Verified a hash +Generate random... Generated random data +Derive a key (HKDF)... Derived key +Authenticate encrypt... Authenticated and encrypted +Authenticate decrypt... Authenticated and decrypted +Generate a key pair... Exported a public key + +-- End Mbed Crypto Getting Started -- +``` + +## Troubleshooting +If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. + +## License and contributions + +The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more info. + +This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getting-started/main.cpp Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,778 @@ +/* + * Copyright (c) 2018-2019, Arm Limited and affiliates + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "psa/crypto.h" +#include "mbedtls/version.h" +#include <string.h> +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> + +#define SOME_PLAINTEXT "I am plaintext." +#define SOME_CIPHERTEXT \ +{ \ +0x9f, 0xbf, 0x0b, 0x99, 0x70, 0xe0, 0x3d, 0xab, \ +0xf7, 0x65, 0x43, 0x88, 0x09, 0x2c, 0xb4, 0x66, \ +} +#define ENCRYPTED_WITH_IV \ +{ \ +0x0e, 0x42, 0x75, 0x78, 0xb5, 0x0d, 0x17, 0x4f, \ +0x6e, 0x13, 0xf4, 0xfd, 0x16, 0x30, 0x3e, 0xc7, \ +} +#define AES_KEY \ +{ \ +0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, \ +0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, \ +} +#define RSA_KEY \ +{ \ +0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, \ +0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, \ +0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, 0x54, 0x1e, 0xe1, 0xfe, 0xb0, \ +0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, 0x49, 0xe1, 0x12, 0x96, 0x28, \ +0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, 0x35, 0x24, 0xef, 0x4c, 0x0e, \ +0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, 0xf1, 0x23, 0x49, 0xdd, 0xee, \ +0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, 0x48, 0xcd, 0x02, 0xb2, 0x02, \ +0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, 0xf8, 0x59, 0xc2, 0xc1, 0x81, \ +0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, 0xde, 0x26, 0x3a, 0x2a, 0xbf, \ +0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, 0x60, 0xf7, 0xd6, 0x83, 0x4d, \ +0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, 0xc3, 0x02, 0x03, 0x01, 0x00, \ +0x01, 0x02, 0x81, 0x81, 0x00, 0x87, 0x4b, 0xf0, 0xff, 0xc2, 0xf2, 0xa7, 0x1d, \ +0x14, 0x67, 0x1d, 0xdd, 0x01, 0x71, 0xc9, 0x54, 0xd7, 0xfd, 0xbf, 0x50, 0x28, \ +0x1e, 0x4f, 0x6d, 0x99, 0xea, 0x0e, 0x1e, 0xbc, 0xf8, 0x2f, 0xaa, 0x58, 0xe7, \ +0xb5, 0x95, 0xff, 0xb2, 0x93, 0xd1, 0xab, 0xe1, 0x7f, 0x11, 0x0b, 0x37, 0xc4, \ +0x8c, 0xc0, 0xf3, 0x6c, 0x37, 0xe8, 0x4d, 0x87, 0x66, 0x21, 0xd3, 0x27, 0xf6, \ +0x4b, 0xbe, 0x08, 0x45, 0x7d, 0x3e, 0xc4, 0x09, 0x8b, 0xa2, 0xfa, 0x0a, 0x31, \ +0x9f, 0xba, 0x41, 0x1c, 0x28, 0x41, 0xed, 0x7b, 0xe8, 0x31, 0x96, 0xa8, 0xcd, \ +0xf9, 0xda, 0xa5, 0xd0, 0x06, 0x94, 0xbc, 0x33, 0x5f, 0xc4, 0xc3, 0x22, 0x17, \ +0xfe, 0x04, 0x88, 0xbc, 0xe9, 0xcb, 0x72, 0x02, 0xe5, 0x94, 0x68, 0xb1, 0xea, \ +0xd1, 0x19, 0x00, 0x04, 0x77, 0xdb, 0x2c, 0xa7, 0x97, 0xfa, 0xc1, 0x9e, 0xda, \ +0x3f, 0x58, 0xc1, 0x02, 0x41, 0x00, 0xe2, 0xab, 0x76, 0x08, 0x41, 0xbb, 0x9d, \ +0x30, 0xa8, 0x1d, 0x22, 0x2d, 0xe1, 0xeb, 0x73, 0x81, 0xd8, 0x22, 0x14, 0x40, \ +0x7f, 0x1b, 0x97, 0x5c, 0xbb, 0xfe, 0x4e, 0x1a, 0x94, 0x67, 0xfd, 0x98, 0xad, \ +0xbd, 0x78, 0xf6, 0x07, 0x83, 0x6c, 0xa5, 0xbe, 0x19, 0x28, 0xb9, 0xd1, 0x60, \ +0xd9, 0x7f, 0xd4, 0x5c, 0x12, 0xd6, 0xb5, 0x2e, 0x2c, 0x98, 0x71, 0xa1, 0x74, \ +0xc6, 0x6b, 0x48, 0x81, 0x13, 0x02, 0x41, 0x00, 0xc5, 0xab, 0x27, 0x60, 0x21, \ +0x59, 0xae, 0x7d, 0x6f, 0x20, 0xc3, 0xc2, 0xee, 0x85, 0x1e, 0x46, 0xdc, 0x11, \ +0x2e, 0x68, 0x9e, 0x28, 0xd5, 0xfc, 0xbb, 0xf9, 0x90, 0xa9, 0x9e, 0xf8, 0xa9, \ +0x0b, 0x8b, 0xb4, 0x4f, 0xd3, 0x64, 0x67, 0xe7, 0xfc, 0x17, 0x89, 0xce, 0xb6, \ +0x63, 0xab, 0xda, 0x33, 0x86, 0x52, 0xc3, 0xc7, 0x3f, 0x11, 0x17, 0x74, 0x90, \ +0x2e, 0x84, 0x05, 0x65, 0x92, 0x70, 0x91, 0x02, 0x41, 0x00, 0xb6, 0xcd, 0xbd, \ +0x35, 0x4f, 0x7d, 0xf5, 0x79, 0xa6, 0x3b, 0x48, 0xb3, 0x64, 0x3e, 0x35, 0x3b, \ +0x84, 0x89, 0x87, 0x77, 0xb4, 0x8b, 0x15, 0xf9, 0x4e, 0x0b, 0xfc, 0x05, 0x67, \ +0xa6, 0xae, 0x59, 0x11, 0xd5, 0x7a, 0xd6, 0x40, 0x9c, 0xf7, 0x64, 0x7b, 0xf9, \ +0x62, 0x64, 0xe9, 0xbd, 0x87, 0xeb, 0x95, 0xe2, 0x63, 0xb7, 0x11, 0x0b, 0x9a, \ +0x1f, 0x9f, 0x94, 0xac, 0xce, 0xd0, 0xfa, 0xfa, 0x4d, 0x02, 0x40, 0x71, 0x19, \ +0x5e, 0xec, 0x37, 0xe8, 0xd2, 0x57, 0xde, 0xcf, 0xc6, 0x72, 0xb0, 0x7a, 0xe6, \ +0x39, 0xf1, 0x0c, 0xbb, 0x9b, 0x0c, 0x73, 0x9d, 0x0c, 0x80, 0x99, 0x68, 0xd6, \ +0x44, 0xa9, 0x4e, 0x3f, 0xd6, 0xed, 0x92, 0x87, 0x07, 0x7a, 0x14, 0x58, 0x3f, \ +0x37, 0x90, 0x58, 0xf7, 0x6a, 0x8a, 0xec, 0xd4, 0x3c, 0x62, 0xdc, 0x8c, 0x0f, \ +0x41, 0x76, 0x66, 0x50, 0xd7, 0x25, 0x27, 0x5a, 0xc4, 0xa1, 0x02, 0x41, 0x00, \ +0xbb, 0x32, 0xd1, 0x33, 0xed, 0xc2, 0xe0, 0x48, 0xd4, 0x63, 0x38, 0x8b, 0x7b, \ +0xe9, 0xcb, 0x4b, 0xe2, 0x9f, 0x4b, 0x62, 0x50, 0xbe, 0x60, 0x3e, 0x70, 0xe3, \ +0x64, 0x75, 0x01, 0xc9, 0x7d, 0xdd, 0xe2, 0x0a, 0x4e, 0x71, 0xbe, 0x95, 0xfd, \ +0x5e, 0x71, 0x78, 0x4e, 0x25, 0xac, 0xa4, 0xba, 0xf2, 0x5b, 0xe5, 0x73, 0x8a, \ +0xae, 0x59, 0xbb, 0xfe, 0x1c, 0x99, 0x77, 0x81, 0x44, 0x7a, 0x2b, 0x24, \ +} + +#if !defined(MBEDTLS_PSA_CRYPTO_C) || (MBEDTLS_VERSION_NUMBER < 0x02130000) +int main(void) +{ + printf("Not all of the requirements are met:\n" + " - MBEDTLS_PSA_CRYPTO_C\n" + " - PSA Crypto API v1.0b3\n"); + return 0; +} +#else + +static void import_a_key(void) +{ + psa_status_t status; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + uint8_t data[] = AES_KEY; + psa_key_handle_t handle; + + printf("Import an AES key...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Set key attributes */ + psa_set_key_usage_flags(&attributes, 0); + psa_set_key_algorithm(&attributes, 0); + psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); + psa_set_key_bits(&attributes, 128); + + /* Import the key */ + status = psa_import_key(&attributes, data, sizeof(data), &handle); + if (status != PSA_SUCCESS) { + printf("Failed to import key\n"); + return; + } + printf("Imported a key\n"); + + /* Free the attributes */ + psa_reset_key_attributes(&attributes); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +static void sign_a_message_using_rsa(void) +{ + psa_status_t status; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + uint8_t key[] = RSA_KEY; + uint8_t hash[] = "INPUT_FOR_SIGN"; + uint8_t signature[PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE] = {0}; + size_t signature_length; + psa_key_handle_t handle; + + printf("Sign a message...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Set key attributes */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_SIGN); + psa_set_key_algorithm(&attributes, PSA_ALG_RSA_PKCS1V15_SIGN_RAW); + psa_set_key_type(&attributes, PSA_KEY_TYPE_RSA_KEY_PAIR); + psa_set_key_bits(&attributes, 1024); + + /* Import the key */ + status = psa_import_key(&attributes, key, sizeof(key), &handle); + if (status != PSA_SUCCESS) { + printf("Failed to import key\n"); + return; + } + + /* Sign message using the key */ + status = psa_asymmetric_sign(handle, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, + hash, sizeof(hash), + signature, sizeof(signature), + &signature_length); + if (status != PSA_SUCCESS) { + printf("Failed to sign\n"); + return; + } + + printf("Signed a message\n"); + + /* Free the attributes */ + psa_reset_key_attributes(&attributes); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +static void encrypt_with_symmetric_ciphers(void) +{ + enum { + block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE(PSA_KEY_TYPE_AES), + }; + psa_status_t status; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_algorithm_t alg = PSA_ALG_CBC_NO_PADDING; + uint8_t plaintext[block_size] = SOME_PLAINTEXT; + uint8_t iv[block_size]; + size_t iv_len; + uint8_t key[] = AES_KEY; + uint8_t output[block_size]; + size_t output_len; + psa_key_handle_t handle; + psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT; + + printf("Encrypt with cipher...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) + { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Import a key */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_ENCRYPT); + psa_set_key_algorithm(&attributes, alg); + psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); + psa_set_key_bits(&attributes, 128); + status = psa_import_key(&attributes, key, sizeof(key), &handle); + if (status != PSA_SUCCESS) { + printf("Failed to import a key\n"); + return; + } + psa_reset_key_attributes(&attributes); + + /* Encrypt the plaintext */ + status = psa_cipher_encrypt_setup(&operation, handle, alg); + if (status != PSA_SUCCESS) { + printf("Failed to begin cipher operation\n"); + return; + } + status = psa_cipher_generate_iv(&operation, iv, sizeof(iv), &iv_len); + if (status != PSA_SUCCESS) { + printf("Failed to generate IV\n"); + return; + } + status = psa_cipher_update(&operation, plaintext, sizeof(plaintext), + output, sizeof(output), &output_len); + if (status != PSA_SUCCESS) { + printf("Failed to update cipher operation\n"); + return; + } + status = psa_cipher_finish(&operation, output + output_len, + sizeof(output) - output_len, &output_len); + if (status != PSA_SUCCESS) { + printf("Failed to finish cipher operation\n"); + return; + } + printf("Encrypted plaintext\n"); + + /* Clean up cipher operation context */ + psa_cipher_abort(&operation); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +static void decrypt_with_symmetric_ciphers(void) +{ + enum { + block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE(PSA_KEY_TYPE_AES), + }; + psa_status_t status; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_algorithm_t alg = PSA_ALG_CBC_NO_PADDING; + psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT; + uint8_t ciphertext[block_size] = SOME_CIPHERTEXT; + uint8_t iv[block_size] = ENCRYPTED_WITH_IV; + uint8_t key[] = AES_KEY; + uint8_t output[block_size]; + size_t output_len; + psa_key_handle_t handle; + + printf("Decrypt with cipher...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) + { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Import a key */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DECRYPT); + psa_set_key_algorithm(&attributes, alg); + psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); + psa_set_key_bits(&attributes, 128); + status = psa_import_key(&attributes, key, sizeof(key), &handle); + if (status != PSA_SUCCESS) { + printf("Failed to import a key\n"); + return; + } + psa_reset_key_attributes(&attributes); + + /* Decrypt the ciphertext */ + status = psa_cipher_decrypt_setup(&operation, handle, alg); + if (status != PSA_SUCCESS) { + printf("Failed to begin cipher operation\n"); + return; + } + status = psa_cipher_set_iv(&operation, iv, sizeof(iv)); + if (status != PSA_SUCCESS) { + printf("Failed to set IV\n"); + return; + } + status = psa_cipher_update(&operation, ciphertext, sizeof(ciphertext), + output, sizeof(output), &output_len); + if (status != PSA_SUCCESS) { + printf("Failed to update cipher operation\n"); + return; + } + status = psa_cipher_finish(&operation, output + output_len, + sizeof(output) - output_len, &output_len); + if (status != PSA_SUCCESS) { + printf("Failed to finish cipher operation\n"); + return; + } + printf("Decrypted ciphertext\n"); + + /* Clean up cipher operation context */ + psa_cipher_abort(&operation); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +static void hash_a_message(void) +{ + psa_status_t status; + psa_algorithm_t alg = PSA_ALG_SHA_256; + psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT; + unsigned char input[] = { 'a', 'b', 'c' }; + unsigned char actual_hash[PSA_HASH_MAX_SIZE]; + size_t actual_hash_len; + + printf("Hash a message...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Compute hash of message */ + status = psa_hash_setup(&operation, alg); + if (status != PSA_SUCCESS) { + printf("Failed to begin hash operation\n"); + return; + } + status = psa_hash_update(&operation, input, sizeof(input)); + if (status != PSA_SUCCESS) { + printf("Failed to update hash operation\n"); + return; + } + status = psa_hash_finish(&operation, actual_hash, sizeof(actual_hash), + &actual_hash_len); + if (status != PSA_SUCCESS) { + printf("Failed to finish hash operation\n"); + return; + } + + printf("Hashed a message\n"); + + /* Clean up hash operation context */ + psa_hash_abort(&operation); + + mbedtls_psa_crypto_free(); +} + +static void verify_a_hash(void) +{ + psa_status_t status; + psa_algorithm_t alg = PSA_ALG_SHA_256; + psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT; + unsigned char input[] = { 'a', 'b', 'c' }; + unsigned char expected_hash[] = { + 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, + 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, + 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad + }; + size_t expected_hash_len = PSA_HASH_SIZE(alg); + + printf("Verify a hash...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Verify message hash */ + status = psa_hash_setup(&operation, alg); + if (status != PSA_SUCCESS) { + printf("Failed to begin hash operation\n"); + return; + } + status = psa_hash_update(&operation, input, sizeof(input)); + if (status != PSA_SUCCESS) { + printf("Failed to update hash operation\n"); + return; + } + status = psa_hash_verify(&operation, expected_hash, expected_hash_len); + if (status != PSA_SUCCESS) { + printf("Failed to verify hash\n"); + return; + } + + printf("Verified a hash\n"); + + /* Clean up hash operation context */ + psa_hash_abort(&operation); + + mbedtls_psa_crypto_free(); +} + +static void generate_a_random_value(void) +{ + psa_status_t status; + uint8_t random[10] = { 0 }; + + printf("Generate random...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + status = psa_generate_random(random, sizeof(random)); + if (status != PSA_SUCCESS) { + printf("Failed to generate a random value\n"); + return; + } + + printf("Generated random data\n"); + + /* Clean up */ + mbedtls_psa_crypto_free(); +} + +static void derive_a_new_key_from_an_existing_key(void) +{ + psa_status_t status; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + static const unsigned char key[] = { + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b }; + static const unsigned char salt[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c }; + static const unsigned char info[] = { + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, + 0xf7, 0xf8, 0xf9 }; + psa_algorithm_t alg = PSA_ALG_HKDF(PSA_ALG_SHA_256); + psa_key_derivation_operation_t operation = + PSA_KEY_DERIVATION_OPERATION_INIT; + size_t derived_bits = 128; + size_t capacity = PSA_BITS_TO_BYTES(derived_bits); + psa_key_handle_t base_key; + psa_key_handle_t derived_key; + + printf("Derive a key (HKDF)...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Import a key for use in key derivation. If such a key has already been + * generated or imported, you can skip this part. */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DERIVE); + psa_set_key_algorithm(&attributes, alg); + psa_set_key_type(&attributes, PSA_KEY_TYPE_DERIVE); + status = psa_import_key(&attributes, key, sizeof(key), &base_key); + if (status != PSA_SUCCESS) { + printf("Failed to import a key\n"); + return; + } + psa_reset_key_attributes(&attributes); + + /* Derive a key */ + status = psa_key_derivation_setup(&operation, alg); + if (status != PSA_SUCCESS) { + printf("Failed to begin key derivation\n"); + return; + } + status = psa_key_derivation_set_capacity(&operation, capacity); + if (status != PSA_SUCCESS) { + printf("Failed to set capacity\n"); + return; + } + status = psa_key_derivation_input_bytes(&operation, + PSA_KEY_DERIVATION_INPUT_SALT, + salt, sizeof(salt)); + if (status != PSA_SUCCESS) { + printf("Failed to input salt (extract)\n"); + return; + } + status = psa_key_derivation_input_key(&operation, + PSA_KEY_DERIVATION_INPUT_SECRET, + base_key); + if (status != PSA_SUCCESS) { + printf("Failed to input key (extract)\n"); + return; + } + status = psa_key_derivation_input_bytes(&operation, + PSA_KEY_DERIVATION_INPUT_INFO, + info, sizeof(info)); + if (status != PSA_SUCCESS) { + printf("Failed to input info (expand)\n"); + return; + } + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_ENCRYPT); + psa_set_key_algorithm(&attributes, PSA_ALG_CTR); + psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); + psa_set_key_bits(&attributes, 128); + status = psa_key_derivation_output_key(&attributes, &operation, + &derived_key); + if (status != PSA_SUCCESS) { + printf("Failed to derive key\n"); + return; + } + psa_reset_key_attributes(&attributes); + + printf("Derived key\n"); + + /* Clean up key derivation operation */ + psa_key_derivation_abort(&operation); + + /* Destroy the keys */ + psa_destroy_key(derived_key); + psa_destroy_key(base_key); + + mbedtls_psa_crypto_free(); +} + +static void authenticate_and_encrypt_a_message(void) +{ + psa_status_t status; + static const uint8_t key[] = { + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF }; + static const uint8_t nonce[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B }; + static const uint8_t additional_data[] = { + 0xEC, 0x46, 0xBB, 0x63, 0xB0, 0x25, + 0x20, 0xC3, 0x3C, 0x49, 0xFD, 0x70 }; + static const uint8_t input_data[] = { + 0xB9, 0x6B, 0x49, 0xE2, 0x1D, 0x62, 0x17, 0x41, + 0x63, 0x28, 0x75, 0xDB, 0x7F, 0x6C, 0x92, 0x43, + 0xD2, 0xD7, 0xC2 }; + uint8_t *output_data = NULL; + size_t output_size = 0; + size_t output_length = 0; + size_t tag_length = 16; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_key_handle_t handle; + + printf("Authenticate encrypt...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + output_size = sizeof(input_data) + tag_length; + output_data = (uint8_t *)malloc(output_size); + if (!output_data) { + printf("Out of memory\n"); + return; + } + + /* Import a key */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_ENCRYPT); + psa_set_key_algorithm(&attributes, PSA_ALG_CCM); + psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); + psa_set_key_bits(&attributes, 128); + status = psa_import_key(&attributes, key, sizeof(key), &handle); + psa_reset_key_attributes(&attributes); + + /* Authenticate and encrypt */ + status = psa_aead_encrypt(handle, PSA_ALG_CCM, + nonce, sizeof(nonce), + additional_data, sizeof(additional_data), + input_data, sizeof(input_data), + output_data, output_size, + &output_length); + if (status != PSA_SUCCESS) { + printf("Failed to authenticate and encrypt\n"); + return; + } + + printf("Authenticated and encrypted\n"); + + /* Clean up */ + free(output_data); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +static void authenticate_and_decrypt_a_message(void) +{ + psa_status_t status; + static const uint8_t key[] = { + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF }; + static const uint8_t nonce[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B }; + static const uint8_t additional_data[] = { + 0xEC, 0x46, 0xBB, 0x63, 0xB0, 0x25, + 0x20, 0xC3, 0x3C, 0x49, 0xFD, 0x70 }; + static const uint8_t input_data[] = { + 0x20, 0x30, 0xE0, 0x36, 0xED, 0x09, 0xA0, 0x45, 0xAF, 0x3C, 0xBA, 0xEE, + 0x0F, 0xC8, 0x48, 0xAF, 0xCD, 0x89, 0x54, 0xF4, 0xF6, 0x3F, 0x28, 0x9A, + 0xA1, 0xDD, 0xB2, 0xB8, 0x09, 0xCD, 0x7C, 0xE1, 0x46, 0xE9, 0x98 }; + uint8_t *output_data = NULL; + size_t output_size = 0; + size_t output_length = 0; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_key_handle_t handle; + + printf("Authenticate decrypt...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + output_size = sizeof(input_data); + output_data = (uint8_t *)malloc(output_size); + if (!output_data) { + printf("Out of memory\n"); + return; + } + + /* Import a key */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DECRYPT); + psa_set_key_algorithm(&attributes, PSA_ALG_CCM); + psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); + psa_set_key_bits(&attributes, 128); + status = psa_import_key(&attributes, key, sizeof(key), &handle); + if (status != PSA_SUCCESS) { + printf("Failed to import a key\n"); + return; + } + psa_reset_key_attributes(&attributes); + + /* Authenticate and decrypt */ + status = psa_aead_decrypt(handle, PSA_ALG_CCM, + nonce, sizeof(nonce), + additional_data, sizeof(additional_data), + input_data, sizeof(input_data), + output_data, output_size, + &output_length); + if (status != PSA_SUCCESS) { + printf("Failed to authenticate and decrypt\n"); + return; + } + + printf("Authenticated and decrypted\n"); + + /* Clean up */ + free(output_data); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +static void generate_and_export_a_public_key() +{ + enum { + key_bits = 256, + }; + psa_status_t status; + size_t exported_length = 0; + static uint8_t exported[PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits)]; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_key_handle_t handle; + + printf("Generate a key pair...\t"); + fflush(stdout); + + /* Initialize PSA Crypto */ + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + printf("Failed to initialize PSA Crypto\n"); + return; + } + + /* Generate a key */ + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_SIGN); + psa_set_key_algorithm(&attributes, + PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256)); + psa_set_key_type(&attributes, + PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_CURVE_SECP256R1)); + psa_set_key_bits(&attributes, key_bits); + status = psa_generate_key(&attributes, &handle); + if (status != PSA_SUCCESS) { + printf("Failed to generate key\n"); + return; + } + psa_reset_key_attributes(&attributes); + + status = psa_export_public_key(handle, exported, sizeof(exported), + &exported_length); + if (status != PSA_SUCCESS) { + printf("Failed to export public key %ld\n", status); + return; + } + + printf("Exported a public key\n"); + + /* Destroy the key */ + psa_destroy_key(handle); + + mbedtls_psa_crypto_free(); +} + +int main(void) +{ + printf("-- Begin Mbed Crypto Getting Started --\n\n"); + + import_a_key(); + sign_a_message_using_rsa(); + encrypt_with_symmetric_ciphers(); + decrypt_with_symmetric_ciphers(); + hash_a_message(); + verify_a_hash(); + generate_a_random_value(); + derive_a_new_key_from_an_existing_key(); + authenticate_and_encrypt_a_message(); + authenticate_and_decrypt_a_message(); + generate_and_export_a_public_key(); + + printf("\n-- End Mbed Crypto Getting Started --\n"); + + return 0; +} +#endif /* MBEDTLS_PSA_CRYPTO_C */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getting-started/mbed-os.lib Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getting-started/mbed_app.json Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,12 @@ +{ + "target_overrides": { + "*": { + "platform.stdio-convert-newlines": true, + "target.components_remove": ["SD"] + } + }, + "macros": [ + "MBEDTLS_USER_CONFIG_FILE=\"mbedtls_user_config.h\"" + ] +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getting-started/mbedtls_user_config.h Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2006-2019, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +/* Enable PSA APIs, which this example depends on. */ +#if !defined(MBEDTLS_PSA_CRYPTO_C) +# define MBEDTLS_PSA_CRYPTO_C +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/README.md Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,12 @@ +# Testing examples + +Examples are tested using tool [htrun](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-host-tests) and templated print log. + +To run the test, use following command after you build the example: +``` +mbedhtrun -d D: -p COM4 -m K64F -f .\BUILD\K64F\GCC_ARM\mbed-crypto.bin --compare-log tests\mbed-crypto.log +``` + + +More details about `htrun` are [here](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-host-tests#testing-mbed-os-examples). +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/getting-started.log Tue Sep 24 12:02:20 2019 +0100 @@ -0,0 +1,15 @@ +-- Begin Mbed Crypto Getting Started -- + +Import an AES key... Imported a key +Sign a message... Signed a message +Encrypt with cipher... Encrypted plaintext +Decrypt with cipher... Decrypted ciphertext +Hash a message... Hashed a message +Verify a hash... Verified a hash +Generate random... Generated random data +Derive a key (HKDF)... Derived key +Authenticate encrypt... Authenticated and encrypted +Authenticate decrypt... Authenticated and decrypted +Generate a key pair... Exported a public key + +-- End Mbed Crypto Getting Started --