The following transfer a key from TPM-A to TPM-B and demonstrates policies that prevent further duplication to TPM-C
ref:
| import google.auth | |
| from google.oauth2 import service_account | |
| from google.cloud import storage | |
| from google.cloud import pubsub_v1 | |
| ## requirements.txt | |
| # google-cloud-storage | |
| # google-cloud-pubsub | |
| # requests | |
| # google-api-python-client |
The following transfer a key from TPM-A to TPM-B and demonstrates policies that prevent further duplication to TPM-C
ref:
The following diff extracts the EKM value for a given TLS connection and then surfaces that to LUA (which emits the EKM as a header to the backend)
the LUA config will log the EKM in trace logs
# envoy -c envoy_server.yaml -l trace
[2025-04-04 08:36:29.396][3334775][info][lua] [source/extensions/filters/common/lua/lua.cc:26] script log: >>>>>>>>>>>> EKM: XGurfnlqXyjXphhJrrCmHRoKXAwC7CjrD7vixHdqOIo=
which has the same derived EKM value as a sample client app (eg, golang)
also see https://github.com/salrashid123/go_ekm_tls
$ gcc server.c -lcrypto -lssl -o server
$ ./server Requires openssl-tpm2 provider
# export OPENSSL_MODULES=/usr/lib/x86_64-linux-gnu/ossl-modules/
#
# cat /etc/ssl/openssl.cnf
# [openssl_init]| package main | |
| /* | |
| Authenticate to GCP using the GCP embedded vTPM AttestationKey | |
| this specific implementation acquires a JWTAccessToken with scopes | |
| https://github.com/salrashid123/gcp-vtpm-ek-ak/tree/main?tab=readme-ov-file#sign-jwt-with-tpm | |
| 1. first create a gce instance with confidentialcompute and vtpm enabled |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <string.h> | |
| #include <sys/socket.h> | |
| #include <arpa/inet.h> | |
| #include <openssl/ssl.h> | |
| #include <openssl/err.h> | |
| #include <openssl/hmac.h> |
| package main | |
| import ( | |
| "crypto/sha256" | |
| "encoding/base64" | |
| "fmt" | |
| ) | |
| // JWT Thumprint: https://datatracker.ietf.org/doc/draft-ietf-cose-dilithium/ | |
| // Appendix A. Examples |
also see
$ gcc server.c -lcrypto -lssl -o server
k$ ./server