Skip to content
This repository was archived by the owner on Apr 27, 2023. It is now read-only.

Commit 7cc6fe1

Browse files
committed
More updates
Signed-off-by: Michael Lodder <redmike7@gmail.com>
1 parent 99251b7 commit 7cc6fe1

File tree

1 file changed

+135
-11
lines changed

1 file changed

+135
-11
lines changed

enclave-interface/README.md

Lines changed: 135 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ The types of hardware-backed or virtual implementations envisaged are:
3939
1. Simple hardware-accelerations (AES-NI, HW RNGs, FPGAs)
4040
2. Personal HSMs (Yubikey, Ledger, smart card. Typically locally connected, single instance, simple integrated key management,
4141
OS keyrings like Mac OS X Keychain, Gnome-Keyring, KWallet, Windows Credential Manager)
42-
3. Enterprise HSMs (Thales, Iron Core Labs, nCipher, Utimaco, Securosys. May be network connected, multi-user and redundent configurations, complex key management with roles and access policies. Logging and auditing requirements)
43-
4. Cloud key management (Microsoft Azure KeyValut, Amazon AWS KMS, Hashicorp Vault, Box KeySafe)
44-
5. Trusted Execution Environments (Intel SGX, Microsoft CoCo, ARM Trustzone, RISC-V Multivisors, Unbound Key Control)
42+
3. Enterprise HSMs (Thales, Iron Core Labs, nCipher, Utimaco, Securosys, Jitsuin.
43+
May be network connected, multi-user and redundent configurations, complex key management with roles and access policies. Logging and auditing requirements)
44+
4. Cloud key management (Microsoft Azure KeyVault, Amazon AWS KMS, Hashicorp Vault, Box KeySafe)
45+
5. Trusted Execution Environments (Intel SGX, ARM Trustzone, RISC-V Multivisors, Unbound Key Control)
4546

4647
Use of each different type of implementation comes with its own unique set of security questions. Superficially a user
4748
may simply want to know **"is my crypto code running in a secure environment or hardware?"**, but for true security
@@ -56,7 +57,7 @@ it is necessary to verify many more of the details:
5657

5758
It is very important not to expose the details of the implementation through the API itself: it gets very messy, very quickly
5859
to try to accommodate all the small details of each potential implementation in a generic API. Instead, it is preferable
59-
to protide attestation commands that return provider-specific information which can be verified out-of-band.
60+
to provide attestation commands that return provider-specific information which can be verified out-of-band.
6061

6162
## Why can't we just invisibly use the encalve we find on our system?
6263

@@ -110,13 +111,14 @@ come in one of the following forms:
110111
1. Networked (HTTP, ethernet, bluetooth)
111112

112113
Therefore initial piece of the interface is the connection. Given each provider has different connection methods,
113-
the connection create process takes a configuration unique to that enclave.
114+
the connection create process takes a configuration unique to that enclave. The goal of this API design is to minimize
115+
changes to it to maintain compatibility.
114116

115117
We show all code samples written as Rust but can be adapted to other languages as desired.
116118

117119
Most hardware implementations will not allow key material to be passed through the API, even in encrypted form, so a system of external references is required that allows keys to be referenced in a way that supports:
118120
1. **Consistency** - The same ID refers to the same key every time (according to the key management paradigm of the underlying hardware)
119-
1. **Naming schemes** - Organizations often name their keys according to some formal naming scheme - such as **legal.europe.documetencryption.May2019-1**.
121+
1. **Naming schemes** - Organizations often name their keys according to some formal naming scheme - such as **legal.europe.documentencryption.May2019-1**.
120122
1. **Key blocks** - Some HSMs not only allow but actively require keys to be passed as formatted and encrypted keyblocks. In this case we not only need to support the simple data type of a binary key block but also (potentially) identify which KEK it's encrypted under.
121123

