Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Keystore interface #496

Merged

Conversation

iamnotacake
Copy link
Contributor

@iamnotacake iamnotacake commented Feb 15, 2022

Add methods GetClientIDSymmetricKey and GetZoneIDSymmetricKey that should return only the latest key that will be used to encrypt data by client / in zone.

Implemented new methods for filesystem keystore v1 and v2 (but no special impl for poison keys).
This should cover Redis as well.

Checklist

Add methods GetClientIDEncryptionKey and GetZoneIDEncryptionKey that
should return only the latest key that will be used to encrypt data by
client / in zone.

By default, it will simply request all keys and take the latest one, so
no performance improvements until these methods are properly implemented
in different keystores.
@iamnotacake iamnotacake marked this pull request as ready for review February 16, 2022 10:50
After recent re-generation of some files, more golint issues were
introduced so had to increase allowed number, it's not related to
changes done in code.
Introduce new function `getLatestSymmetricKey`, similar to
`getSymmetricKeys` that will only read one key, use it in methods
implementation
crypto/poison_detector.go Outdated Show resolved Hide resolved
crypto/poison_detector.go Outdated Show resolved Hide resolved
keystore/filesystem/server_keystore.go Outdated Show resolved Hide resolved
@Lagovas Lagovas mentioned this pull request Feb 17, 2022
7 tasks
GetClientIDEncryptionKey -> GetClientIDSymmetricKey
GetZoneIDEncryptionKey -> GetZoneIDSymmetricKey
Extend `RecordProcessorKeyStore` and `PoisonKeyStore` with new nethod:
  GetPoisonSymmetricKey() ([]byte, error)
and implement it in keystores v1/v2.
Use this function in `Get*IDSymmetricKey` of poison keystore.

Comment unused function `NewRecordProcessor` that caused compilation
issues.

Re-generate some mock files again.
// If a poison record does not exist, it is created and its sole symmetric key is returned.
func (store *KeyStore) GetPoisonSymmetricKey() ([]byte, error) {
keyFileName := getSymmetricKeyName(PoisonKeyFilename)
poisonKeyExists, err := store.fs.Exists(store.GetPrivateKeyFilePath(keyFileName))
Copy link
Collaborator

Choose a reason for hiding this comment

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

my last comment was related to this block
#496 (comment)

// Try getting it from cache first
key, ok := store.cache.Get(keyFileName)
if ok {
return key, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

here is it's encrypted unuseful key. we should decrypt it. and add test if your tests passed it )

Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

merge after successful test run

@Lagovas Lagovas merged commit fa02316 into cossacklabs:master Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants