Skip to content

Adding decryption support to keystore backends#54428

Merged
eriktate merged 1 commit intomasterfrom
eriktate/keystore-decryption
May 29, 2025
Merged

Adding decryption support to keystore backends#54428
eriktate merged 1 commit intomasterfrom
eriktate/keystore-decryption

Conversation

@eriktate
Copy link
Copy Markdown
Contributor

This PR adds support for generating encryption/decryption keypairs as well as retrieving decrypters from keystore backends.

@eriktate eriktate force-pushed the eriktate/keystore-decryption branch 8 times, most recently from f6e998a to c42490e Compare May 6, 2025 22:26
@eriktate eriktate marked this pull request as ready for review May 6, 2025 22:26
@github-actions github-actions Bot requested review from nklaassen and vapopov May 6, 2025 22:27
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from 64fe22b to b84468a Compare May 8, 2025 17:43
@eriktate eriktate added the no-changelog Indicates that a PR does not require a changelog entry label May 8, 2025
Comment thread api/proto/teleport/legacy/types/types.proto Outdated
Comment thread api/proto/teleport/legacy/types/types.proto Outdated
Comment thread api/proto/teleport/legacy/types/types.proto Outdated
Comment thread api/proto/teleport/legacy/types/types.proto Outdated
Comment thread lib/auth/keystore/pkcs11.go Outdated
Comment thread lib/auth/keystore/gcp_kms.go Outdated
Comment thread lib/auth/keystore/gcp_kms.go Outdated
Comment thread lib/auth/keystore/gcp_kms.go Outdated
Comment thread lib/auth/keystore/pkcs11.go Outdated
Comment thread lib/cryptosuites/suites.go Outdated
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from b84468a to 3b7b4bb Compare May 12, 2025 19:54
@eriktate eriktate requested a review from nklaassen May 13, 2025 15:15
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from 3b7b4bb to e4ef25d Compare May 13, 2025 22:49
Copy link
Copy Markdown
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's looking pretty good to me there's just a few lingering comments

Comment thread lib/auth/keystore/gcp_kms.go Outdated
Comment thread lib/auth/keystore/manager.go Outdated
}

// GetDecrypter returns the [crypto.Decrypter] associated with a given EncryptionKeyPair if accessible.
func (m *Manager) GetDecrypter(ctx context.Context, keyPair *types.EncryptionKeyPair) (crypto.Decrypter, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in reality if you have multiple auths with PKCS#11 HSMs, you're going to have multiple possible EncryptionKeyPairs, and I don't think you're going to know which one to pass here. This is why the signer equivalents like GetJWTSigner pass the whole CA and then the keystore.Manager selects the key it can actually use with the available keystore backends. but maybe it will be better to just refactor this in a later PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I account for this in a later PR by calling GetDecrypter for each EncryptionKeyPair. I could modify this to accept a slice or an iterator of EncryptionkeyPairs, but it actually ends up being useful to know the result for each key during a rotation as a check for which keys are accessible to a given keystore.Manager. In particular when a key is being rotated the Manager can resolve both the rotated pair and the new pair, but the caller needs to make decisions based on the state of both of them (e.g. if the new pair is still unfulfilled, the key marked as rotating is still the active key. If it's fulfilled then the rotating key needs to be marked as rotated).

Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/keystore/gcp_kms.go Outdated
Comment thread lib/auth/keystore/pkcs11.go Outdated
@eriktate eriktate requested a review from nklaassen May 14, 2025 20:06
@eriktate
Copy link
Copy Markdown
Contributor Author

@nklaassen @vapopov friendly bump!

@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from c3b364d to 6a5041a Compare May 20, 2025 14:05
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from 6a5041a to d4161b8 Compare May 22, 2025 19:23
Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/keystore/pkcs11.go Outdated
Comment thread lib/cryptosuites/suites.go
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from d4161b8 to 027543d Compare May 27, 2025 21:57
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from vapopov May 27, 2025 21:57
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from 027543d to cd91ba6 Compare May 27, 2025 21:58
@eriktate eriktate enabled auto-merge May 27, 2025 22:01
@eriktate eriktate disabled auto-merge May 27, 2025 22:02
@eriktate eriktate force-pushed the eriktate/keystore-decryption branch from cd91ba6 to 12ade31 Compare May 29, 2025 18:57
@eriktate eriktate enabled auto-merge May 29, 2025 18:59
@eriktate eriktate added this pull request to the merge queue May 29, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 29, 2025
@eriktate eriktate added this pull request to the merge queue May 29, 2025
Merged via the queue into master with commit 479e99b May 29, 2025
43 checks passed
@eriktate eriktate deleted the eriktate/keystore-decryption branch May 29, 2025 20:02
eriktate added a commit that referenced this pull request Jun 30, 2025
eriktate added a commit that referenced this pull request Jul 1, 2025
eriktate added a commit that referenced this pull request Jul 1, 2025
eriktate added a commit that referenced this pull request Jul 1, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Sep 3, 2025
* adding support for encryption/decryption keys to keystore manager (#54428, #55652)

* adds new protos for resources related to encrypted session recordings and updates the existing SessionRecordingConfig protos to include a Status (#54780)

* adding local service implementation for recording encryption resources (#54816)

* adding Manager for RecordingEncryption resources that handles shared ops more complex than CRUD (#55078)

* Adding session recording plugin for `age` (#55120)

* adding Manager for RecordingEncryption resources that handles shared ops more complex than CRUD

* adding age plugin wrapping default X25519 Identity/Recipient implementation with hooks to more efficiently lookup private keys given their respective public key

* Adding recording encryption and playback for `sync` modes (#54901)

* adding cache for RecordingEncryption (#55857)

* adding recording_encryption service protos (#55121)

* adding async recording encryption with gRPC multipart uploader (#55859)

* adding file configuration for encrypted session recording (#56200)

* Switching recording encryption to unwrap keys using direct keystore RSA decryption (#56776)

* adding manual key management config (#56920)

* updating protos for recording encryption (#57055)

* Add missing handling for recording encryption configs and keys (#57279)

* updating protos for recording encryption

* changing labels for encryption keys to prevent automatic cleanup, adjusting pkcs11 host UUID check to allow for key sharing of encryption keys, preventing cloud tenants from enabling manual key management, preventing use of recording encryption in FIPS mode

* adding new protos for rotated keys and the local service for interacting (#57576)

with them

* Switching encryption keys from PEM to ASN.1 DER encoding (#58137)

* using pregenerated RSA4096 key for keystore tests because generation is too slow (#58138)

* extending precomputed RSA keys to support 4096-bit keys (#58251)

* adding rotation process to Manager and exposing with new RPCs and (#57577)

* adding rotation sub commands for recording encryption keys and fixing (#57780)

broken session_recording_config when using fileconf

* using more reliable method of validating key bit length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/lg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants