Skip to content

Commit 534b15a

Browse files
committed
Update the README, move CONTRIBUTING.md
1 parent e19fdbb commit 534b15a

File tree

2 files changed

+146
-55
lines changed

2 files changed

+146
-55
lines changed

CONTRIBUTING.md renamed to .github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ If you discover a potential security issue in this project we ask that you notif
5656

5757
## Licensing
5858

59-
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
59+
See the [LICENSE](../LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
6060

6161
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.

README.md

Lines changed: 145 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,130 @@
11
# corePKCS11 Library
2-
[PKCS #11](https://en.wikipedia.org/wiki/PKCS_11) is a standardized and widely used API for manipulating common cryptographic objects. It is important because the functions it specifies allow application software to use, create, modify, and delete cryptographic objects, without ever exposing those objects to the application’s memory.
3-
For example, FreeRTOS AWS reference integrations use a small subset of the PKCS #11 API to, among other things, access the secret (private) key necessary to create a network connection that is authenticated and secured by the [Transport Layer Security (TLS)](https://en.wikipedia.org/wiki/Transport_Layer_Security) protocol – without the application ever ‘seeing’ the key.
42

5-
6-
The Cryptoki or PKCS #11 standard defines a platform-independent API to manage and use cryptographic tokens. The name, "PKCS #11", is used interchangeably to refer to the API itself and the standard which defines it.
7-
8-
This repository contains a software based mock implementation of the PKCS #11 interface (API) that uses the cryptographic functionality provided by Mbed TLS. Using a software mock enables rapid development and flexibility, but it is expected that the mock be replaced by an implementation specific to your chosen secure key storage in production devices.
9-
10-
Only a subset of the PKCS #11 standard is implemented, with a focus on operations involving asymmetric keys, random number generation, and hashing.
11-
12-
The targeted use cases include certificate and key management for TLS authentication and code-sign signature verification, on small embedded devices.
13-
14-
corePKCS11 is implemented on PKCS #11 v2.4.0, the full PKCS #11 standard can be found on the [oasis website](http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html).
15-
16-
This library has gone through code quality checks including verification that no function has a [GNU Complexity](https://www.gnu.org/software/complexity/manual/complexity.html) score over 8, and checks against deviations from mandatory rules in the [MISRA coding standard](https://www.misra.org.uk). Deviations from the MISRA C:2012 guidelines are documented under [MISRA Deviations](MISRA.md). This library has also undergone both static code analysis from [Coverity static analysis](https://scan.coverity.com/) and validation of memory safety through the [CBMC automated reasoning tool](https://www.cprover.org/cbmc/).
17-
18-
See memory requirements for this library [here](./docs/doxygen/include/size_table.md).
19-
20-
**corePKCS11 v3.5.0 [source code](https://github.com/FreeRTOS/corePKCS11/tree/v3.5.0/source) is part of the [FreeRTOS 202210.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202210.00-LTS) release.**
21-
22-
**corePKCS11 v3.0.0 [source code](https://github.com/FreeRTOS/corePKCS11/tree/v3.0.0/source) is part of the [FreeRTOS 202012.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.00-LTS) release.**
3+
**[API Documentation Pages for current and previous releases of this library can be found here](https://freertos.github.io/corePKCS11/)**
4+
5+
[PKCS #11](https://en.wikipedia.org/wiki/PKCS_11) is a standardized and widely
6+
used API for manipulating common cryptographic objects. It is important because
7+
the functions it specifies allow application software to use, create, modify,
8+
and delete cryptographic objects, without ever exposing those objects to the
9+
application’s memory. For example, FreeRTOS AWS reference integrations use a
10+
small subset of the PKCS #11 API to, among other things, access the secret
11+
(private) key necessary to create a network connection that is authenticated and
12+
secured by the
13+
[Transport Layer Security (TLS)](https://en.wikipedia.org/wiki/Transport_Layer_Security)
14+
protocol – without the application ever ‘seeing’ the key.
15+
16+
The Cryptoki or PKCS #11 standard defines a platform-independent API to manage
17+
and use cryptographic tokens. The name, "PKCS #11", is used interchangeably to
18+
refer to the API itself and the standard which defines it.
19+
20+
This repository contains a software based mock implementation of the PKCS #11
21+
interface (API) that uses the cryptographic functionality provided by Mbed TLS.
22+
Using a software mock enables rapid development and flexibility, but it is
23+
expected that the mock be replaced by an implementation specific to your chosen
24+
secure key storage in production devices.
25+
26+
Only a subset of the PKCS #11 standard is implemented, with a focus on
27+
operations involving asymmetric keys, random number generation, and hashing.
28+
29+
The targeted use cases include certificate and key management for TLS
30+
authentication and code-sign signature verification, on small embedded devices.
31+
32+
corePKCS11 is implemented on PKCS #11 v2.4.0, the full PKCS #11 standard can be
33+
found on the
34+
[oasis website](http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html).
35+
36+
This library has gone through code quality checks including verification that no
37+
function has a
38+
[GNU Complexity](https://www.gnu.org/software/complexity/manual/complexity.html)
39+
score over 8, and checks against deviations from mandatory rules in the
40+
[MISRA coding standard](https://www.misra.org.uk). Deviations from the MISRA
41+
C:2012 guidelines are documented under [MISRA Deviations](MISRA.md). This
42+
library has also undergone both static code analysis from
43+
[Coverity static analysis](https://scan.coverity.com/) and validation of memory
44+
safety through the
45+
[CBMC automated reasoning tool](https://www.cprover.org/cbmc/).
46+
47+
See memory requirements for this library
48+
[here](./docs/doxygen/include/size_table.md).
49+
50+
**corePKCS11 v3.5.0
51+
[source code](https://github.com/FreeRTOS/corePKCS11/tree/v3.5.0/source) is part
52+
of the
53+
[FreeRTOS 202210.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202210.00-LTS)
54+
release.**
55+
56+
**corePKCS11 v3.0.0
57+
[source code](https://github.com/FreeRTOS/corePKCS11/tree/v3.0.0/source) is part
58+
of the
59+
[FreeRTOS 202012.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.00-LTS)
60+
release.**
2361

2462
# Purpose
2563

26-
Generally vendors for secure cryptoprocessors such as Trusted Platform Module ([TPM](https://en.wikipedia.org/wiki/Trusted_Platform_Module)), Hardware Security Module ([HSM](https://en.wikipedia.org/wiki/Hardware_security_module)), Secure Element, or any other type of secure hardware enclave, distribute a PKCS #11 implementation with the hardware.
27-
The purpose of the corePKCS11 software only mock library is therefore to provide a non hardware specific PKCS #11 implementation that allows for rapid prototyping and development before switching to a cryptoprocessor specific PKCS #11 implementation in production devices.
28-
29-
Since the PKCS #11 interface is defined as part of the PKCS #11 [specification](https://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html) replacing this library with another implementation should require little porting effort, as the interface will not change. The system tests distributed in this repository can be leveraged to verify the behavior of a different implementation is similar to corePKCS11.
64+
Generally vendors for secure cryptoprocessors such as Trusted Platform Module
65+
([TPM](https://en.wikipedia.org/wiki/Trusted_Platform_Module)), Hardware
66+
Security Module ([HSM](https://en.wikipedia.org/wiki/Hardware_security_module)),
67+
Secure Element, or any other type of secure hardware enclave, distribute a PKCS
68+
#11 implementation with the hardware. The purpose of the corePKCS11 software
69+
only mock library is therefore to provide a non hardware specific PKCS #11
70+
implementation that allows for rapid prototyping and development before
71+
switching to a cryptoprocessor specific PKCS #11 implementation in production
72+
devices.
73+
74+
Since the PKCS #11 interface is defined as part of the PKCS #11
75+
[specification](https://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html)
76+
replacing this library with another implementation should require little porting
77+
effort, as the interface will not change. The system tests distributed in this
78+
repository can be leveraged to verify the behavior of a different implementation
79+
is similar to corePKCS11.
3080

3181
## corePKCS11 Configuration
3282

33-
The corePKCS11 library exposes preprocessor macros which must be defined prior to building the library.
34-
A list of all the configurations and their default values are defined in the doxygen documentation for this library.
83+
The corePKCS11 library exposes preprocessor macros which must be defined prior
84+
to building the library. A list of all the configurations and their default
85+
values are defined in the doxygen documentation for this library.
3586

3687
## Build Prerequisites
88+
3789
### Library Usage
90+
3891
For building the library the following are required:
92+
3993
- **A C99 compiler**
40-
- **mbedcrypto** library from [mbedtls](https://github.com/ARMmbed/mbedtls) version 2.x or 3.x.
41-
- **pkcs11 API header(s)** available from [OASIS](https://github.com/oasis-tcs/pkcs11) or [OpenSC](https://github.com/OpenSC/libp11/blob/master/src/pkcs11.h)
94+
- **mbedcrypto** library from [mbedtls](https://github.com/ARMmbed/mbedtls)
95+
version 2.x or 3.x.
96+
- **pkcs11 API header(s)** available from
97+
[OASIS](https://github.com/oasis-tcs/pkcs11) or
98+
[OpenSC](https://github.com/OpenSC/libp11/blob/master/src/pkcs11.h)
4299

43-
Optionally, variables from the pkcsFilePaths.cmake file may be referenced if your project uses cmake.
100+
Optionally, variables from the pkcsFilePaths.cmake file may be referenced if
101+
your project uses cmake.
44102

45103
### Integration and Unit Tests
46-
In order to run the integration and unit test suites the following are dependencies are necessary:
104+
105+
In order to run the integration and unit test suites the following are
106+
dependencies are necessary:
107+
47108
- **C Compiler**
48109
- **CMake 3.13.0 or later**
49110
- **Ruby 2.0.0 or later** required by CMock.
50111
- **Python 3** required for configuring mbedtls.
51112
- **git** required for fetching dependencies.
52113
- **GNU Make** or **Ninja**
53114

54-
The *mbedtls*, *CMock*, and *Unity* libraries are downloaded and built automatically using the cmake FetchContent feature.
115+
The _mbedtls_, _CMock_, and _Unity_ libraries are downloaded and built
116+
automatically using the cmake FetchContent feature.
55117

56118
### Coverage Measurement and Instrumentation
119+
57120
The following software is required to run the coverage target:
121+
58122
- Linux, MacOS, or another POSIX-like environment.
59-
- A recent version of **GCC** or **Clang** with support for gcov-like coverage instrumentation.
123+
- A recent version of **GCC** or **Clang** with support for gcov-like coverage
124+
instrumentation.
60125
- **gcov** binary corresponding to your chosen compiler
61-
- **lcov** from the [Linux Test Project](https://github.com/linux-test-project/lcov)
126+
- **lcov** from the
127+
[Linux Test Project](https://github.com/linux-test-project/lcov)
62128
- **perl** needed to run the lcov utility.
63129

64130
Coverage builds are validated on recent versions of Ubuntu Linux.
@@ -68,65 +134,90 @@ Coverage builds are validated on recent versions of Ubuntu Linux.
68134
1. Navigate to the root directory of this repository in your shell.
69135

70136
1. Run **cmake** to construct a build tree: `cmake -S test -B build`
71-
- You may specify your preferred build tool by appending `-G'Unix Makefiles'` or `-GNinja` to the command above.
72-
- You may append `-DUNIT_TESTS=0` or `-DSYSTEM_TESTS=0` to disable Unit Tests or Integration Tests respectively.
137+
138+
- You may specify your preferred build tool by appending `-G'Unix Makefiles'`
139+
or `-GNinja` to the command above.
140+
- You may append `-DUNIT_TESTS=0` or `-DSYSTEM_TESTS=0` to disable Unit Tests
141+
or Integration Tests respectively.
73142

74143
1. Build the test binaries: `cmake --build ./build --target all`
75144

76-
1. Run `ctest --test-dir ./build` or `cmake --build ./build --target test` to run the tests without capturing coverage.
145+
1. Run `ctest --test-dir ./build` or `cmake --build ./build --target test` to
146+
run the tests without capturing coverage.
77147

78-
1. Run `cmake --build ./build --target coverage` to run the tests and capture coverage data.
148+
1. Run `cmake --build ./build --target coverage` to run the tests and capture
149+
coverage data.
79150

80151
## CBMC
81152

82-
To learn more about CBMC and proofs specifically, review the training material [here](https://model-checking.github.io/cbmc-training).
153+
To learn more about CBMC and proofs specifically, review the training material
154+
[here](https://model-checking.github.io/cbmc-training).
83155

84156
The `test/cbmc/proofs` directory contains CBMC proofs.
85157

86-
In order to run these proofs you will need to install CBMC and other tools by following the instructions [here](https://model-checking.github.io/cbmc-training/installation.html).
158+
In order to run these proofs you will need to install CBMC and other tools by
159+
following the instructions
160+
[here](https://model-checking.github.io/cbmc-training/installation.html).
87161

88162
## Reference examples
89163

90-
The FreeRTOS-Labs repository contains demos using the PKCS #11 library [here](https://github.com/FreeRTOS/FreeRTOS-Labs/tree/master/FreeRTOS-Plus/Demo/FreeRTOS_Plus_PKCS11_Windows_Simulator/examples) using FreeRTOS on the Windows simulator platform. These can be used as reference examples for the library API.
164+
The FreeRTOS-Labs repository contains demos using the PKCS #11 library
165+
[here](https://github.com/FreeRTOS/FreeRTOS-Labs/tree/master/FreeRTOS-Plus/Demo/FreeRTOS_Plus_PKCS11_Windows_Simulator/examples)
166+
using FreeRTOS on the Windows simulator platform. These can be used as reference
167+
examples for the library API.
91168

92169
## Porting Guide
93-
Documentation for porting corePKCS11 to a new platform can be found on the AWS [docs](https://docs.aws.amazon.com/freertos/latest/portingguide/afr-porting-pkcs.html) web page.
94170

95-
corePKCS11 is not meant to be ported to projects that have a TPM, HSM, or other hardware for offloading crypto-processing. This library is specifically meant to be used for development and prototyping.
171+
Documentation for porting corePKCS11 to a new platform can be found on the AWS
172+
[docs](https://docs.aws.amazon.com/freertos/latest/portingguide/afr-porting-pkcs.html)
173+
web page.
96174

175+
corePKCS11 is not meant to be ported to projects that have a TPM, HSM, or other
176+
hardware for offloading crypto-processing. This library is specifically meant to
177+
be used for development and prototyping.
97178

98179
## Related Example Implementations
99-
These projects implement the PKCS #11 interface on real hardware and have similar behavior to corePKCS11. It is preferred to use these, over corePKCS11, as they allow for offloading Cryptography to separate hardware.
100180

101-
* ARM's [Platform Security Architecture](https://github.com/Linaro/freertos-pkcs11-psa).
102-
* Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib).
103-
* Infineon's [Optiga Trust X](https://github.com/aws/amazon-freertos/blob/main/vendors/infineon/secure_elements/pkcs11/iot_pkcs11_trustx.c).
181+
These projects implement the PKCS #11 interface on real hardware and have
182+
similar behavior to corePKCS11. It is preferred to use these, over corePKCS11,
183+
as they allow for offloading Cryptography to separate hardware.
184+
185+
- ARM's
186+
[Platform Security Architecture](https://github.com/Linaro/freertos-pkcs11-psa).
187+
- Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib).
188+
- Infineon's
189+
[Optiga Trust X](https://github.com/aws/amazon-freertos/blob/main/vendors/infineon/secure_elements/pkcs11/iot_pkcs11_trustx.c).
104190

105191
## Documentation
106192

107193
### Existing Documentation
108-
For pre-generated documentation, please see the documentation linked in the locations below:
109194

110-
| Location |
111-
| :-: |
195+
For pre-generated documentation, please see the documentation linked in the
196+
locations below:
197+
198+
| Location |
199+
| :------------------------------------------------------------------------------------------------------------------: |
112200
| [AWS IoT Device SDK for Embedded C](https://github.com/aws/aws-iot-device-sdk-embedded-C#releases-and-documentation) |
113-
| [FreeRTOS.org](https://freertos.org/Documentation/api-ref/corePKCS11/docs/doxygen/output/html/index.html) |
201+
| [FreeRTOS.org](https://freertos.org/Documentation/api-ref/corePKCS11/docs/doxygen/output/html/index.html) |
114202

115-
Note that the latest included version of corePKCS11 may differ across repositories.
203+
Note that the latest included version of corePKCS11 may differ across
204+
repositories.
116205

117206
### Generating Documentation
207+
118208
The Doxygen references were created using Doxygen version 1.9.2. To generate the
119-
Doxygen pages, please run the following command from the root of this repository:
209+
Doxygen pages, please run the following command from the root of this
210+
repository:
120211

121212
```shell
122213
doxygen docs/doxygen/config.doxyfile
123214
```
124215

125216
## Security
126217

127-
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
218+
See [CONTRIBUTING](.github/CONTRIBUTING.md#security-issue-notifications) for more
219+
information.
128220

129221
## License
130222

131223
This library is licensed under the MIT-0 License. See the LICENSE file.
132-

0 commit comments

Comments
 (0)