feat(crypto): add hybrid X-Wing KEM support for TDF key wrapping#3239
feat(crypto): add hybrid X-Wing KEM support for TDF key wrapping#3239
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces support for hybrid post-quantum key wrapping using the X-Wing KEM algorithm. By integrating this into the existing TDF key wrapping infrastructure, the platform gains the ability to secure data using a combination of classical and post-quantum cryptographic primitives. The changes span the entire stack, including cryptographic libraries, service-level security logic, and protocol definitions, ensuring a consistent implementation across the SDK and KAS components. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Quantum threats are on the way, But X-Wing keeps the keys at bay. With hybrid strength we hold the line, And make our crypto look just fine. Footnotes
|
Dependency ReviewThe following issues were found:
|
There was a problem hiding this comment.
Code Review
This pull request implements support for hybrid post-quantum cryptography using the X-Wing KEM. Key additions include X-Wing key pair generation and DEK wrapping/unwrapping in the ocrypto library, along with integration into the SDK and Key Access Service (KAS) to handle hybrid-wrapped key access objects. Protobuf definitions and security providers were also updated to support the new ALGORITHM_HPQT_XWING type. Feedback was provided to optimize the public key export logic in the in-process provider by using a switch statement on the existing algorithm field instead of a trial-and-error approach.
| if rsaKey, err := k.cryptoProvider.RSAPublicKey(kid); err == nil { | ||
| return rsaKey, nil | ||
| } | ||
| return k.cryptoProvider.ECPublicKey(kid) | ||
| if ecKey, err := k.cryptoProvider.ECPublicKey(kid); err == nil { | ||
| return ecKey, nil | ||
| } | ||
| return k.cryptoProvider.XWingPublicKey(kid) |
There was a problem hiding this comment.
This trial-and-error approach to finding the public key is inefficient and can be brittle. Since the KeyDetailsAdapter already stores the key's algorithm in the k.algorithm field, it would be more direct and robust to use a switch statement on k.algorithm to call the appropriate public key retrieval method.
switch k.algorithm {
case ocrypto.RSA2048Key, ocrypto.RSA4096Key:
return k.cryptoProvider.RSAPublicKey(kid)
case ocrypto.EC256Key, ocrypto.EC384Key, ocrypto.EC521Key:
return k.cryptoProvider.ECPublicKey(kid)
case ocrypto.HybridXWingKey:
return k.cryptoProvider.XWingPublicKey(kid)
default:
return "", fmt.Errorf("unsupported algorithm for PEM export: %s", k.algorithm)
}
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
cloudflare/circlHybridXWingKey("hpqt:xwing") key type and"hybrid-wrapped"scheme type alongside existing RSA and ECXWING PUBLIC KEY)wrapped_keyfield — no new KAO fields orschema changes needed
hybrid_tdf_enabledin KAS config, matching the pattern used for EC supportlib/ocrypto→service/internal/security→service/kas/access→sdkALGORITHM_HPQT_XWINGadded to protoAlgorithmandKasPublicKeyAlgEnumenums with updated CEL validation