Julian Hall | 7b59462 | 2022-04-08 14:04:15 +0100 | [diff] [blame] | 1 | Crypto Service |
| 2 | ============== |
| 3 | Overview |
| 4 | -------- |
Julian Hall | e76ade8 | 2020-11-25 03:07:21 +0100 | [diff] [blame] | 5 | The Crypto service provides a rich set of cryptographic operations with the backing |
| 6 | of a private key store. Clients identify keys using opaque key handles, enabling |
| 7 | cryptographic operations to be performed without exposing key values beyond the |
| 8 | boundary of the service's secure processing environment. This pattern underpins |
| 9 | the security guarantees offered by the Crypto service. |
| 10 | |
| 11 | The set of supported operations is aligned to the PSA Crypto API. C API functions |
| 12 | are invoked by clients using the Crypto service access protocol. All types and values |
| 13 | defined by the PSA Crypto C API are projected by the Crypto access protocol. The |
| 14 | one-to-one mapping between the C API and Crypto access protocol allows developers |
| 15 | to use PSA Crypto documentation and examples to understand details of the protocol. |
| 16 | |
| 17 | Supported operations fall into the following categories: |
| 18 | |
| 19 | * Key lifetime management |
| 20 | * Message signing and signature verification |
| 21 | * Asymmetric encryption/decryption |
| 22 | * Random number generation |
| 23 | |
| 24 | Service Provider Implementation |
| 25 | ------------------------------- |
| 26 | The default crypto service provider uses the Mbed Crypto library to implement backend |
| 27 | operations. The following diagram illustrates the component dependencies in the crypto |
| 28 | service provider implementation (note that there are many more handlers than |
| 29 | illustrated): |
| 30 | |
| 31 | .. uml:: uml/CryptoProviderClassDiagram.puml |
| 32 | |
| 33 | The packages illustrated reflect the partitioning of the code into separate directories. |
| 34 | Functionality is partitioned as follows: |
| 35 | |
| 36 | Crypto Provider |
| 37 | ''''''''''''''' |
| 38 | Implements the set of handlers that map incoming RPC call requests to PSA Crypto API |
| 39 | function calls. A separate handler function exists for each operation supported by the |
| 40 | service. |
| 41 | |
| 42 | Crypto Serializer |
| 43 | ''''''''''''''''' |
| 44 | Incoming call request parameters are de-serialized and response parameters serialized |
| 45 | by a serializer. The trusted services framework allows for the use of alternative |
| 46 | serializers to support different parameter encoding schemes. |
| 47 | |
| 48 | Mbed Crypto |
| 49 | ''''''''''' |
| 50 | All cryptographic operations are handled by an instance of the Mbed Crypto library. |
| 51 | The library is built with a specific configuration that creates dependencies on the |
| 52 | following: |
| 53 | |
| 54 | * PSA ITS API for persistent key storage |
| 55 | * External entropy source |
| 56 | |
| 57 | Secure Storage |
| 58 | '''''''''''''' |
| 59 | Persistent storage of keys is handled by an instance of the Secure Storage service. |
| 60 | The service is accessed via a client that presents the PSA ITS API at its upper edge. |
| 61 | This is needed for compatibility with Mbed Crypto. As long as it meets security |
| 62 | requirements, any Secure Storage service provider may be used. An RPC session between |
| 63 | the Crypto and Secure Storage service providers is established during initialization |
| 64 | and is maintained for the lifetime of the Crypto service provider. |
| 65 | |
| 66 | Entropy Source |
| 67 | '''''''''''''' |
| 68 | Certain cryptographic operations, such as key generation, require use of a |
| 69 | cryptographically secure random number generator. To allow a hardware TRNG to be used, |
| 70 | the Mbed Crypto library is configured to use an externally provided entropy source. |
| 71 | Any deployment of the service provider must include an implementation of the following |
| 72 | function:: |
| 73 | |
| 74 | int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen) |
| 75 | |
| 76 | For production deployments, an implementation of this function should be provided that |
| 77 | obtains the requested bytes of entropy from a suitable source. To allow the Crypto |
| 78 | service to be used where no hardware backed implementation is available, a software |
| 79 | only implementation is provided. |
| 80 | |
| 81 | -------------- |
| 82 | |
Julian Hall | 7b59462 | 2022-04-08 14:04:15 +0100 | [diff] [blame] | 83 | *Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.* |
Julian Hall | e76ade8 | 2020-11-25 03:07:21 +0100 | [diff] [blame] | 84 | |
| 85 | SPDX-License-Identifier: BSD-3-Clause |