Skip to content

Commit

Permalink
encryption 1.0 obsolete (#29588)
Browse files Browse the repository at this point in the history
* encryption 1.0 obsolete

disabling warnings within own code base for this new obsoletion

* exportapi

* fix test and recording

* recording

* update link
  • Loading branch information
jaschrep-msft authored Jul 6, 2022
1 parent 87a861b commit 4ee1f30
Show file tree
Hide file tree
Showing 33 changed files with 2,511 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,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

0 comments on commit 4ee1f30

Please sign in to comment.