Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
8a3883e
[Internal] Client Telemetry: Fixes tests leaking environment variable…
ealsur Oct 27, 2022
543294c
Updated change log and bumped up the version. (#3526)
kundadebdatta Oct 29, 2022
abf3d93
Query: Fixes performance regression on target partition on some ORDER…
neildsh Oct 31, 2022
84ef545
[Internal] AI Integration: Adds SubStatusCode Information in attribut…
sourabh1007 Nov 2, 2022
68b9805
Diagnostics: Removes unused properties and reduces size (#3519)
aavasthy Nov 2, 2022
a9bcaf5
[Internal] docs: Add address caches conceptual flow (#3534)
kirankumarkolli Nov 2, 2022
6762e07
Release: Adds SDK version and changelog for 3.31.2 (#3546)
neildsh Nov 3, 2022
ef7339e
[Internal] Documentation: Removes invalid comment from ReadThroughput…
ealsur Nov 4, 2022
825595a
[Internal] nugetconfig: Removes specific overrides (#3551)
kirankumarkolli Nov 7, 2022
4746a6f
Query: Fixes partition range evaluation for spatial queries (#3495)
adityasa Nov 9, 2022
acd899e
[Internal] Documentation: Refactors cache content on its own document…
ealsur Nov 9, 2022
01c1cd4
[Internal] Emulator unit tests: Adds IdEncoding unit tests for Comput…
FabianMeiswinkel Nov 10, 2022
ab1f249
Change Feed Processor: Adds support for Resource Tokens (#3566)
ealsur Nov 15, 2022
9fb3a12
[Internal] AI integration: Refactor code how container and database n…
sourabh1007 Nov 15, 2022
9c2015b
[Internal] AI Integration: Adds a new flag in DistributedTracingOptio…
sourabh1007 Nov 16, 2022
c38346d
Query: Fixes default to BadRequestException in case of internal error…
neildsh Nov 17, 2022
9cafaa8
[Internal] Query: Adds unit tests for Merge/Split implementation with…
akotalwar Nov 17, 2022
2681be8
Client Retry Policy: Adds HTTP timeouts with request-level cross-regi…
NaluTripician Nov 18, 2022
010e4ba
Documentation: Fixes EUAP in Comments (#3579)
PramodValavala-MSFT Nov 21, 2022
b24eeb9
Query: Fixes incorrect FeedResponse.Count when result contains undefi…
neildsh Nov 23, 2022
9734ec5
removed allr eference (#3581)
sourabh1007 Nov 24, 2022
6632168
Trace: Fixes Tracing/diagnostics hour-times to 24Hours (#3577)
kirankumarkolli Nov 24, 2022
8e82a1a
AI Integration: Adds cosmetic fixes (#3576)
sourabh1007 Nov 26, 2022
2f047e1
Query: Adds ALL Scalar Expression (#3509)
ezrahaleva-msft Nov 28, 2022
07b34e6
Release: Adds API contracts for 3.31.2-preview (#3586)
neildsh Nov 28, 2022
5318646
[Internal] sccignore: Adds a .sccignore file to apply an exception fo…
vivekr20 Nov 29, 2022
28318b0
[Internal] PermissionTests: Adds CosmosPermissionTests Coverage (#3593)
prasadu-microsoft Dec 1, 2022
a34bac7
[Internal] AI Integration: Refactors to Operation prefix and add test…
sourabh1007 Dec 5, 2022
6b1fa03
[Internal] HttpTimeoutPolicy: Removes Data Plane Writes from being ab…
NaluTripician Dec 15, 2022
814e72e
[Internal] Performance Testing: Adds Distributed Tracing option in be…
sourabh1007 Dec 20, 2022
5c05fbb
[Internal] Benchmark: Refactors code to make Memory Stream capacity c…
sourabh1007 Jan 4, 2023
73c9e08
add new LatestVersion changefeed mode that has same behavior as Incre…
philipthomas-MSFT Jan 4, 2023
77e3aa4
Query: Fixes handling of CosmosUndefined, CosmosGuid and CosmosBinary…
neildsh Jan 7, 2023
3c875c7
[Internal] Subpartitioning: Adds updates to test coverage for subpart…
NaluTripician Jan 9, 2023
416b154
[Internal] ContainerProperties: Fixes version reset when setting Part…
ealsur Jan 9, 2023
59b70a6
[Internal] AI Integration: Adds CorrelationId and Activity Id Attribu…
sourabh1007 Jan 10, 2023
612337c
Documentation: Fixes CosmosClientBuilder.WithConnectionModeGateway pa…
arthuraugsten Jan 11, 2023
55f9ce8
Upgrade Resiliency: Refactors Implementation for Opening Rntbd Connec…
kundadebdatta Jan 11, 2023
9dde99e
[Preview] AI integration: Adds IsDistributedTracingEnabled flag as pu…
sourabh1007 Jan 12, 2023
36d0e0f
Change Feed Processor: Fixes behavior with StartTime on Local (#3645)
ealsur Jan 13, 2023
bdd059d
[Internal] Client Telemetry: Refactors code to use base useragent str…
sourabh1007 Jan 17, 2023
b3cf7df
[Internal] AI Integration: Refactors code to rename event name (#3648)
sourabh1007 Jan 17, 2023
4b77519
Region Availability: Adds Poland Central Region For Public Usage (#3656)
kundadebdatta Jan 17, 2023
1710115
Client Encryption: Adds validation code to check if the Key Vault URI…
kr-santosh Jan 19, 2023
e383d83
[Internal] Query: Adds Split Support for Ode (#3572)
akotalwar Jan 20, 2023
ccaf8fb
[Internal] AI Integration : Fixes operation type for batch (#3660)
sourabh1007 Jan 23, 2023
c29abfe
CosmosClientOptions: Adds ServerCertificateCustomValidationCallback f…
aavasthy Jan 24, 2023
2608d4a
Query: Adds EnableOptimisticDirectExecution flag to QueryRequestOptio…
akotalwar Jan 26, 2023
d6a439f
[Internal] Tests: Removes Direct/HTTPS emulator tests (#3679)
ealsur Feb 2, 2023
393ae23
[Internal] Benchmark : Fixes issue with dependency on Cosmos Project …
sourabh1007 Feb 2, 2023
122bc56
LocalQuorum: Adds Quorum reads on Consistent Prefix Accounts (#3680)
pravengithub Feb 3, 2023
8a537ce
3.32.0: Adds new SDK version and contract files (#3687)
aavasthy Feb 6, 2023
bf9a6d4
[Internal] Samples: Adds change feed pull model samples (#3646)
jcocchi Feb 9, 2023
16caa1b
[Internal] Tests: Refactors emulator CI (#3688)
ealsur Feb 13, 2023
6434c10
[Internal] GitHub Template: Adds needs-investigation label (#3708)
ealsur Feb 14, 2023
4e923da
Adding fabric bot action (#3709)
ealsur Feb 14, 2023
38d1bcc
CosmosNullReferenceException: Refactors CosmosNullReferenceException …
jeet1995 Feb 17, 2023
209e473
[Internal] PriorityRequests: Fixes header value (#3714)
Achint-Agrawal Feb 17, 2023
67e1a90
[Internal] Query: Adds single physical partition check for Optimistic…
akotalwar Feb 17, 2023
b257f8e
[Internal] CTL: Fixes Reservoir Sampling Logic (#3712)
kundadebdatta Feb 17, 2023
94c83f5
Diagnostics: Adds startDate in Summary (#3707)
NimitS1 Feb 27, 2023
462a2c4
[Internal] Client Telemetry: Adds network information in the payload …
sourabh1007 Feb 27, 2023
0088c2f
Documentation: Fixes Database.ReadAsync description (#3457)
SaurabhSharma-MSFT Mar 1, 2023
fd687f5
Upgrade Resiliency: Adds Implementation for Validating the Unhealthy …
kundadebdatta Mar 1, 2023
93bb10b
ReadMany: Fixes BadRequest when using Ids with single quotes (#3732)
ealsur Mar 1, 2023
45c0d14
Release: Adds SDK version and changelog for 3.32.1 (#3733)
ealsur Mar 1, 2023
0018c4a
[Internal] Build: Fixes static tool analysis versions (#3736)
ealsur Mar 2, 2023
d6e04a9
Query: Fixes System.ArgumentException when using PartitionKey.None on…
neildsh Mar 2, 2023
f262f89
Query: Adds FIRST and LAST Scalar Expressions (#3629)
ezrahaleva-msft Mar 6, 2023
dc3d037
Subpartitioning: Adds support for Prefix Partition Key searches for s…
philipthomas-MSFT Mar 7, 2023
6ebb8d4
[Internal] ClientTelemetry: Adds logic to limit payload size to 2 MB …
sourabh1007 Mar 9, 2023
682b001
Query: Fixes regression from LINQ custom serializer fix (#3749)
leminh98 Mar 10, 2023
f2a3078
[Internal] LocalQuorum: Refactors override (i.e. strong) to allow fro…
kirankumarkolli Mar 10, 2023
d41f099
Release: Adds SDK version and change log for 3.32.2 (#3752)
ealsur Mar 11, 2023
1acfaa2
Subpartitioning: Adds APIs for public release and increase REST API v…
NaluTripician Mar 21, 2023
d0c0578
Change Feed Processor: Fixes LeaseLostException leaks on notification…
ealsur Mar 23, 2023
4ab6293
Upgrade Resiliency: Refactors GatewayAddressCache to Mark TransportAd…
kundadebdatta Mar 23, 2023
d822239
[Preview] PriorityBasedExecution: Adds PriorityLevel as a RequestOpti…
Achint-Agrawal Mar 27, 2023
1c544bf
[Internal] Client Telemetry: Adds sampling logic for network level te…
sourabh1007 Mar 29, 2023
6553a70
[Internal] Emulator Test : Fixes test when running with distributed t…
sourabh1007 Mar 29, 2023
67dc262
Release: Adds SDK version and changelog for 3.32.3 (#3788)
ealsur Mar 30, 2023
a697242
SummaryDiagnostics: Refactors Code to Remove Dependency of HttpRespon…
kundadebdatta Apr 3, 2023
e41eea5
[Internal] Documentation: Fixes API name to NoSQL (#3795)
jcocchi Apr 4, 2023
ba078c9
[Internal] CTL: Fixes docker image pipeline (#3794)
ealsur Apr 4, 2023
ae6bcf3
[Internal] AI Integration : Refactors useragent attribute name as per…
sourabh1007 Apr 4, 2023
2b69394
HttpClient: Adds Properties to the Http messages if available (#3803)
ealsur Apr 6, 2023
4222cef
Documentation: Refactors SQL API reference to NoSQL API (#3793)
scottaddie Apr 6, 2023
fce9702
[Internal] Perf test: Refactors code to re-enable performance tests (…
sourabh1007 Apr 7, 2023
2f2e8fb
HttpClient: Adds detection of DNS changes through use of SocketsHttpH…
NaluTripician Apr 7, 2023
789f701
[Internal] Tests: Fixes Open Telemetry attributes for ReadMany test (…
ealsur Apr 8, 2023
2b6fdb7
[Internal] Client Telemetry: Refactors code to run client telemetry d…
sourabh1007 Apr 10, 2023
33dea8a
Patch: Adds Move Operation (#3389)
Amaan-Haque Apr 11, 2023
31b1ff3
[Internal] Pipelines: Adds nightly build to produce packages (#3802)
ealsur Apr 11, 2023
bfbb43e
[Internal] OpenTelemetry: Direct Package update and replacing diagnos…
aavasthy Apr 18, 2023
f94869a
[Internal] MerlinBot: Adds auto-merge and cleanup automation (#3813)
ealsur Apr 18, 2023
afd5904
Update fabricbot.json (#3824)
ealsur Apr 24, 2023
fb80ba8
[Internal] Upgrade Resiliency: Adds Logic to Validate `Unknown` Repli…
kundadebdatta Apr 24, 2023
5d4f7c1
Serialization: Fixes call to CosmosSerializer.FromStream on Gateway m…
Apr 25, 2023
0d0ffe0
[Internal] Documentation: Adds documentation covering build pipelines…
ealsur Apr 27, 2023
e872f93
Client Encryption: Adds release version of Microsoft.Azure.Cosmos to …
vipulvishal-ms Apr 27, 2023
e5972ac
SDK 3.33.0 : Adds version bump and changelog (#3823)
NaluTripician Apr 27, 2023
7465da2
[Internal] Documentation: Adds msdata/direct Sync-up Guide. (#3828)
kundadebdatta May 1, 2023
20121c8
Query: Adds TRIM string system function support in LINQ (#3833)
leminh98 May 2, 2023
15616d3
Query: Fixes Parsing Error in SQL DOM when CultureInfo is available (…
leminh98 May 2, 2023
1dcba53
Client Encryption: Adds api FetchDataEncryptionKeyWithoutRawKeyAsync …
vipulvishal-ms May 3, 2023
9ba3f75
Initial commit (#3826)
adityasa May 3, 2023
17203a5
Query: Adds Computed Property SDK Support (#3761)
adityasa May 4, 2023
033e883
[Internal] Samples: Adds OpenTelemetry and Application Insights sampl…
jcocchi May 5, 2023
0c15865
[Internal] Query: Added custom serializer coverage tests to Expressio…
onionhammer May 9, 2023
ade7e34
Query: Added remaining Cosmos Type checking functions to CosmosLinqEx…
onionhammer May 9, 2023
aff7349
update sdk version and section tags (#3841)
jcocchi May 10, 2023
1a8b7f0
PackageLicense: Removes PackageLicenseUrl and Adds PackageLicenseFile…
philipthomas-MSFT May 16, 2023
b06d6c3
making ChangeFeedMode.LatestVersion accessible to the public (#3854)
philipthomas-MSFT May 17, 2023
37a80b3
Merge branch 'master' into msdata/direct
kundadebdatta May 17, 2023
0c10434
Code changes to update msdata/direct repo.
kundadebdatta May 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion .github/fabricbot.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,82 @@
}
]
}
},
{
"taskType": "trigger",
"capabilityId": "AutoMerge",
"subCapability": "AutoMerge",
"version": "1.0",
"config": {
"taskName": "PR Automerge",
"allowAutoMergeInstructionsWithoutLabel": false,
"mergeType": "squash",
"deleteBranches": true,
"removeLabelOnPush": true,
"label": "auto-merge",
"requireAllStatuses": false,
"requireSpecificCheckRuns": false,
"usePrDescriptionAsCommitMessage": false,
"minMinutesOpen": "60",
"enforceDMPAsStatus": true
}
},
{
"taskType": "scheduled",
"capabilityId": "ScheduledSearch",
"subCapability": "ScheduledSearch",
"version": "1.1",
"config": {
"frequency": [
{
"weekDay": 1,
"hours": [
9
],
"timezoneOffset": -7
}
],
"searchTerms": [
{
"name": "isOpen",
"parameters": {}
},
{
"name": "isIssue",
"parameters": {}
},
{
"name": "hasLabel",
"parameters": {
"label": "needs-more-information"
}
},
{
"name": "noActivitySince",
"parameters": {
"days": 14
}
},
{
"name": "noAssignees",
"parameters": {}
}
],
"taskName": "Close inactive needs-information",
"actions": [
{
"name": "addReply",
"parameters": {
"comment": "@${issueAuthor} this issue requires more information for the team to be able to help. In case this information is available, please add it and re-open the Issue."
}
},
{
"name": "closeIssue",
"parameters": {}
}
]
}
}
],
"userGroups": []
}
}
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ClientOfficialVersion>3.32.2</ClientOfficialVersion>
<ClientPreviewVersion>3.32.2</ClientPreviewVersion>
<ClientOfficialVersion>3.33.0</ClientOfficialVersion>
<ClientPreviewVersion>3.33.0</ClientPreviewVersion>
<ClientPreviewSuffixVersion>preview</ClientPreviewSuffixVersion>
<DirectVersion>3.30.4</DirectVersion>
<DirectVersion>3.30.8</DirectVersion>
<EncryptionOfficialVersion>2.0.1</EncryptionOfficialVersion>
<EncryptionPreviewVersion>2.0.1</EncryptionPreviewVersion>
<EncryptionPreviewSuffixVersion>preview</EncryptionPreviewSuffixVersion>
<CustomEncryptionVersion>1.0.0-preview04</CustomEncryptionVersion>
<CustomEncryptionVersion>1.0.0-preview05</CustomEncryptionVersion>
<HybridRowVersion>1.1.0-preview3</HybridRowVersion>
<LangVersion>10.0</LangVersion>
<AboveDirBuildProps>$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))</AboveDirBuildProps>
Expand Down
5 changes: 5 additions & 0 deletions Microsoft.Azure.Cosmos.Encryption.Custom/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Preview features are treated as a separate branch and will not be included in th
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### <a name="1.0.0-preview05"/> [1.0.0-preview05](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Encryption.Custom/1.0.0-preview05) - 2023-04-27

#### Fixes
- [#3809](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/3809) Adds api FetchDataEncryptionKeyWithoutRawKeyAsync and FetchDataEncryptionKey to get DEK without and with raw key respectively.

### <a name="1.0.0-preview04"/> [1.0.0-preview04](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Encryption.Custom/1.0.0-preview04) - 2022-08-16

#### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,25 @@ public async Task InitializeAsync(
this.container = containerResponse.Container;
}

/// <inheritdoc/>
public override async Task<DataEncryptionKey> FetchDataEncryptionKeyWithoutRawKeyAsync(
string id,
string encryptionAlgorithm,
CancellationToken cancellationToken)
{
return await this.FetchDekAsync(id, encryptionAlgorithm, cancellationToken);
}

/// <inheritdoc/>
public override async Task<DataEncryptionKey> FetchDataEncryptionKeyAsync(
string id,
string encryptionAlgorithm,
CancellationToken cancellationToken)
{
return await this.FetchDekAsync(id, encryptionAlgorithm, cancellationToken, true);
}

private async Task<DataEncryptionKey> FetchDekAsync(string id, string encryptionAlgorithm, CancellationToken cancellationToken, bool withRawKey = false)
{
DataEncryptionKeyProperties dataEncryptionKeyProperties = await this.dataEncryptionKeyContainerCore.FetchDataEncryptionKeyPropertiesAsync(
id,
Expand Down Expand Up @@ -200,7 +214,8 @@ public override async Task<DataEncryptionKey> FetchDataEncryptionKeyAsync(
InMemoryRawDek inMemoryRawDek = await this.dataEncryptionKeyContainerCore.FetchUnwrappedAsync(
dataEncryptionKeyProperties,
diagnosticsContext: CosmosDiagnosticsContext.Create(null),
cancellationToken: cancellationToken);
cancellationToken: cancellationToken,
withRawKey);

return inMemoryRawDek.DataEncryptionKey;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public override async Task<byte[]> DecryptAsync(
string encryptionAlgorithm,
CancellationToken cancellationToken = default)
{
DataEncryptionKey dek = await this.DataEncryptionKeyProvider.FetchDataEncryptionKeyAsync(
DataEncryptionKey dek = await this.DataEncryptionKeyProvider.FetchDataEncryptionKeyWithoutRawKeyAsync(
dataEncryptionKeyId,
encryptionAlgorithm,
cancellationToken);

if (dek == null)
{
throw new InvalidOperationException($"Null {nameof(DataEncryptionKey)} returned from {nameof(this.DataEncryptionKeyProvider.FetchDataEncryptionKeyAsync)}.");
throw new InvalidOperationException($"Null {nameof(DataEncryptionKey)} returned from {nameof(this.DataEncryptionKeyProvider.FetchDataEncryptionKeyWithoutRawKeyAsync)}.");
}

return dek.DecryptData(cipherText);
Expand All @@ -55,14 +55,14 @@ public override async Task<byte[]> EncryptAsync(
string encryptionAlgorithm,
CancellationToken cancellationToken = default)
{
DataEncryptionKey dek = await this.DataEncryptionKeyProvider.FetchDataEncryptionKeyAsync(
DataEncryptionKey dek = await this.DataEncryptionKeyProvider.FetchDataEncryptionKeyWithoutRawKeyAsync(
dataEncryptionKeyId,
encryptionAlgorithm,
cancellationToken);

if (dek == null)
{
throw new InvalidOperationException($"Null {nameof(DataEncryptionKey)} returned from {nameof(this.DataEncryptionKeyProvider.FetchDataEncryptionKeyAsync)}.");
throw new InvalidOperationException($"Null {nameof(DataEncryptionKey)} returned from {nameof(this.DataEncryptionKeyProvider.FetchDataEncryptionKeyWithoutRawKeyAsync)}.");
}

return dek.EncryptData(plainText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ internal async Task<DataEncryptionKey> FetchUnWrappedMdeSupportedLegacyDekAsync(
unwrapResult.DataEncryptionKey);

return new MdeEncryptionAlgorithm(
unwrapResult.DataEncryptionKey,
plaintextDataEncryptionKey,
Data.Encryption.Cryptography.EncryptionType.Randomized);
}
Expand Down Expand Up @@ -378,13 +379,14 @@ internal async Task<DataEncryptionKey> FetchUnWrappedLegacySupportedMdeDekAsync(
internal async Task<InMemoryRawDek> FetchUnwrappedAsync(
DataEncryptionKeyProperties dekProperties,
CosmosDiagnosticsContext diagnosticsContext,
CancellationToken cancellationToken)
CancellationToken cancellationToken,
bool withRawKey = false)
{
try
{
if (string.Equals(dekProperties.EncryptionAlgorithm, CosmosEncryptionAlgorithm.MdeAeadAes256CbcHmac256Randomized))
{
DataEncryptionKey dek = this.InitMdeEncryptionAlgorithm(dekProperties);
DataEncryptionKey dek = this.InitMdeEncryptionAlgorithm(dekProperties, withRawKey);

// TTL is not used since DEK is not cached.
return new InMemoryRawDek(dek, TimeSpan.FromMilliseconds(0));
Expand Down Expand Up @@ -564,7 +566,7 @@ private async Task<EncryptionKeyUnwrapResult> UnWrapDekMdeEncAlgoAsync(
return unwrapResult;
}

internal DataEncryptionKey InitMdeEncryptionAlgorithm(DataEncryptionKeyProperties dekProperties)
internal DataEncryptionKey InitMdeEncryptionAlgorithm(DataEncryptionKeyProperties dekProperties, bool withRawKey = false)
{
if (this.DekProvider.MdeKeyWrapProvider == null)
{
Expand All @@ -576,7 +578,8 @@ internal DataEncryptionKey InitMdeEncryptionAlgorithm(DataEncryptionKeyPropertie
dekProperties,
Data.Encryption.Cryptography.EncryptionType.Randomized,
this.DekProvider.MdeKeyWrapProvider.EncryptionKeyStoreProvider,
this.DekProvider.PdekCacheTimeToLive);
this.DekProvider.PdekCacheTimeToLive,
withRawKey);
}

private async Task<DataEncryptionKeyProperties> ReadResourceAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ namespace Microsoft.Azure.Cosmos.Encryption.Custom
public abstract class DataEncryptionKeyProvider
{
/// <summary>
/// Retrieves the data encryption key for the given id.
/// Retrieves the data encryption key for the given id without rawkey. RawKey will be set to null.
/// </summary>
/// <param name="id">Identifier of the data encryption key.</param>
/// <param name="encryptionAlgorithm">Encryption algorithm that the retrieved key will be used with.</param>
/// <param name="cancellationToken">Token for request cancellation.</param>
/// <returns>Data encryption key bytes.</returns>
public abstract Task<DataEncryptionKey> FetchDataEncryptionKeyWithoutRawKeyAsync(
string id,
string encryptionAlgorithm,
CancellationToken cancellationToken);

/// <summary>
/// Retrieves the data encryption key for the given id with RawKey value.
/// </summary>
/// <param name="id">Identifier of the data encryption key.</param>
/// <param name="encryptionAlgorithm">Encryption algorithm that the retrieved key will be used with.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,13 +791,6 @@ public override Task<IReadOnlyList<FeedRange>> GetFeedRangesAsync(
return this.container.GetFeedRangesAsync(cancellationToken);
}

public override Task<IEnumerable<string>> GetPartitionKeyRangesAsync(
FeedRange feedRange,
CancellationToken cancellationToken = default)
{
return this.container.GetPartitionKeyRangesAsync(feedRange, cancellationToken);
}

public override FeedIterator GetItemQueryStreamIterator(
FeedRange feedRange,
QueryDefinition queryDefinition,
Expand Down Expand Up @@ -1010,6 +1003,14 @@ public override async Task<FeedResponse<T>> ReadManyItemsAsync<T>(
return this.ResponseFactory.CreateItemFeedResponse<T>(responseMessage);
}

#if ENCRYPTIONPREVIEW
public override Task<IEnumerable<string>> GetPartitionKeyRangesAsync(
FeedRange feedRange,
CancellationToken cancellationToken = default)
{
return this.container.GetPartitionKeyRangesAsync(feedRange, cancellationToken);
}

public override Task<ResponseMessage> DeleteAllItemsByPartitionKeyStreamAsync(
Cosmos.PartitionKey partitionKey,
RequestOptions requestOptions = null,
Expand All @@ -1020,6 +1021,7 @@ public override Task<ResponseMessage> DeleteAllItemsByPartitionKeyStreamAsync(
requestOptions,
cancellationToken);
}
#endif

private async Task<ResponseMessage> ReadManyItemsHelperAsync(
IReadOnlyList<(string id, PartitionKey partitionKey)> items,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ internal sealed class MdeEncryptionAlgorithm : DataEncryptionKey
{
private readonly AeadAes256CbcHmac256EncryptionAlgorithm mdeAeadAes256CbcHmac256EncryptionAlgorithm;

private readonly byte[] unwrapKey;

// unused for MDE Algorithm.
public override byte[] RawKey => null;
public override byte[] RawKey { get; }

public override string EncryptionAlgorithm => CosmosEncryptionAlgorithm.MdeAeadAes256CbcHmac256Randomized;

Expand All @@ -32,7 +34,8 @@ public MdeEncryptionAlgorithm(
DataEncryptionKeyProperties dekProperties,
Data.Encryption.Cryptography.EncryptionType encryptionType,
EncryptionKeyStoreProvider encryptionKeyStoreProvider,
TimeSpan? cacheTimeToLive)
TimeSpan? cacheTimeToLive,
bool withRawKey=false)
{
if (dekProperties == null)
{
Expand All @@ -49,36 +52,39 @@ public MdeEncryptionAlgorithm(
dekProperties.EncryptionKeyWrapMetadata.Value,
encryptionKeyStoreProvider);

ProtectedDataEncryptionKey protectedDataEncryptionKey;
if (cacheTimeToLive.HasValue)
if (!withRawKey)
{
// no caching
if (cacheTimeToLive.Value == TimeSpan.Zero)
{
protectedDataEncryptionKey = new ProtectedDataEncryptionKey(
ProtectedDataEncryptionKey protectedDataEncryptionKey = cacheTimeToLive.HasValue && cacheTimeToLive.Value == TimeSpan.Zero
? new ProtectedDataEncryptionKey(
dekProperties.Id,
keyEncryptionKey,
dekProperties.WrappedDataEncryptionKey)
: ProtectedDataEncryptionKey.GetOrCreate(
dekProperties.Id,
keyEncryptionKey,
dekProperties.WrappedDataEncryptionKey);
}
else
{
protectedDataEncryptionKey = ProtectedDataEncryptionKey.GetOrCreate(
dekProperties.Id,
keyEncryptionKey,
dekProperties.WrappedDataEncryptionKey);
}
this.mdeAeadAes256CbcHmac256EncryptionAlgorithm = AeadAes256CbcHmac256EncryptionAlgorithm.GetOrCreate(
protectedDataEncryptionKey,
encryptionType);
}
else
{
protectedDataEncryptionKey = ProtectedDataEncryptionKey.GetOrCreate(
dekProperties.Id,
keyEncryptionKey,
dekProperties.WrappedDataEncryptionKey);
byte[] rawKey = keyEncryptionKey.DecryptEncryptionKey(dekProperties.WrappedDataEncryptionKey);
PlaintextDataEncryptionKey plaintextDataEncryptionKey = cacheTimeToLive.HasValue && (cacheTimeToLive.Value == TimeSpan.Zero)
? new PlaintextDataEncryptionKey(
dekProperties.Id,
rawKey)
: PlaintextDataEncryptionKey.GetOrCreate(
dekProperties.Id,
rawKey);
this.RawKey = rawKey;
this.mdeAeadAes256CbcHmac256EncryptionAlgorithm = AeadAes256CbcHmac256EncryptionAlgorithm.GetOrCreate(
plaintextDataEncryptionKey,
encryptionType);

}

this.mdeAeadAes256CbcHmac256EncryptionAlgorithm = AeadAes256CbcHmac256EncryptionAlgorithm.GetOrCreate(
protectedDataEncryptionKey,
encryptionType);

}

/// <summary>
Expand All @@ -90,9 +96,11 @@ public MdeEncryptionAlgorithm(
/// <param name="dataEncryptionKey"> Data Encryption Key </param>
/// <param name="encryptionType"> Encryption type </param>
public MdeEncryptionAlgorithm(
byte[] rawkey,
Data.Encryption.Cryptography.DataEncryptionKey dataEncryptionKey,
Data.Encryption.Cryptography.EncryptionType encryptionType)
{
this.RawKey = rawkey;
this.mdeAeadAes256CbcHmac256EncryptionAlgorithm = AeadAes256CbcHmac256EncryptionAlgorithm.GetOrCreate(
dataEncryptionKey,
encryptionType);
Expand Down
Loading