Skip to content

Commit

Permalink
Merge pull request #189 from microsoft/beejones/kid-bug
Browse files Browse the repository at this point in the history
Fix kid bug
  • Loading branch information
beejones authored Nov 4, 2024
2 parents b9b8f35 + c3f680d commit 70afc62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/endpoints/refreshEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export const refresh = (
// Get HPKE key pair id
const id = hpkeKeyIdMap.size + 1;

// Generate HPKE key pair with a six digit id
const keyItem = KeyGeneration.generateKeyItem(100000 + id);

// since OHTTP is limited to 2 char ids, we can only have ids from 10 to 99
// So the current logic is to have ids rotate from 10 to 99
const keyItem = KeyGeneration.generateKeyItem(id % 90 + 10);

// Store HPKE key pair kid
keyItem.kid = `${keyItem.kid!}_${id}`;
hpkeKeyIdMap.storeItem(id, keyItem.kid);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class Demo {
Demo.assertField(member.name, keyResponse, "receipt", notUndefinedString);

Demo.assert(`keyResponse.timestamp > 0`, keyResponse.timestamp > 0);
Demo.assert(`keyResponse.id > 100000`, keyResponse.id > 100000);
Demo.assert(`keyResponse.id > 10`, keyResponse.id > 10);
//#endregion

//#region listpubkeys
Expand Down
4 changes: 2 additions & 2 deletions test/system-test/test_pubkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_no_params_with_single_key(setup_kms):
if status_code != 202:
break
assert status_code == 200
assert key_json["id"] == 100001
assert key_json["id"] == 11


def test_no_params_with_multiple_keys(setup_kms):
Expand All @@ -26,7 +26,7 @@ def test_no_params_with_multiple_keys(setup_kms):
if status_code != 202:
break
assert status_code == 200
assert key_json["id"] == 100002
assert key_json["id"] == 12


def test_kid_not_present_with_other_keys(setup_kms):
Expand Down

0 comments on commit 70afc62

Please sign in to comment.