Questions about crypto support
Hi everybody,
In the last SVSM meeting we started to discuss some design questions related to crypto support and I mentioned that I could open a github issue for us to continue the discussion. However, I have the impression that mailing lists have worked better for discussions. Let me know if this is not the case.
Since the crypto support questions applies directly to the context of vTPM and attestation, I also added a block diagram below to help us visualize the big picture.
Feel free to add new questions or information that you find relevant.
Thanks,
Claudio
Questions
---------
Q1) FIPS 140 certification. Should we consider OpenSSL as a static or shared library?
Q2) How should we handle build dependencies between CPL3 modules? E.g. the vTPM (Microsoft TPM impl.) build depends on the OpenSSL library.
Q3) What libc implementation should we use to build OpenSSL and other CPL3 modules?
Q4) Interface 1. How CPL0 code should communicate with CPL3 code?
Q5) Interface 2. CPL0 to CPL3 communication may need to carry secrets (e.g. VMPCK0 key), how should we do that securely?
Q6) Interface 3. How a CPL3 module should communicate with other CPL3 modules? It may also need to carry secrets such as keys.
Appendix 1: vTPM and attestation as a use case
----------------------------------------------
.-------------. .-------------.
| Runtime | | Attestation |
-------->| Protocols |---->| Report |
'-------------' '-------------'
| |
| v
| .------------.
| | Crypto API |-----.
| '------------' v
| .------.
Interface 1 | ossl |
| '------'
| |
CPL0 | Interface 2
|-------------------------------------------|-------|
CPL3 | |
| |
v v
.------------. .---------.
| vTPM | | OpenSSL |
| Module |----Interface 3---->| Module |
'------------' '---------'A1-1) CPL0: Runtime Protocols
-----------------------------
SVSM protocols described in the SVSM spec:
- Core
- Attestation
- vTPM
A1-2) CPL0: Attestation Report
------------------------------
Implements the attestation report feature. When a VMPL0 attestation report is requested, the request needs to be encrypted/decrypted with the VMPCK0 key using AES-GCM.
A1-3) CPL0: Crypto API
----------------------
SVSM kernel interface (Rust trait) that abstracts the crypto module running in CPL3.
Example in pseudo-code:
aes_gcm_encrypt(key, iv, aad, cleartext, ciphertext, authtag) aes_gcm_decrypt(key, iv, aad, ciphertext, authtag, cleartext)
A1-4) CPL0: ossl
----------------
Crypto API implementation (wrappers) for OpenSSL.
A1-5) CPL3: vTPM Module
-----------------------
Microsoft TPM 2.0 reference (ms-tpm-20-ref) implementation; only the TPM Simulator interface is exported.
The ms-tpm-20-ref build requires OpenSSL (or WolfSSL).
A1-6) CPL3: OpenSSL Module
--------------------------
OpenSSL library built to run in the restricted SVSM environment. Summary of the build steps we have used (inspired on how OVMF builds OpenSSL):
- create a svsm_openssl.config that sets some compiler flags and inherited configs.
- disable crypto modules not needed
- reduce memory footprint
- link it against the libcrt library, which is a small libc we crafted to build OpenSSL (libcrt) and the Microsoft TPM.
Quoted 12 lines · Claudio Carvalho
Hi everybody,
In the last SVSM meeting we started to discuss some design questions related to crypto support and I mentioned that I could open a github issue for us to continue the discussion. However, I have the impression that mailing lists have worked better for discussions. Let me know if this is not the case.
Since the crypto support questions applies directly to the context of vTPM and attestation, I also added a block diagram below to help us visualize the big picture.
Quoted 8 lines
Feel free to add new questions or information that you find relevant.
Thanks,
ClaudioQuestions
---------
Forgive me if my answers wrt CPL0 and CPL3 are full of misconceptions about how SVSM plans to implement this support. I'm quite new here.
Quoted 4 lines
Q1) FIPS 140 certification. Should we consider OpenSSL as a static or shared library?
Is there a plan for dynamic linking support for shared libraries to be possible in SVSM? I would think everything is going to be statically linked, loaded as part of the boot image, and not even position-independent.
Quoted 3 lines
Q2) How should we handle build dependencies between CPL3 modules? E.g. the vTPM (Microsoft TPM impl.) build depends on the OpenSSL library.
Different CPL3 modules will be have their own CR3 values, right? Unless you develop an library envelope service to turn library calls into RPCs across process boundaries, I would guess everything needs to just be duplicated with static linking.
Quoted 8 lines
Q3) What libc implementation should we use to build OpenSSL and other CPL3 modules?
Q4) Interface 1. How CPL0 code should communicate with CPL3 code?
Q5) Interface 2. CPL0 to CPL3 communication may need to carry secrets (e.g. VMPCK0 key), how should we do that securely?
I think that whichever CPL3 module(s) that will handle VMPCK0 will need to be hardcoded such that only specific vetted code is allowed to have that data copied into its context. That code is trusted to manage that key material correctly and destroy it after use. I wouldn't want that access to be arbitrarily available.
Quoted 3 lines
Q6) Interface 3. How a CPL3 module should communicate with other CPL3 modules? It may also need to carry secrets such as keys.
I don't expect a full VFS system to make shared memory a thing to implement IPC. I would imagine that you would send messages to different modules by handing a buffer and a module identifier to CPL0 to go deliver to that module's mailbox and return success, mailbox full & try again later, or message too large.
Quoted 62 lines
Appendix 1: vTPM and attestation as a use case
----------------------------------------------.-------------. .-------------. | Runtime | | Attestation | -------->| Protocols |---->| Report | '-------------' '-------------' | | | v | .------------. | | Crypto API |-----. | '------------' v | .------. Interface 1 | ossl | | '------' | | CPL0 | Interface 2 |-------------------------------------------|-------| CPL3 | | | | v v .------------. .---------. | vTPM | | OpenSSL | | Module |----Interface 3---->| Module | '------------' '---------'A1-1) CPL0: Runtime Protocols
-----------------------------SVSM protocols described in the SVSM spec:
- Core
- Attestation
- vTPMA1-2) CPL0: Attestation Report
------------------------------Implements the attestation report feature. When a VMPL0 attestation report is requested, the request needs to be encrypted/decrypted with the VMPCK0 key using AES-GCM.
A1-3) CPL0: Crypto API
----------------------SVSM kernel interface (Rust trait) that abstracts the crypto module running in CPL3.
Example in pseudo-code:
aes_gcm_encrypt(key, iv, aad, cleartext, ciphertext, authtag)aes_gcm_decrypt(key, iv, aad, ciphertext, authtag, cleartext)A1-4) CPL0: ossl
----------------Crypto API implementation (wrappers) for OpenSSL.
A1-5) CPL3: vTPM Module
-----------------------
Quoted 8 lines
Microsoft TPM 2.0 reference (ms-tpm-20-ref) implementation; only the TPM Simulator interface is exported.
The ms-tpm-20-ref build requires OpenSSL (or WolfSSL).
A1-6) CPL3: OpenSSL Module
--------------------------
Big organizations will have their pet crypto libraries they'll prefer. We'll need dedicated maintainers from each one if we're going to strive for compatibility, or we run the risk of forks and separately vendored binaries.
I'm very interested what people are thinking in terms of binary distributions and co-endorsement of verified builds, since signatures are so much easier to work with operationally than always verifying an attestation's measurement back through a transparent build process.
WRT source -> measurement transparency, Google has been working on slsa.dev for build security, provenance tracking and verifiable build artifacts, and Project Oak has a transparent release project to tie sources + toolchain container through to the slsa artifact that gets signed and added to the sigstore.dev repository of build artifacts. A fork is a big deal due to the downstream effects that has on auditors of this code as it flows through a transparency toolchain. We'll need a approach transparently built binaries of the favored varieties (crypto library x,y,z crossed with TPM simulator x,yz) as "public good" work, further with the community's agreement about which toolchain containers are trustworthy. Google Cloud build doesn't quite hit the SLSA L3 target we'd like with their container marketplace, so I'm still running that one down.
Quoted 8 lines
OpenSSL library built to run in the restricted SVSM environment. Summary of the build steps we have used (inspired on how OVMF builds OpenSSL):
- create a svsm_openssl.config that sets some compiler flags and inherited configs.
- disable crypto modules not neededFrom my understanding of FIPS 140-2 certification, the process
involves a 100% audit of all of the machine code, and for organizations like Google, it's best to not mess with the linked object. We're locked into a 2MiB blob for all crypto operations done in any regulated workload. This bloat-shedding is typically not worth the annual O($300,000) cost of recertification.
Quoted 3 lines
- reduce memory footprint
- link it against the libcrt library, which is a small libc we crafted to build OpenSSL (libcrt) and the Microsoft TPM.
I'm not particularly familiar with libcrt. Do you have a link to the project? How healthy is it?
There's also the nanolibc project Google has for similar situations (which I'm not suggesting we use. It has exactly 1 commit by Bill Cox–solid guy working in sealed computing, but busy).
I'm not saying this for tribal reasons, more that I'm not sure who's responsible for maintenance of all these dependencies, their reputation or level of qualification, and that makes the enterprise tech leaders I need to discuss risks to... itchy.
Quoted 4 lines
--
Svsm-devel mailing list
[email protected]
https://mail.8bytes.org/cgi-bin/mailman/listinfo/svsm-devel
--
-Dionna Glaze, PhD (she/her)
Quoted 30 lines · Dionna Amalie Glaze
Quoted 15 lines · Claudio Carvalho
Hi everybody,
In the last SVSM meeting we started to discuss some design questions related to
crypto support and I mentioned that I could open a github issue for us to continue the discussion. However, I have the impression that mailing lists have
worked better for discussions. Let me know if this is not the case.Since the crypto support questions applies directly to the context of vTPM and
attestation, I also added a block diagram below to help us visualize the big picture.Quoted 8 lines
Feel free to add new questions or information that you find relevant.
Thanks,
ClaudioQuestions
---------Forgive me if my answers wrt CPL0 and CPL3 are full of misconceptions about how SVSM plans to implement this support. I'm quite new here.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Q1) FIPS 140 certification. Should we consider OpenSSL as a static or shared library?
Is there a plan for dynamic linking support for shared libraries to be possible in SVSM? I would think everything is going to be statically linked, loaded as part of the boot image, and not even position-independent.
We have used FIPS 140 certification as one criterion to choose between crypto libraries and approaches. However, multiple questions popped up on how difficult would be to certify OpenSSL. So I added this question.
The aspect we started to discuss is if the OpenSSL should be built as a static or shared library. If we are concerned about FIPS 140, the recommendation is to use an OpenSSL version that has been FIPS validated, such as [1].
[1] says that the OpenSSL FIPS provider is a shared library (fips.so). IIUC, it would be complicated to support a Linux shared library in the SVSM. On the other hand, certifying any static crypto library would also be complicated.
Other aspects about FIPS 140:
- The same problem also exists for OVMF since it also builds its own crypto library (OpenSSL).
- Even if we use a FIPS validated crypto, we still need to make sure that the consumers will support it. IIUC, the Microsoft TPM implementation does not support a FIPS validated OpenSSL.
My impression is that FIPS 140 is a complicated problem when it comes to firmware and it seems too big to be considered now. I would like to hear what you guys think about that and if CPL0 should have it's own crypto (e.g. RustCrypto) in order to simplify the design. At the moment, the only crypto requirement we have for CPL0 code is AES_GCM, which is required by the attestation report feature.
[1] - Latest FIPS validated OpenSSL -
https://github.com/openssl/openssl/blob/openssl-3.0.8/README-FIPS.md
Quoted 31 lines
Quoted 5 lines
Q2) How should we handle build dependencies between CPL3 modules? E.g. the vTPM
(Microsoft TPM impl.) build depends on the OpenSSL library.Different CPL3 modules will be have their own CR3 values, right? Unless you develop an library envelope service to turn library calls into RPCs across process boundaries, I would guess everything needs to just be duplicated with static linking.
Quoted 8 lines
Q3) What libc implementation should we use to build OpenSSL and other CPL3 modules?
Q4) Interface 1. How CPL0 code should communicate with CPL3 code?
Q5) Interface 2. CPL0 to CPL3 communication may need to carry secrets (e.g. VMPCK0 key), how should we do that securely?
I think that whichever CPL3 module(s) that will handle VMPCK0 will need to be hardcoded such that only specific vetted code is allowed to have that data copied into its context. That code is trusted to manage that key material correctly and destroy it after use. I wouldn't want that access to be arbitrarily available.
Quoted 4 lines
Q6) Interface 3. How a CPL3 module should communicate with other CPL3 modules?
It may also need to carry secrets such as keys.
Quoted 6 lines
I don't expect a full VFS system to make shared memory a thing to implement IPC. I would imagine that you would send messages to different modules by handing a buffer and a module identifier to CPL0 to go deliver to that module's mailbox and return success, mailbox full & try again later, or message too large.
Jorg mentioned that IPC could be an option for communication between CPL3 modules, but then James mentioned that crypto operations may not perform well over IPC. I added this question to check if we need to revisit this.
Quoted 117 lines
Quoted 64 lines
Appendix 1: vTPM and attestation as a use case
----------------------------------------------.-------------. .-------------.
| Runtime | | Attestation | -------->| Protocols |---->| Report | '-------------' '-------------' | | | v | .------------. | | Crypto API |-----. | '------------' v | .------. Interface 1 | ossl | | '------' | | CPL0 | Interface 2 |-------------------------------------------|-------| CPL3 | | | | v v .------------. .---------. | vTPM | | OpenSSL | | Module |----Interface 3---->| Module |'------------' '---------'
A1-1) CPL0: Runtime Protocols
-----------------------------SVSM protocols described in the SVSM spec:
- Core
- Attestation
- vTPMA1-2) CPL0: Attestation Report
------------------------------Implements the attestation report feature. When a VMPL0 attestation report is
requested, the request needs to be encrypted/decrypted with the VMPCK0 key using AES-GCM.A1-3) CPL0: Crypto API
----------------------SVSM kernel interface (Rust trait) that abstracts the crypto module running in
CPL3.Example in pseudo-code:
aes_gcm_encrypt(key, iv, aad, cleartext, ciphertext, authtag)aes_gcm_decrypt(key, iv, aad, ciphertext, authtag, cleartext)A1-4) CPL0: ossl
----------------Crypto API implementation (wrappers) for OpenSSL.
A1-5) CPL3: vTPM Module
-----------------------Quoted 8 lines
Microsoft TPM 2.0 reference (ms-tpm-20-ref) implementation; only the TPM Simulator interface is exported.
The ms-tpm-20-ref build requires OpenSSL (or WolfSSL).
A1-6) CPL3: OpenSSL Module
--------------------------Big organizations will have their pet crypto libraries they'll prefer. We'll need dedicated maintainers from each one if we're going to strive for compatibility, or we run the risk of forks and separately vendored binaries.
I'm very interested what people are thinking in terms of binary distributions and co-endorsement of verified builds, since signatures are so much easier to work with operationally than always verifying an attestation's measurement back through a transparent build process.
WRT source -> measurement transparency, Google has been working on slsa.dev for build security, provenance tracking and verifiable build artifacts, and Project Oak has a transparent release project to tie sources + toolchain container through to the slsa artifact that gets signed and added to the sigstore.dev repository of build artifacts. A fork is a big deal due to the downstream effects that has on auditors of this code as it flows through a transparency toolchain. We'll need a approach transparently built binaries of the favored varieties (crypto library x,y,z crossed with TPM simulator x,yz) as "public good" work, further with the community's agreement about which toolchain containers are trustworthy. Google Cloud build doesn't quite hit the SLSA L3 target we'd like with their container marketplace, so I'm still running that one down.
Quoted 7 lines
OpenSSL library built to run in the restricted SVSM environment. Summary of the
build steps we have used (inspired on how OVMF builds OpenSSL):- create a svsm_openssl.config that sets some compiler flags and inherited configs.
- disable crypto modules not neededFrom my understanding of FIPS 140-2 certification, the process involves a 100% audit of all of the machine code, and for organizations like Google, it's best to not mess with the linked object. We're locked into a 2MiB blob for all crypto operations done in any regulated workload. This bloat-shedding is typically not worth the annual
O($300,000)cost of recertification.Quoted 4 lines
- reduce memory footprint
- link it against the libcrt library, which is a small libc we crafted to build
OpenSSL (libcrt) and the Microsoft TPM.
Quoted 9 lines
I'm not particularly familiar with libcrt. Do you have a link to the project? How healthy is it?
There's also the nanolibc project Google has for similar situations (which I'm not suggesting we use. It has exactly 1 commit by Bill Cox–solid guy working in sealed computing, but busy).
I'm not saying this for tribal reasons, more that I'm not sure who's responsible for maintenance of all these dependencies, their reputation or level of qualification, and that makes the enterprise tech leaders I need to discuss risks to... itchy.
Libcrt is a libc implementation we created for the SVSM-vTPM proof-of-concept we developed some time ago [2]. It is subset of musl + some OVMF stubs that we put together to easily build OpenSSL and the Microsoft TPM. However, with CPL3 support, we may want to have more complete libc implementation.
[2] Libcrt - https://github.com/svsm-vtpm/libcrt
Claudio
Quoted 10 lines
Quoted 5 lines
--
Svsm-devel mailing list
[email protected]
https://mail.8bytes.org/cgi-bin/mailman/listinfo/svsm-devel--
-Dionna Glaze, PhD (she/her)
Quoted 6 lines · Claudio Carvalho
My impression is that FIPS 140 is a complicated problem when it comes to firmware and it seems too big to be considered now. I would like to hear what you guys think about that and if CPL0 should have it's own crypto (e.g. RustCrypto) in order to simplify the design. At the moment, the only crypto requirement we have for CPL0 code is
AES_GCM, which is required by the attestation report feature.
Agreed, we do not make any decision here yet. Lets start simple and get vTPM support in CPL3 up and running. Once that is done we can start improving and extending things as we see need.
Regards,
Joerg
Hi Dionna,
Quoted 4 lines · Dionna Amalie Glaze
Is there a plan for dynamic linking support for shared libraries to be possible in SVSM? I would think everything is going to be statically linked, loaded as part of the boot image, and not even position-independent.
So yes, everything is part of the boot image, as it contains the archive for the RamFS, with all module binaries in it. But from a conceptual level we can support shared linking. The requirement came from the fact that FIPS certification is done on binaries, not source code. So we like to get to a situation where we can ship crypto support for all modules in a single binary, be it a RPC based module or a shared library.
Quoted 2 lines
I don't expect a full VFS system to make shared memory a thing to implement IPC.
Well, we are almost there already. The RamFS implementation builds on reference-counted page allocations which allow easy sharing of pages. And the upcoming VMM support also has the idea of shared mappings built in.
Quoted 4 lines
I would imagine that you would send messages to different modules by handing a buffer and a module identifier to CPL0 to go deliver to that module's mailbox and return success, mailbox full & try again later, or message too large.
I would appreciate something more clever than copying data around for IPC. Since the SVSM is very modularized there will protentially be a lot IPC and that should not be too big of a bottleneck. Doing IPC using shared memory is certainly a good start thinking about this.
Regards,
Joerg
Hi Claudio,
Quoted 2 lines · Claudio Carvalho
Q1) FIPS 140 certification. Should we consider OpenSSL as a static or shared library?
We are flexible on that, we can start with statically linking OpenSSL and then move on and support it as a shared lib. This does not touch the SVSM core much beyond the fact that it needs support for shared mappings. For shared we can also use a simplified approach like James suggested in the last meeting.
Quoted 2 lines
Q2) How should we handle build dependencies between CPL3 modules? E.g. the vTPM (Microsoft TPM impl.) build depends on the OpenSSL library.
That makes me think again about the requirements for our build system.
Quoted 2 lines
Q3) What libc implementation should we use to build OpenSSL and other CPL3 modules?
What amount of libc does openssl need? Or how much is it beyond malloc/free? Whatever libc we chose, some porting efforts to the SVSM syscall interface will be needed.
Quoted 1 line
Q4) Interface 1. How CPL0 code should communicate with CPL3 code?
The answer here is via a TBD IPC mechanism.
Quoted 2 lines
Q5) Interface 2. CPL0 to CPL3 communication may need to carry secrets (e.g. VMPCK0 key), how should we do that securely?
There are various ways to do this, one is via IPC with a kernel service and a capabilities system that restricts access to the secrets.
Another idea that was discussed is doing it via files. The filesystem implementation in the SVSM does not have a concept of a CWD, so there are no . and .. directories.
We can give every module a separate root directory and link the secrets it needs to access into that directory.
But none of this is decided yet.
Quoted 2 lines
Q6) Interface 3. How a CPL3 module should communicate with other CPL3 modules? It may also need to carry secrets such as keys.
For secrets like the VMPCK keys there should be a single owner, or do you see a need to pass those around? Besides secrets, communication will be done via the TBD IPC mechanism.
As it is still TBD, I am open for design ideas.
Regards,
Joerg
Quoted 6 lines
Quoted 2 lines
Q3) What libc implementation should we use to build OpenSSL and other CPL3 modules?
What amount of libc does openssl need? Or how much is it beyond malloc/free? Whatever libc we chose, some porting efforts to the SVSM syscall interface will be needed.
edk2 essentially has the same problem, and it is solved by building with --taget=UEFI plus a combination of #defines and stubs and efi-specific implementations.
Details are here:
* https://github.com/tianocore/edk2/tree/master/CryptoPkg/Library/Include
(where CrtLibSupport.h is the most interesting file)
* https://github.com/tianocore/edk2/blob/master/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
* https://github.com/tianocore/edk2/tree/master/CryptoPkg/Library/OpensslLib/OpensslStub
There also is
https://github.com/tianocore/edk2/tree/master/CryptoPkg/Library/IntrinsicLib
to provide an implementation for the compiler intrinsics generated by gcc.
take care,
Gerd
Quoted 7 lines
Quoted 2 lines
Q3) What libc implementation should we use to build OpenSSL and other CPL3 modules?
What amount of libc does openssl need? Or how much is it beyond malloc/free? Whatever libc we chose, some porting efforts to the SVSM syscall interface will be needed.
I've written some stubs to enable the crypto components of BoringSSL (trimmed-down OpenSSL) in a nostdlib environment, and it's not insignificant.
There are a number of string manipulation functions, of course malloc/free, and also pthread_once and pthread_key_* functions. Without pthreads, you have to build with -DOPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED I don't know what the concurrency story is for SVSM, but I imagine it's concurrent for all vCPUs to use without a global lock.
Quoted 8 lines
Quoted 3 lines
Q6) Interface 3. How a CPL3 module should communicate with other CPL3 modules? It may also need to carry secrets such as keys.
For secrets like the VMPCK keys there should be a single owner, or do you see a need to pass those around? Besides secrets, communication will be done via the TBD IPC mechanism.
VMPCKs may have a single conceptual owner, but they'll still need to be used in cryptographic operations, so I do see them getting passed around.
Signature · 1 line
-Dionna Glaze, PhD (she/her)
Hi Dionna,
Quoted 6 lines · Dionna Amalie Glaze
There are a number of string manipulation functions, of course malloc/free, and also
pthread_onceand pthread_key_* functions. Without pthreads, you have to build with -DOPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED I don't know what the concurrency story is for SVSM, but I imagine it's concurrent for all vCPUs to use without a global lock.
Ugh, pthreads, that is bit harder to support right now as SVSM will start with cooperative scheduling. Given that we only need the bare crypto functionality and none of the protocols or file parsing functionality I wonder what the pthread calls are used for.
The concurrency story for SVSM is still very simple, I already mentioned cooperative scheduling. Besides that we don't have a facility yet to force another VCPU into VMPL0 to execute threads there. Same with timers to implement preemptive scheduling.
Quoted 3 lines
VMPCKs may have a single conceptual owner, but they'll still need to be used in cryptographic operations, so I do see them getting passed around.
We can encapsulate that into a module which talks to the PSP. AFAIR the commands have sequence numbers, and that module would also keep track of them. Any other module sending requests would format and send them to the PSP communication module. That would then also be the single owner of the VMPCK0 key.
Regards,
Signature · 10 lines
Jörg Rödel [email protected] SUSE Software Solutions Germany GmbH Frankenstraße 146 90461 Nürnberg Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman