-
Notifications
You must be signed in to change notification settings - Fork 9
Cbc UI d2 4571 cloud encryption cleanup #355
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
Merged
cody-constine-ttd
merged 13 commits into
main
from
cbc-UID2-4571-cloud-encryption-cleanup
Dec 17, 2024
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
32119f9
Adding the start of what is needed for salt encryption
cody-constine-ttd 7fe538c
[CI Pipeline] Released Snapshot version: 8.0.10-alpha-172-SNAPSHOT
3a808a2
Added more work
cody-constine-ttd e741256
Addressing PR comments
cody-constine-ttd b2e9b68
[CI Pipeline] Released Snapshot version: 8.0.11-alpha-173-SNAPSHOT
1a23d0d
Had to adjust to work with 1mil salts
cody-constine-ttd 65abd71
[CI Pipeline] Released Snapshot version: 8.0.12-alpha-174-SNAPSHOT
e66cd22
Adding encrypted version of ClientSideKeypairStore
cody-constine-ttd 9f9b37b
[CI Pipeline] Released Snapshot version: 8.0.13-alpha-175-SNAPSHOT
b9f29ed
Have the scope resolve the metadata path instead
cody-constine-ttd 9951667
[CI Pipeline] Released Snapshot version: 8.0.14-alpha-176-SNAPSHOT
445f111
Updating rotating cloud encryptionKeyProvider
cody-constine-ttd 73cf984
[CI Pipeline] Released Snapshot version: 8.0.15-alpha-177-SNAPSHOT
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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/uid2/shared/store/RotatingEncryptedSaltProvider.java
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,48 @@ | ||
| package com.uid2.shared.store; | ||
|
|
||
| import com.uid2.shared.cloud.DownloadCloudStorage; | ||
| import com.uid2.shared.encryption.AesGcm; | ||
| import com.uid2.shared.model.CloudEncryptionKey; | ||
| import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider; | ||
|
|
||
| import com.uid2.shared.store.reader.StoreReader; | ||
| import io.vertx.core.json.JsonObject; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.Base64; | ||
| import java.util.Collection; | ||
|
|
||
| public class RotatingEncryptedSaltProvider extends RotatingSaltProvider implements StoreReader<Collection<RotatingSaltProvider.SaltSnapshot>> { | ||
| private final RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider; | ||
|
||
|
|
||
| public RotatingEncryptedSaltProvider(DownloadCloudStorage fileStreamProvider, String metadataPath, RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider) { | ||
| super(fileStreamProvider, metadataPath); | ||
| this.cloudEncryptionKeyProvider = cloudEncryptionKeyProvider; | ||
| } | ||
|
|
||
| @Override | ||
| protected String readInputStream(InputStream inputStream) throws IOException { | ||
cody-constine-ttd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String encryptedContent = super.readInputStream(inputStream); | ||
|
|
||
| JsonObject json = new JsonObject(encryptedContent); | ||
| int keyId = json.getInteger("key_id"); | ||
| String encryptedPayload = json.getString("encrypted_payload"); | ||
| CloudEncryptionKey decryptionKey = cloudEncryptionKeyProvider.getKey(keyId); | ||
|
|
||
| if (decryptionKey == null) { | ||
| throw new IllegalStateException("No matching S3 key found for decryption for key ID: " + keyId); | ||
| } | ||
|
|
||
| byte[] secret = Base64.getDecoder().decode(decryptionKey.getSecret()); | ||
| byte[] encryptedBytes = Base64.getDecoder().decode(encryptedPayload); | ||
| byte[] decryptedBytes = AesGcm.decrypt(encryptedBytes, 0, secret); | ||
|
|
||
| return new String(decryptedBytes, StandardCharsets.UTF_8); | ||
| } | ||
|
|
||
| @Override | ||
| public Collection<SaltSnapshot> getAll() { | ||
| return super.getSnapshots(); | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.