Skip to content

Conversation

@rizlik
Copy link
Contributor

@rizlik rizlik commented Dec 1, 2025

No description provided.

Copy link
Contributor

@billphipps billphipps left a comment

Choose a reason for hiding this comment

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

We need to fix more issues like this in keystore. This fixes a problem in the wrong way. I'll reach out with details.

/* Get the appropriate cache context for this key */
ctx = _GetCacheContext(server, keyId);

/* Evict keyId from cache to avoid duplicates */
Copy link
Contributor

Choose a reason for hiding this comment

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

keyId here is very likely NOT the actual keyid that the user is wanting. It was recently added so that the server context could choose between global and local keycaches based on the top bits of the keyid itself. Additionally, evicting a key would be an unexpected side effect of asking the server for an empty cache slot.

Instead, the cache slot logic for "making" a key should match that for importing a key:

  1. Search appropriate cache looking for a matching keyid (should use FindInCache). If found, use that key slot. Remember to reset the committed flag since this key slot will no longer match the backing store (if it had been previously committed).
  2. Find an empty key slot using GetCacheSlot. If found, use that key slot

There's lots more issues in keystore that I can now see. We need to work all of them. More to come

@bigbrett bigbrett marked this pull request as draft December 3, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants