Skip to content

Commit 96339a4

Browse files
committed
Migrate to .NET 8
1 parent ce5ec08 commit 96339a4

File tree

11 files changed

+40
-50
lines changed

11 files changed

+40
-50
lines changed

src/samples/SampleWebApiProject/SampleWebApiProject.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Bogus" Version="34.0.1" />
9-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
11-
<PackageReference Include="NSwag.AspNetCore" Version="13.14.7" />
8+
<PackageReference Include="Bogus" Version="34.0.2" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
11+
<PackageReference Include="NSwag.AspNetCore" Version="14.0.0-preview010" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

src/samples/SampleWebApiProject/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5252
app.UseAuthorization();
5353

5454
app.UseOpenApi();
55-
app.UseSwaggerUi3();
55+
app.UseSwaggerUi();
5656

5757
app.UseEndpoints(endpoints =>
5858
{

src/src/Harrison314.EntityFrameworkCore.Encryption.Contrib/Harrison314.EntityFrameworkCore.Encryption.Contrib.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<Version>1.2.0</Version>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Version>1.3.0</Version>
66
<Authors>harrison314</Authors>
77
<Product>Harrison314.EntityFrameworkCore.Encryption</Product>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -33,7 +33,7 @@ PKCS#11 Data crypto provider.</Description>
3333
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3434
<PrivateAssets>all</PrivateAssets>
3535
</PackageReference>
36-
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="6.0.0" />
36+
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
3737
</ItemGroup>
3838

3939
<ItemGroup>

src/src/Harrison314.EntityFrameworkCore.Encryption/CryptoProviders/PasswordDbContextEncryptedCryptoProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ValueTask<MasterKeyData> EncryptMasterKey(byte[] masterKey, CancellationT
5050

5151
byte[] encryptedKey = new byte[masterKey.Length];
5252

53-
using AesGcm aes = new AesGcm(key);
53+
using AesGcm aes = new AesGcm(key, passwordData.AesGcmTag.Length);
5454
aes.Encrypt(passwordData.AesGcmNonce, masterKey, encryptedKey, passwordData.AesGcmTag);
5555

5656
MasterKeyData masterKeyData = new MasterKeyData()
@@ -76,15 +76,15 @@ public ValueTask<byte[]> DecryptMasterKey(MasterKeyData masterKeyData, Cancellat
7676
byte[] key = this.DerieveKey(passwordData);
7777

7878
byte[] decryptedKey = new byte[masterKeyData.Data.Length];
79-
using AesGcm aes = new AesGcm(key);
79+
using AesGcm aes = new AesGcm(key, passwordData.AesGcmTag.Length);
8080
aes.Decrypt(passwordData.AesGcmNonce, masterKeyData.Data, passwordData.AesGcmTag, decryptedKey);
8181

8282
return new ValueTask<byte[]>(decryptedKey);
8383
}
8484

8585
private byte[] DerieveKey(PasswordData passwordData, int keySize = 32)
8686
{
87-
using Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(this.passwordData, passwordData.PasswordSalt, passwordData.Iterations);
87+
using Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(this.passwordData, passwordData.PasswordSalt, passwordData.Iterations, HashAlgorithmName.SHA1);
8888
return pbkdf2.GetBytes(keySize);
8989
}
9090

src/src/Harrison314.EntityFrameworkCore.Encryption/EfEncryptionException.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,5 @@ public EfEncryptionException(string message, Exception innerException)
2222
: base(message, innerException)
2323
{
2424
}
25-
26-
protected EfEncryptionException(SerializationInfo info, StreamingContext context)
27-
: base(info, context)
28-
{
29-
}
3025
}
3126
}

src/src/Harrison314.EntityFrameworkCore.Encryption/EfEncryptionScopeNotFoundException.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,5 @@ public EfEncryptionScopeNotFoundException(string message, Exception innerExcepti
2121
: base(message, innerException)
2222
{
2323
}
24-
25-
protected EfEncryptionScopeNotFoundException(SerializationInfo info, StreamingContext context)
26-
: base(info, context)
27-
{
28-
}
2924
}
3025
}