122124
In keeping with the drive for Ursa to be simple and hard to mess up, the proposal is to make KeyIDs in the Ursa interface be simple UTF-8 string names, and leave the underlying provider implementation to deal with the complexities of translation, key rollover, duplication and so on. Keyblocks will not be supported until really demanded.
@@ -130,7 +132,7 @@ pub trait EnclaveLike {
130132
/// Terminate the current session/context
131133
fn close(self);
132134
/// Get a list of capabilities supported by this enclave
133-
fn capabilities(&self) -> Result<Vec<EnclaveCapabilities>, Error>;
135+
fn capabilities(&self) -> Result<Vec<EnclaveOperation>, Error>;
134136
/// Create a new enclave key. Settings and key type and supported operations are
135137
/// defined in the `EnclaveCreateKeyOptions`.
136138
fn create_key(&self, options: EnclaveCreateKeyOptions) -> Result<EnclaveMessage, Error>;
@@ -174,7 +176,9 @@ pub enum EnclaveConnector {
174176
YubiHsm(YubiHsmConnector),
175177
SGX(SGXConnector),
176178
Trustzone(TrustzoneConnector),
177-
AwsKms(AwsKmsConnector)
179+
AwsKms(AwsKmsConnector),
180+
AzureKeyVault(AzureKeyVaultConnector),
181+
HashicorpVault(HashicorpConnector)
178182
}
179183
```
180184

@@ -222,19 +226,139 @@ pub enum YubiHsmConnector {
222226
}
223227
```
224228

225-
Once a `EnclaveConnector` has been defined, the connection is created. The connection enables the
229+
Once a `EnclaveConnector` has been defined, the connection is created. The connection enables all other operations.
230+
Enclave providers must be queryable for capabilities which can then be used by the caller to determine what its allowed
231+
to use. Common capabilities with existing enclaves are in the following rust code. These are not mutually exclusive
232+
```rust
233+
pub enum EnclaveOperation {
234+
DeriveDiffieHellman(DeriveParams),
235+
GenerateAsymmetricKey(GenerateAsymmetricParams),
236+
GenerateSymmetricKey(GenerateSymmetricParams),
237+
GenerateRandom(RandomParams),
238+
Attestation(AttestationParams),
239+
Sign(SigningParams),
240+
Verify(VerifyParams),
241+
Encrypt(EncryptParams),
242+
Decrypt(DecryptParams),
243+
DeleteKey(DeleteKeyParams),
244+
WrapKey(WrapParams),
245+
UnwrapKey(UnwrapParams),
246+
ExportWrappedKey(ExportWrappedParams),
247+
ImportWrappedKey(ImportWrappedParams),
248+
KeyInfo(KeyInfoParams),
249+
Audit(AuditParams),
250+
Log(LogParams),
251+
DeviceInfo
252+
}
253+
254+
pub enum DeriveParams {
255+
Pkcs3(Pkcs3Params),
256+
Ecdh(EcdhParams),
257+
Pq(PostQuantumParams)
258+
}
259+
260+
/// PKCS#3 parameters according to v1.4
261+
pub struct Pkcs3Params {
262+
/// Prime, must be 2048, 3072, 4096, 6144, or 8192
263+
p: Pkcs3DhP,
264+
/// Base
265+
g: BigNum,
266+
/// This enclave's key id
267+
id: String,
268+
/// Other's public key
269+
peer: BigNum
270+
}
271+
272+
/// Pkcs3 diffie hellman prime
273+
pub struct Pkcs3DhP {
274+
value: BigNum
275+
}
276+
277+
/// Elliptic Curve Diffie Hellman parameters
278+
pub struct EcdhParams {
279+
/// The curve to use
280+
curve: EccCurve,
281+
/// This enclave's key id
282+
id: String,
283+
/// Other's public key as an uncompressed point for curves that support compressed points
284+
/// typically is 57, 65, 97, 129, 133, 193 bytes
285+
peer: EcPoint
286+
}
287+
288+
/// Valid elliptic curves see https://eprint.iacr.org/2018/193.pdf
289+
/// and https://eprint.iacr.org/2005/133.pdf
290+
/// for information about BN and BLS curves
291+
pub enum EccCurve {
292+
/// Curve25519
293+
Curve25519,
294+
/// Curve41417
295+
Curve41417,
296+
/// Curve448 AKA Goldilocks
297+
Curve448,
298+
/// Barreto-Lynn-Scott embedding degree 12 with prime field 381 bits
299+
Bls381,
300+
/// Barreto-Lynn-Scott embedding degree 12 with prime field 461 bits
301+
Bls461,
302+
/// Barreto-Lynn-Scott embedding degree 24 with equivalent security of AES-192
303+
Bls24,
304+
/// Barreto-Lynn-Scott embedding degree 48 with equivalent security of AES-256 with 581 bit prime
305+
/// see https://tools.ietf.org/id/draft-kato-threat-pairing-01.html#rfc.section.3
306+
Bls48,
307+
/// Barreto Naehrig with prime field 254 bits. About 100 bits of security
308+
Bn254,
309+
/// Barreto Naehrig with prime field 256 bits. See https://cryptojedi.org/papers/dclxvi-20100714.pdf
310+
/// and https://moderncrypto.org/mail-archive/curves/2016/000740.html for more details
311+
BnP256,
312+
/// Barreto Naehrig with prime field 384 bits. See https://cryptojedi.org/papers/dclxvi-20100714.pdf
313+
BnP384,
314+
/// Barreto Naehrig with prime field 512 bits as specified in ISO15946-5
315+
BnP512,
316+
/// Barreto Naehrig with prime field 638 bits as specified in
317+
/// https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-ecdaa-algorithm-v2.0-rd-20180702.html#supported-curves-for-ecdaa
318+
BnP638,
319+
/// NIST P-224 (secp224r1)
320+
EcP224,
321+
/// NIST P-256 (secp256r1, prime256v1)
322+
EcP256,
323+
/// NIST P-384 (secp384r1)
324+
EcP384,
325+
/// NIST P-521 (secp521r1)
326+
EcP521,
327+
/// secp256k1
328+
EcK256,
329+
/// Brainpool 224
330+
EcBP224,
331+
/// BrainPool 256
332+
EcBP256,
333+
/// BrainPool 384
334+
EcBP384,
335+
/// BrainPool 512
336+
EcBP512,
337+
}
338+
```
339+
340+
Some capabilities offer multiple options like `DeriveDiffieHellman` which can be either PKCS#3 DHParameter structure
341+
or Elliptic-Curve based.
342+
343+
This model allows the flexibility to add new operations and types without changing the APIs.
344+
345+
Each operation will return an Enclave Message that contains the results or an error upon failure. For example,
346+
Encryption will return the ciphertext and possibly an authentication tag. Signing returns the signature.
226347

227348
# Drawbacks
228349
[drawbacks]: #drawbacks
229350
For developers intimately familiar with enclave programming, this API may be a more expensive/complicated scheme than
230351
using the methods they are already used to using. Care must be taken so this scheme does not change frequency with each
231352
enclave provider that is to be supported.
232353

354+
Another possibility is that this approach is too flexible and requires intimate knowledge about crypto algorithms.
355+
To mitigate this, predefined ciphers can be created for end consumers like RSA-3072-PSS-SHA256 or
356+
AES-256-GCM or AES-128-CBC-HMAC-SHA256 or XCHACHA20-POLY1305. This reduces algorithmic agility that is an inherent problem
357+
with many cryptographic libraries.
358+
233359
# Rationale and alternatives
234360
[alternatives]: #alternatives
235361

236-
237-
238362
# Prior art
239363
[prior-art]: #prior-art
240364
This provider model is extremely common in the crypto world with implementations like [PKCS11](http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html)

0 commit comments

Comments
 (0)