Skip to content

[keymanager] GenerateKey API - incorporate signature change#677

Open
atulpatildbz wants to merge 2 commits intogoogle:mainfrom
atulpatildbz:generate_signature_fix_20260225
Open

[keymanager] GenerateKey API - incorporate signature change#677
atulpatildbz wants to merge 2 commits intogoogle:mainfrom
atulpatildbz:generate_signature_fix_20260225

Conversation

@atulpatildbz
Copy link
Collaborator

@atulpatildbz atulpatildbz commented Feb 25, 2026

  • Renamed endpoint from /v1/keys:generate_kem to /v1/keys:generate_key.
  • Restructured GenerateKeyRequest to use a nested Algorithm definition containing Type and an algorithm-specific Params object with kem_id.
  • Added support for KEY_PROTECTION_VM_EMULATED in the KeyProtectionMechanism enum and established this as the default and only supported mechanism for Vanguard so far.
  • Validated lifecycle configurations and parsed Algorithm appropriately according to updated schemas.
  • Updated associated unit and integration tests (server_test.go, integration_test.go) to use the new endpoints and the new request signature.

Manually tested with :

payload = {
    "algorithm": {
        "type": "kem",
        "params": {
            "kem_id": "DHKEM_X25519_HKDF_SHA256"
        }
    },
    "lifespan": 3600
}
resp = session.post(f"{base_url}/v1/keys:generate_key", json=payload)

result:

Generated Key: 64baa919-0fa8-4211-b41d-70f4aa1edc40

@atulpatildbz atulpatildbz force-pushed the generate_signature_fix_20260225 branch from c6b247e to 65c8d9f Compare February 25, 2026 18:26
@atulpatildbz atulpatildbz marked this pull request as ready for review February 25, 2026 18:26
@atulpatildbz atulpatildbz force-pushed the generate_signature_fix_20260225 branch from 65c8d9f to fcb3242 Compare February 25, 2026 18:27
Comment on lines 156 to 160
if req.Algorithm.Type != "kem" {
writeError(w, fmt.Sprintf("unsupported algorithm type: %q. Only 'kem' is supported.", req.Algorithm.Type), http.StatusBadRequest)
return
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

How do we make this check future proof, since we will also be using this to generate signing keys in future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a switch case here. that can be extended once we support new keys

Comment on lines 168 to 173
if req.KeyProtectionMechanism == KeyProtectionMechanismUnspecified {
req.KeyProtectionMechanism = KeyProtectionMechanismVMEmulated
}
if !req.KeyProtectionMechanism.IsSupported() {
writeError(w, fmt.Sprintf("unsupported keyProtectionMechanism: %s", req.KeyProtectionMechanism), http.StatusBadRequest)
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

GenerateKey does not have a KeyProtectionMechanism in the param anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks. somehow i had missed this. removed

KemID: KemAlgorithmDHKEMX25519HKDFSHA256,
},
},
KeyProtectionMechanism: KeyProtectionMechanismVMEmulated,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same KeyProtectionMechanism param anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

Comment on lines 68 to 71
KeyProtectionMechanismUnspecified: "KEY_PROTECTION_UNSPECIFIED",
KeyProtectionMechanismDefault: "DEFAULT",
KeyProtectionMechanismVM: "KEY_PROTECTION_VM",
KeyProtectionMechanismVMEmulated: "KEY_PROTECTION_VM_EMULATED",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed this entirely

@atulpatildbz atulpatildbz force-pushed the generate_signature_fix_20260225 branch from d5c867b to a7a2b09 Compare February 27, 2026 09:03
@atulpatildbz atulpatildbz force-pushed the generate_signature_fix_20260225 branch 3 times, most recently from f26280f to cb4e9af Compare February 28, 2026 03:55
Key changes:
- Renamed endpoint from /v1/keys:generate_kem to /v1/keys:generate_key.
- Restructured `GenerateKeyRequest` to use a nested `Algorithm`
definition containing `Type` and an algorithm-specific `Params` object
with `kem_id`.
- Added support for `KEY_PROTECTION_VM_EMULATED` in the
KeyProtectionMechanism enum and established this as the default and only
supported mechanism for Vanguard so far.
- Validated lifecycle configurations and parsed `Algorithm`
appropriately according to updated schemas.
- Updated associated unit and integration tests (server_test.go,
integration_test.go) to use the new endpoints and the new request
signature.
* Refactor GenerateKey algorithm validation to support future key types
* remove KeyProtectionMechanism
@atulpatildbz atulpatildbz force-pushed the generate_signature_fix_20260225 branch from cb4e9af to 5e805cc Compare February 28, 2026 07: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