src/src/Harrison314.EntityFrameworkCore.Encryption/Harrison314.EntityFrameworkCore.Encryption.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<Authors>harrison314</Authors>
6-
<Copyright>harrison314 (c) 2022</Copyright>
6+
<Copyright>harrison314 (c) 2023</Copyright>
77
<PackageLicenseExpression>MIT</PackageLicenseExpression>
88
<PackageProjectUrl>https://github.com/harrison314/Harrison314.EntityFrameworkCore.Encryption/</PackageProjectUrl>
99
<RepositoryType>git</RepositoryType>
@@ -12,19 +12,19 @@
1212
Work with any database and using standard cryptographic algorithms (AES, HMAC SHA, SP800-108, PBKDF-2,...).</Description>
1313
<PackageIcon>NugetIcon.png</PackageIcon>
1414
<Nullable>enable</Nullable>
15-
<Version>1.2.0</Version>
15+
<Version>1.3.0</Version>
1616
<PackageTags>EF Core, Entity Framework core, Encryption, Database encryption, Transparent Encryption, AES, AEAD</PackageTags>
17-
<AssemblyVersion>1.2.0.0</AssemblyVersion>
18-
<FileVersion>1.2.0.0</FileVersion>
17+
<AssemblyVersion>1.3.0.0</AssemblyVersion>
18+
<FileVersion>1.3.0.0</FileVersion>
1919
<ImplicitUsings>disable</ImplicitUsings>
2020
</PropertyGroup>
2121

22-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
23-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
24-
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
22+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
23+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
24+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
2525
</ItemGroup>
2626
<ItemGroup>
27-
<PackageReference Include="PkcsExtensions" Version="1.2.1" />
27+
<PackageReference Include="PkcsExtensions" Version="1.3.0" />
2828
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.1.0">
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
<PrivateAssets>all</PrivateAssets>

src/src/Harrison314.EntityFrameworkCore.Encryption/Internal/PropertyEncryptors/AesGcmDeterministicPropertyEncryptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public AesGcmDeterministicPropertyEncryptor(byte[] key, byte[] masterKey, byte[]
3232
{
3333
byte[] reult = new byte[data.Length + TagLen];
3434

35-
using AesGcm aesgcm = new AesGcm(this.key);
35+
using AesGcm aesgcm = new AesGcm(this.key, TagLen);
3636
aesgcm.Encrypt(this.nonce.AsSpan(),
3737
data,
3838
reult.AsSpan(TagLen),
@@ -46,7 +46,7 @@ public AesGcmDeterministicPropertyEncryptor(byte[] key, byte[] masterKey, byte[]
4646
{
4747
byte[] plaintext = new byte[data.Length - TagLen];
4848

49-
using AesGcm aesgcm = new AesGcm(this.key);
49+
using AesGcm aesgcm = new AesGcm(this.key, TagLen);
5050

5151
try
5252
{

src/src/Harrison314.EntityFrameworkCore.Encryption/Internal/PropertyEncryptors/AesGcmRandomizedPropertyEncryptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public AesGcmRandomizedPropertyEncryptor(byte[] key)
3434
seed,
3535
derivedOutput: internalKey);
3636

37-
using AesGcm aesgcm = new AesGcm(internalKey);
37+
using AesGcm aesgcm = new AesGcm(internalKey, TagLen);
3838

3939
aesgcm.Encrypt(reult.AsSpan(SeedLen, NonceLen),
4040
data,
@@ -57,7 +57,7 @@ public AesGcmRandomizedPropertyEncryptor(byte[] key)
5757

5858
byte[] plaintext = new byte[data.Length - (SeedLen + NonceLen + TagLen)];
5959

60-
using AesGcm aesgcm = new AesGcm(internalKey);
60+
using AesGcm aesgcm = new AesGcm(internalKey, TagLen);
6161
try
6262
{
6363
aesgcm.Decrypt(data.AsSpan(SeedLen, NonceLen),

src/test/Harrison314.EntityFrameworkCore.Contrib.Tests/Harrison314.EntityFrameworkCore.Contrib.Tests.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="FluentAssertions" Version="6.2.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.0" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
13-
<PackageReference Include="Moq" Version="4.16.1" />
14-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
15-
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
16-
<PackageReference Include="coverlet.collector" Version="3.1.0">
10+
<PackageReference Include="FluentAssertions" Version="6.12.0" />
11+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
13+
<PackageReference Include="Moq" Version="4.20.69" />
14+
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
15+
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
16+
<PackageReference Include="coverlet.collector" Version="6.0.0">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>

src/test/Harrison314.EntityFrameworkCore.Encryption.Tests/Harrison314.EntityFrameworkCore.Encryption.Tests.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
12-
<PackageReference Include="Moq" Version="4.16.1" />
13-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
14-
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
15-
<PackageReference Include="coverlet.collector" Version="3.1.0">
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
12+
<PackageReference Include="Moq" Version="4.20.69" />
13+
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
14+
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
15+
<PackageReference Include="coverlet.collector" Version="6.0.0">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>

0 commit comments

Comments
 (0)