Skip to content

Commit de0fcf7

Browse files
Merge branch 'dev'
2 parents 7f38b9e + 7a21a88 commit de0fcf7

File tree

69 files changed

+11731
-2358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+11731
-2358
lines changed

.github/workflows/semgrep-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
uses: github/codeql-action/upload-sarif@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 #v3.30.5
3939
with:
4040
sarif_file: semgrep.sarif
41-
if: always()
41+
if: always()

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Release 2025-12-17 #2
2+
3+
### Amazon.Extensions.S3.Encryption (4.0.0)
4+
* feat:add ability to encrypt/decrypt with AES GCM with Key commitment
5+
16
## Release 2025-11-12
27

38
### Amazon.Extensions.S3.Encryption (3.1.0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The AmazonS3EncryptionClientV2 supports the following encryption methods for enc
1414
* RSA-OAEP-SHA1
1515
* AES-GCM
1616

17-
Object content is encrypted using AES-GCM with generated DEKs which are stored in the S3 object metadata or in a separate instruction file (as configured).
17+
Object content is encrypted using committing AES-GCM (default) with generated DEKs which are stored in the S3 object metadata or in a separate instruction file (as configured).
1818

1919
# Code examples and API Documentation
2020

SUPPORT_POLICY.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Overview
2+
========
3+
This page describes the support policy for the Amazon S3 Encryption Client for .NET. We regularly provide the Amazon S3 Encryption Client for .NET with updates that may contain support for new or updated APIs, new features, enhancements, bug fixes, security patches, or documentation updates. Updates may also address changes with dependencies, language runtimes, and operating systems.
4+
5+
We recommend users to stay up-to-date with Amazon S3 Encryption Client for .NET releases to keep up with the latest features, security updates, and underlying dependencies. Continued use of an unsupported SDK version is not recommended and is done at the user's discretion.
6+
7+
8+
Major Version Lifecycle
9+
========================
10+
The Amazon S3 Encryption Client for .NET follows the same major version lifecycle as the AWS SDK. For details on this lifecycle, see `AWS SDKs and Tools Maintenance Policy`_.
11+
12+
Version Support Matrix
13+
======================
14+
This table describes the current support status of each major version of the Amazon S3 Encryption Client for .NET. It also shows the next status each major version will transition to, and the date at which that transition will happen.
15+
16+
.. list-table::
17+
:widths: 30 50 50 50
18+
:header-rows: 1
19+
20+
* - Major version
21+
- Current status
22+
- Next status
23+
- Next status date
24+
* - 4.x
25+
- General Availability
26+
-
27+
-
28+
* - 3.x
29+
- General Availability
30+
- Maintenance
31+
-
32+
* - 2.x
33+
- General Availability
34+
- Maintenance
35+
- March 1, 2026
36+
37+
.. _AWS SDKs and Tools Maintenance Policy: https://docs.aws.amazon.com/sdkref/latest/guide/maint-policy.html#version-life-cycle

docs/index.md

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,32 @@ _layout: landing
77
## Overview
88

99
These are the API docs for the Amazon S3 Encryption client for .NET. There exist two (2) clients in this product:
10-
* AmazonS3EncryptionClient
1110
* AmazonS3EncryptionClientV2
11+
* AmazonS3EncryptionClientV4
1212

13-
The AmazonS3EncryptionClient has an identical API to the obsolete client that is in the AWS SDK for .NET. The main difference is
14-
that this client can also decrypt AmazonS3EncryptionClientV2 encrypted objects.
13+
The AmazonS3EncryptionClientV2 has an identical API to the AmazonS3EncryptionClientV4 that is in the AWS SDK for .NET. The main difference is
14+
that AmazonS3EncryptionClientV2 can only decrypt message with content encryption AesGcmWithCommitment, while AmazonS3EncryptionClientV4 can encrypt or decrypt
15+
message with content encryption AesGcmWithCommitment. It is recommended to use AesGcmWithCommitment instead of AesGcm without key commitment because key commitment
16+
prevents attackers from crafting ciphertexts that decrypt to different plaintexts under different keys, protecting against key substitution attacks when on instruction file mode.
1517

