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