Skip to content

Instantly share code, notes, and snippets.

@salrashid123
salrashid123 / awsgolang.md
Last active June 24, 2024 15:52
[golang] using AWS_WEB_IDENTITY_TOKEN_FILE with google workload identity federation
@salrashid123
salrashid123 / workload_identity_aws.md
Last active June 24, 2024 15:35
[python] using AWS_WEB_IDENTITY_TOKEN_FILE with google workload identity federation
@salrashid123
salrashid123 / keyfile.md
Last active June 11, 2024 13:40
go-tpm-files save/load from persistent handle
  • crate prmiary

  • create key

  • evict primary to persistent handle 0x81000000

  • save key with go-tpm-keyfiles

  • load key using go-tpm-keyfile

module main
@salrashid123
salrashid123 / tpm2_createprimary_h2.md
Created May 31, 2024 22:16
tpm2 primarykey for (eg TCG EK Credential Profile H-2 profile
@salrashid123
salrashid123 / tpm2_hmac_pcr_policy.md
Last active June 2, 2024 18:24
tpm2_hmac with pcr policy

seal an external hmac key to a tpm with a PCR policy

export secret="change this password to a secret"
export plain="foo"
echo -n $secret > hmac.key
hexkey=$(xxd -p -c 256 < hmac.key)
echo $hexkey
echo -n $plain > data.in
openssl dgst -sha256 -mac hmac -macopt hexkey:$hexkey data.in
@salrashid123
salrashid123 / go-tpm-gokeyfile.md
Created May 30, 2024 16:49
go-tpm-tools compatibility with go-tpm-keyfile and go-tpm

sample demonstrating cross-usage/compatiblity between

go-tpm go-tpm-keyfile go-tpm-tools

package main
@salrashid123
salrashid123 / keyfilepermanent.md
Created May 26, 2024 16:19
TPM Keyfile with permanent handle
@salrashid123
salrashid123 / iap_jwtaccesstoken.go
Last active May 21, 2024 17:57
self-signed jwt access to google cloud iap
/*
self-signed jwt access to google cloud iap
https://cloud.google.com/iap/docs/authentication-howto#authenticating_with_a_self-signed_jwt
using google auth library
and service account bound inside Trusted Platform Module
*/
package main
@salrashid123
salrashid123 / duplicate_policyduplicationselect.md
Created May 9, 2024 14:56
Prevent Chained duplication from TPM-A -> TPM-B -> TPM-C using tpm2_policyduplicationselect

Prevent Chained duplication from A -> B -> C using tpm2_policyduplicationselect

This procedure will transfer an HMAC key created inside TPM-A to TPM-B but prevent TPM-B to transfer it to TPM-C.

Basically, and extension of As an end-to-end example, the following will transfer an RSA key generated on TPM-A to TPM-B but using tpm2_policyduplicationselect tp prevent further duplication

Step 1 below will transfer a key from A->B, step 2 attempts B->C but is prevented duplication on B by policy

@salrashid123
salrashid123 / duplicate_policycommandcode.md
Created May 9, 2024 14:40
Duplicate and Transfer an encoded key from TPM-A -> TPM-B -> TPM-C using tpm2_policycommandcode