16-
## How to use the AmazonS3EncryptionClientV2 client
18+
## How to use the AmazonS3EncryptionClientV4 client
1719

18-
The AmazonS3EncryptionClientV2 supports the following encryption methods for encrypting DEKs (Data encryption keys):
20+
The AmazonS3EncryptionClientV4 supports the following encryption methods for encrypting DEKs (Data encryption keys):
1921

2022
* AWS supplied KEK (key encryption key):
2123
* AWS KMS + Context
2224
* User supplied KEK:
2325
* RSA-OAEP-SHA1
2426
* AES-GCM
2527

26-
Object content is encrypted using AES-GCM with generated DEKs which are stored in the S3 object metadata or in a separate instruction file (as configured).
28+
Object content is encrypted using committing AES-GCM (default) with generated DEKs which are stored in the S3 object metadata or in a separate instruction file (as configured).
29+
2730

2831
### Data Key Encryption
2932

3033
#### AWS KMS + Context
3134

32-
To use "AWS KMS + Context", you must supply an EncryptionMaterialsV2 instance with the following information:
35+
To use "AWS KMS + Context", you must supply an EncryptionMaterialsV4 instance with the following information:
3336

3437
* A KMS key id
3538
* This id will be used in decryption as well. If the id specified is not the key used to encrypt the object, decryption will fail.
@@ -40,39 +43,57 @@ To use "AWS KMS + Context", you must supply an EncryptionMaterialsV2 instance wi
4043
```csharp
4144
var encryptionContext = new Dictionary<string, string>();
4245
var encryptionMaterial =
43-
new EncryptionMaterialsV2("1234abcd-12ab-34cd-56ef-1234567890ab", KmsType.KmsContext, encryptionContext);
44-
var configuration = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2);
45-
var encryptionClient = new AmazonS3EncryptionClientV2(configuration, encryptionMaterial);
46+
new EncryptionMaterialsV4("1234abcd-12ab-34cd-56ef-1234567890ab", KmsType.KmsContext, encryptionContext);
47+
var configuration = new AmazonS3CryptoConfigurationV4(SecurityProfile.V4, CommitmentPolicy.RequireEncryptRequireDecrypt, ContentEncryptionAlgorithm.AesGcmWithCommitment);
48+
var encryptionClient = new AmazonS3EncryptionClientV4(configuration, encryptionMaterial);
4649
```
4750

4851
#### RSA-OAEP-SHA1
4952

50-
To use "RSA-OAEP-SHA1", you must supply an EncryptionMaterialsV2 instance with the following information:
53+
To use "RSA-OAEP-SHA1", you must supply an EncryptionMaterialsV4 instance with the following information:
5154

5255
* A RSA instance containing the encryption materials.
5356
* Which algorithm to use (AsymmetricAlgorithmType.RsaOaepSha1)
5457

5558
```csharp
5659
var asymmetricAlgorithm = RSA.Create();
57-
var encryptionMaterial = new EncryptionMaterialsV2(asymmetricAlgorithm, AsymmetricAlgorithmType.RsaOaepSha1);
58-
var configuration = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2);
59-
var encryptionClient = new AmazonS3EncryptionClientV2(configuration, encryptionMaterial);
60+
var encryptionMaterial = new EncryptionMaterialsV4(asymmetricAlgorithm, AsymmetricAlgorithmType.RsaOaepSha1);
61+
var configuration = new AmazonS3CryptoConfigurationV4(SecurityProfile.V4, CommitmentPolicy.RequireEncryptRequireDecrypt, ContentEncryptionAlgorithm.AesGcmWithCommitment);
62+
var encryptionClient = new AmazonS3EncryptionClientV4(configuration, encryptionMaterial);
6063
```
6164

6265
#### AES-GCM
6366

64-
To use "AES-GCM", you must supply an EncryptionMaterialsV2 instance with the following information:
67+
To use "AES-GCM", you must supply an EncryptionMaterialsV4 instance with the following information:
6568

