-
Notifications
You must be signed in to change notification settings - Fork 13
Testkit tests for property encryption #727
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
Draft
RichardIrons-neo4j
wants to merge
21
commits into
6.x
Choose a base branch
from
feat/property-encryption
base: 6.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+761
−1
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8f71634
Added client-side property encryption protocol objects and simple rou…
RichardIrons-neo4j 5953e4d
Fix casing
RichardIrons-neo4j bb101a5
Strengthen property encryption stub tests
RichardIrons-neo4j 4639707
Add a stub test for decrypting with the wrong AAD
RichardIrons-neo4j 436914a
Add more tests, scraping the barrel of the ADR a bit
RichardIrons-neo4j 559bc30
Add cross-driver decrypt-interop check for property encryption
RichardIrons-neo4j 4eedd40
Derive the fixture generator's encrypted value from the driver name
RichardIrons-neo4j 70fde99
Fix flake8/isort style violations in the decrypt-interop check
RichardIrons-neo4j e293a25
Skip building the Rust boltstub when TEST_RUSTY_STUB isn't set
RichardIrons-neo4j 430b2e5
add javascript test
MaxAake fe0a73f
Regenerate the javascript decrypt-interop fixture with HKDF key deriv…
RichardIrons-neo4j f66641d
Make the fixture generator print lint-clean, paste-ready entries
RichardIrons-neo4j 3f0c717
Add Backend:MockRandom for deterministic property-encryption tests
RichardIrons-neo4j f49760c
Replace Backend:MockRandom with a per-call fixedIv on EncryptToBytes
RichardIrons-neo4j 4a46206
Add deterministic encryption test with known-answer fixtures
RichardIrons-neo4j 1e4aaf8
Merge remote-tracking branch 'neo4j/6.x' into feat/property-encryption
RichardIrons-neo4j 9b264a1
Test that decrypt honours the persisted AAD on an AAD-bound value
RichardIrons-neo4j cce49ca
remove number too big for js
RichardIrons-neo4j 642a43d
Regenerate deterministic fixtures for ADR-conformant AAD metadata
RichardIrons-neo4j 0fff674
Rename fixedIv/fixedKek to iv/kek and encode as bare hex on the wire
RichardIrons-neo4j b7ed9b9
Regenerate deterministic fixtures for the sorted metadata ordering (A…
RichardIrons-neo4j File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -343,6 +343,42 @@ def __init__(self, id): | |
| self.id = id | ||
|
|
||
|
|
||
| class EncryptedValue: | ||
| """ | ||
| The result of encrypting a value with client-side property encryption. | ||
|
|
||
| Sent in response to an EncryptToBytes request. | ||
| """ | ||
|
|
||
| def __init__(self, encryptedBytes): | ||
| self.encrypted_bytes = bytes.fromhex(encryptedBytes) | ||
|
|
||
|
|
||
| class DecryptedValue: | ||
| """ | ||
| The result of decrypting a value with client-side property encryption. | ||
|
|
||
| Sent in response to a Decrypt request. | ||
| """ | ||
|
|
||
| def __init__(self, decryptedValue): | ||
| self.decrypted_value = decryptedValue | ||
|
|
||
|
|
||
| class EncapsulatedKey: | ||
| """ | ||
| An encapsulated data encryption key. | ||
|
|
||
| Sent in response to a CreateEncapsulatedKey request. | ||
| """ | ||
|
|
||
| def __init__(self, id, alias, encapsulatedBytes, metadata): | ||
| self.id = id | ||
| self.alias = alias | ||
| self.encapsulated_bytes = bytes.fromhex(encapsulatedBytes) | ||
| self.metadata = metadata | ||
|
Comment on lines
+378
to
+379
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| class Result: | ||
| """Represents a result instance on the backend.""" | ||
|
|
||
|
|
||
Empty file.
78 changes: 78 additions & 0 deletions
78
tests/stub/property_encryption/decrypt_interop_fixtures.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| """ | ||
| Shared cross-driver fixture list for the decrypt-interop check. | ||
|
|
||
| Each entry was produced by one driver team's own implementation, using | ||
| generate_decrypt_interop_fixture.py against their own backend. Every driver's | ||
| test suite decrypts every entry here, proving it can read values encrypted by | ||
| every other driver. | ||
|
|
||
| Add your own entry by running that script and pasting its output below. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
| import nutkit.protocol as types | ||
|
|
||
| # don't change this or the interop decryption test will break | ||
| INTEROP_PROFILE_NAME = "interop" | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class DecryptInteropFixture: | ||
| driver: str | ||
| kek: bytes | ||
| encapsulation: bytes | ||
| metadata: dict | ||
| encrypted: bytes | ||
| value: object | ||
|
|
||
|
|
||
| DECRYPT_INTEROP_TEST_CASES = [ | ||
| DecryptInteropFixture( | ||
| driver="dotnet", | ||
| kek=bytes.fromhex( | ||
| "1974e1620d8d540ffba202d9eeb616f4" | ||
| "266a731f3eadd3637f25c71bb96ad024" | ||
| ), | ||
| encapsulation=bytes.fromhex( | ||
| "014603135847721b9f3a1b1089ec98712" | ||
| "1e03c8d703df8c35b7ca95f8893c84f6f" | ||
| "e23c661aae26ef78bc9b1b6bb06905" | ||
| ), | ||
| metadata={"iv": "nJvPChdeMDkE/FDM"}, | ||
| encrypted=bytes.fromhex( | ||
| "01b66587696e7465726f70cc24eab4839" | ||
| "fe33026669beb1413b7a3581cb32edae0" | ||
| "1e2c94e41e6e4ed741e6302df4da42208" | ||
| "6535452494e470100a5866b65795f6964" | ||
| "8130826976cc0ca3feff5e0278a951c49" | ||
| "0a11483616164cc00d0126161645f7072" | ||
| "6f746f636f6c5f6d616a6f7201d012616" | ||
| "1645f70726f746f636f6c5f6d696e6f72" | ||
| "00" | ||
| ), | ||
| value=types.CypherString("hello from dotnet!"), | ||
| ), | ||
| DecryptInteropFixture( | ||
| driver="javascript", | ||
| kek=bytes.fromhex( | ||
| "ac4828b563d2dd626d34214c3dcd8168" | ||
| "ed77c5ed9620b383e4b63665286302f9" | ||
| ), | ||
| encapsulation=bytes.fromhex( | ||
| "4320112f90e2228f4dabffdc82c904bf" | ||
| "ff33eb70b4b162354474cb6a389717e9" | ||
| "dfe3077d9255913ee6d0e30f2a9f55f0" | ||
| ), | ||
| metadata={"iv": "lL9ga7QC9WWcKXH6"}, | ||
| encrypted=bytes.fromhex( | ||
| "01b66587696e7465726f70cc28e4d50c" | ||
| "776bdf240ccb0afd823376dfda1b55ba" | ||
| "682601933fe5fc15a9276dcdd20e2cda" | ||
| "2768236a1686535452494e470100a282" | ||
| "6976cc0c343f2b095b3385d0d7adf455" | ||
| "866b65795f69648130" | ||
| ), | ||
| value=types.CypherString("hello from javascript!"), | ||
| ), | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add the
keyIdhere as well as the identifier goes into the metadata of the Encrypted Structure and it must be predictable for stub tests asserting on expected encrypted bytes. The message handler should take all of this in import the key directly into its key repository.