Skip to content
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

encryption 1.0 obsolete #29588

Merged
merged 6 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ static bool TryParseEncryptionVersion(
case "2.0":
version = ClientSideEncryptionVersion.V2_0;
return true;
#pragma warning disable CS0618 // obsolete
case "1.0":
version = ClientSideEncryptionVersion.V1_0;
return true;
#pragma warning restore CS0618 // obsolete
default:
version = 0;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public async Task<Stream> DecryptInternal(
int v2StartRegion0Indexed = (int)((contentRange?.Start / encryptionData.EncryptedRegionInfo?.GetTotalRegionLength()) ?? 0);
int alreadyTrimmedOffset = encryptionData.EncryptionAgent.EncryptionVersion switch
{
#pragma warning disable CS0618 // obsolete
ClientSideEncryptionVersion.V1_0 => ivInStream ? Constants.ClientSideEncryption.EncryptionBlockSize : 0,
#pragma warning restore CS0618 // obsolete
// first block is special case where we don't want to communicate a trim. Otherwise communicate nonce length * 1-indexed start region + tag length * 0-indexed region
ClientSideEncryptionVersion.V2_0 => contentRange?.Start > 0
? (-encryptionData.EncryptedRegionInfo.NonceLength * (v2StartRegion0Indexed)) - (Constants.ClientSideEncryption.V2.TagSize * v2StartRegion0Indexed)
Expand Down Expand Up @@ -137,10 +139,12 @@ internal static EncryptionData GetAndValidateEncryptionDataOrDefault(Metadata me

switch (encryptionData.EncryptionAgent.EncryptionVersion)
{
#pragma warning disable CS0618 // obsolete
case ClientSideEncryptionVersion.V1_0:
_ = encryptionData.ContentEncryptionIV ?? throw Errors.ClientSideEncryption.MissingEncryptionMetadata(
nameof(EncryptionData.ContentEncryptionIV));
break;
#pragma warning restore CS0618 // obsolete
case ClientSideEncryptionVersion.V2_0:
_ = encryptionData.EncryptedRegionInfo ?? throw Errors.ClientSideEncryption.MissingEncryptionMetadata(
nameof(EncryptionData.EncryptedRegionInfo));
Expand Down Expand Up @@ -205,8 +209,10 @@ internal static HttpRange GetEncryptedBlobRange(HttpRange originalRange, Encrypt

switch (encryptionData.EncryptionAgent.EncryptionVersion)
{
#pragma warning disable CS0618 // obsolete
case ClientSideEncryptionVersion.V1_0:
return GetEncryptedBlobRangeV1_0(originalRange);
#pragma warning restore CS0618 // obsolete
case ClientSideEncryptionVersion.V2_0:
return GetEncryptedBlobRangeV2_0(originalRange, encryptionData);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@ namespace Azure.Storage.Blobs.Tests
/// difficult to add onto only one test fixture parameter value and not others.
/// </summary>
[LiveOnly]
#pragma warning disable CS0618 // obsolete
[TestFixture(ClientSideEncryptionVersion.V1_0)]
[TestFixture(ClientSideEncryptionVersion.V2_0)]
#pragma warning restore CS0618 // obsolete
public class ClientSideEncryptedBlobClientOpenWriteTests : BlobClientOpenWriteTests
{
public ClientSideEncryptedBlobClientOpenWriteTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
private readonly ClientSideEncryptionVersion _version;

public ClientSideEncryptedBlobClientOpenWriteTests(
ClientSideEncryptionVersion version,
bool async,
BlobClientOptions.ServiceVersion serviceVersion)
: base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
{
_version = version;
// Validate every test actually used client-side encryption when writing a blob.
AdditionalAssertions += async (client) =>
{
Expand All @@ -34,7 +44,7 @@ public ClientSideEncryptedBlobClientOpenWriteTests(bool async, BlobClientOptions
protected override BlobClient GetResourceClient(BlobContainerClient container, string resourceName = null, BlobClientOptions options = null)
{
options ??= ClientBuilder.GetOptions();
options._clientSideEncryptionOptions = new ClientSideEncryptionOptions(ClientSideEncryptionVersion.V1_0)
options._clientSideEncryptionOptions = new ClientSideEncryptionOptions(_version)
{
KeyEncryptionKey = this.GetIKeyEncryptionKey(expectedCancellationToken: default).Object,
KeyWrapAlgorithm = ClientSideEncryptionTestExtensions.s_algorithmName
Expand Down
Loading