6669
* An Aes instance containing the encryption materials.
6770
* Which algorithm to use (SymmetricAlgorithmType.AesGcm)
6871

6972
```csharp
7073
var symmetricAlgorithm = Aes.Create();
71-
var encryptionMaterial = new EncryptionMaterialsV2(symmetricAlgorithm, SymmetricAlgorithmType.AesGcm);
72-
var configuration = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2);
73-
var encryptionClient = new AmazonS3EncryptionClientV2(configuration, encryptionMaterial);
74+
var encryptionMaterial = new EncryptionMaterialsV4(symmetricAlgorithm, SymmetricAlgorithmType.AesGcm);
75+
var configuration = new AmazonS3CryptoConfigurationV4(SecurityProfile.V4, CommitmentPolicy.RequireEncryptRequireDecrypt, ContentEncryptionAlgorithm.AesGcmWithCommitment);
76+
var encryptionClient = new AmazonS3EncryptionClientV4(configuration, encryptionMaterial);
7477
```
7578

79+
### CommitmentPolicy and ContentEncryptionAlgorithm
80+
81+
Starting with Amazon S3 Encryption Client for .NET V4, you can encrypt objects with AES-GCM with key commitment (default for V4), which protects your data against key substitution attacks. To help you migrate from AES-GCM to AES-GCM with key commitment, this version includes three commitment policies.
82+
83+
For more information, see [S3 Encryption Client Migration (V2 to V4)](https://docs.aws.amazon.com/sdk-for-net/v4/developer-guide/s3-encryption-migration-v2-v4.html).
84+
85+
* ForbidEncryptAllowDecrypt:
86+
* With ForbidEncryptAllowDecrypt CommitmentPolicy, the client continues to encrypt objects without key commitment and can decrypt both non-key-committing objects and key-committing objects encrypted with AES GCM with commitment.
87+
* Because this policy encrypts with AES-GCM without key commitment, it does not enforce commitment and may allow keys in Instruction Files to be tampered with which does not protect against key substitution attacks.
88+
89+
* RequireEncryptAllowDecrypt
90+
* With RequireEncryptAllowDecrypt CommitmentPolicy, the client starts encrypting objects with key commitment (AES-GCM with key commitment) and can still decrypt objects encrypted without key commitment.
91+
* This policy protects newly encrypted objects against key substitution attacks while maintaining backward compatibility for decryption.
92+
93+
* RequireEncryptRequireDecrypt (default for V4)
94+
* With RequireEncryptRequireDecrypt CommitmentPolicy, the client will no longer decrypt objects encrypted without key commitment (AES-GCM without key commitment) and cannot decrypt objects encrypted without key commitment.
95+
* This policy fully enforces key commitment and protects against key substitution attacks.
96+
7697
### Storage Mode
7798

7899
You can specify a storage mode for the encrypted data key and associated metadata needed for decryption of an object:
@@ -82,32 +103,32 @@ You can specify a storage mode for the encrypted data key and associated metadat
82103
* InstructionFile
83104
* Stores the data in a separate S3 object
84105

85-
This can be set on the AmazonS3CryptoConfigurationV2 instance:
106+
This can be set on the AmazonS3CryptoConfigurationV4 instance:
86107

87108
```csharp
88-
var configuration = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2)
109+
var configuration = new AmazonS3CryptoConfigurationV4(SecurityProfile.V4)
89110
{
90111
StorageMode.InstructionFile
91112
}
92113
```
93114

94115
### Security Profile
95116

96-
A security profile setting needs to be passed to the constructor of the AmazonS3CryptoConfigurationV2 instance, either:
117+
A security profile setting needs to be passed to the constructor of the AmazonS3CryptoConfigurationV4 instance, either:
97118

98-
* V2
99-
* V2AndLegacy
119+
* V4
120+
* V4AndLegacy
100121

101-
Unless you are migrating existing applications, use V2. If you need leagcy mode:
122+
Unless you are migrating existing applications from legacy content encryption message format (message encrypted with AmazonS3EncryptionClient which uses AES CBC), use V4. If you need legacy mode:
102123

103124
```csharp
104-
var configuration = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2AndLegacy);
125+
var configuration = new AmazonS3CryptoConfigurationV4(SecurityProfile.V4AndLegacy);
105126
```
106127

107128
### Multipart Uploads
108129

109-
The AmazonS3EncryptionClientV2 extends the base AmazonS3Client. You can use multipart upload using the same APIs: <https://docs.aws.amazon.com/AmazonS3/latest/dev/LLuploadFileDotNet.html>
130+
The AmazonS3EncryptionClientV4 extends the base AmazonS3Client. You can use multipart upload using the same APIs: <https://docs.aws.amazon.com/AmazonS3/latest/dev/LLuploadFileDotNet.html>
110131

111132
### Transfer Utility Integration
112133

113-
The AmazonS3EncryptionClientV2 extends the base AmazonS3Client. You can use the TransferUtility just as you would using the base AmazonS3Client: <https://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileDotNet.html>
134+
The AmazonS3EncryptionClientV4 extends the base AmazonS3Client. You can use the TransferUtility just as you would using the base AmazonS3Client: <https://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileDotNet.html>

src/Amazon.Extensions.S3.Encryption.csproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net472;netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks>
5-
<Version>3.1.0</Version>
5+
<Version>4.0.0</Version>
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77
<PackageId>Amazon.Extensions.S3.Encryption</PackageId>
88
<Title>Amazon S3 Encryption Client for .NET</Title>
@@ -53,4 +53,13 @@
5353
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
5454
</ItemGroup>
5555

56+
<ItemGroup>
57+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
58+
<_Parameter1>Amazon.Extensions.S3.Encryption.UnitTests,PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4</_Parameter1>
59+
</AssemblyAttribute>
60+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
61+
<_Parameter1>Amazon.Extensions.S3.Encryption.IntegrationTests.NetFramework,PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4</_Parameter1>
62+
</AssemblyAttribute>
63+
</ItemGroup>
64+
5665
</Project>

src/AmazonS3CryptoConfiguration.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/AmazonS3CryptoConfigurationBase.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,35 @@ namespace Amazon.Extensions.S3.Encryption
2828
/// </summary>
2929
public abstract class AmazonS3CryptoConfigurationBase: AmazonS3Config
3030
{
31+
//= ../specification/s3-encryption/client.md#instruction-file-configuration
32+
//# The S3EC MAY support the option to provide Instruction File Configuration during its initialization.
33+
34+
//= ../specification/s3-encryption/client.md#instruction-file-configuration
35+
//# If the S3EC in a given language supports Instruction Files, then it MUST accept Instruction File Configuration during its initialization.
36+
3137
/// <summary>
3238
/// Gets and sets the StorageMode property. This determines if the crypto metadata is stored as metadata on the object or as a separate object in S3.
3339
/// The default is ObjectMetadata.
3440
/// </summary>
3541
public CryptoStorageMode StorageMode { get; set; }
42+
43+
//= ../specification/s3-encryption/data-format/metadata-strategy.md#instruction-file
44+
//= type=implication
45+
//# Instruction File writes MUST be optionally configured during client creation or on each PutObject request.
3646

3747
/// <summary>
3848
/// Default Constructor.
3949
/// </summary>
4050
public AmazonS3CryptoConfigurationBase()
4151
{
42-
// By default, store encryption info in metadata
52+
//= ../specification/s3-encryption/data-format/metadata-strategy.md#object-metadata
53+
//# By default, the S3EC MUST store content metadata in the S3 Object Metadata.
54+
55+
//= ../specification/s3-encryption/data-format/metadata-strategy.md#instruction-file
56+
//# Instruction File writes MUST NOT be enabled by default.
57+
58+
//= ../specification/s3-encryption/client.md#instruction-file-configuration
59+
//# In this case, the Instruction File Configuration SHOULD be optional, such that its default configuration is used when none is provided.
4360
StorageMode = CryptoStorageMode.ObjectMetadata;
4461
}
4562
/// <summary>

0 commit comments

Comments
 (0)