Skip to content

Commit 915fd14

Browse files
committed
fix: convert pfx (used for strong signing) to snk; cant build against pfx.
```shell csc PfxToSnk.cs PfxToSnk.exe bcrypt.pfx YourPfxPassword sn -Tp bin\Release\net10.0\BCrypt.Net-Next-StrongName.dll --- Public key (hash algorithm: sha1): 0024000004800000940000000602000000240000525341310004000001000100fd7d3be24bc7ac e3fe3e8af407bd7c6ad5548f990c2e8cf7cbefcbd9f8cbaf4b201c11c44cbf7cb5cd0492524b5a 4d0ef8683a7f9911c9d75055662147475c2795d89698118d6cc90ebfc007c5608d5812ee4474ec c55f3064ae8fc689e9b227064288c6d6360cdee9c078042db52e93fea6885e10966a5b5743620b c3748aed Public key token is 1e11be04b6288443 ``` Token extracted from nuget package: Assembly BCrypt.Net-Next.StrongName, Version=2.1.3.0, Culture=neutral, PublicKeyToken=1e11be04b6288443
1 parent 1873949 commit 915fd14

7 files changed

Lines changed: 30 additions & 16 deletions

File tree

assets/PfxToSnk.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.IO;
3+
using System.Security.Cryptography;
4+
using System.Security.Cryptography.X509Certificates;
5+
6+
class PfxToSnk
7+
{
8+
static void Main(string[] args)
9+
{
10+
var cert = new X509Certificate2(args[0], args.Length > 1 ? args[1] : "",
11+
X509KeyStorageFlags.Exportable);
12+
var rsa = cert.GetRSAPrivateKey();
13+
var parameters = rsa.ExportParameters(true);
14+
15+
// Re-import into RSACryptoServiceProvider to get the CSP blob
16+
var csp = new RSACryptoServiceProvider();
17+
csp.ImportParameters(parameters);
18+
var blob = csp.ExportCspBlob(true);
19+
20+
File.WriteAllBytes(args[0].Replace(".pfx", ".snk"), blob);
21+
Console.WriteLine("Done. Written " + blob.Length + " bytes.");
22+
}
23+
}

bcrypt.pub

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

bcrypt.snk

436 Bytes
Binary file not shown.

benchmarks/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<PropertyGroup>
1212
<SignAssembly>true</SignAssembly>
1313
<AssemblyOriginatorKeyFile>..\..\bcrypt.snk</AssemblyOriginatorKeyFile>
14-
<DelaySign>true</DelaySign>
14+
<PublicKey>1e11be04b6288443</PublicKey>
15+
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
1516
</PropertyGroup>
1617

1718
<ItemGroup>

src/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<PropertyGroup>
2424
<SignAssembly>true</SignAssembly>
2525
<AssemblyOriginatorKeyFile>..\..\bcrypt.snk</AssemblyOriginatorKeyFile>
26-
<DelaySign>true</DelaySign>
26+
<PublicKey>1e11be04b6288443</PublicKey>
27+
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
2728
</PropertyGroup>
2829

2930
<ItemGroup>

tests/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<PropertyGroup>
1313
<SignAssembly>true</SignAssembly>
1414
<AssemblyOriginatorKeyFile>..\..\bcrypt.snk</AssemblyOriginatorKeyFile>
15-
<DelaySign>true</DelaySign>
15+
<PublicKey>1e11be04b6288443</PublicKey>
16+
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
1617
</PropertyGroup>
1718

1819
<ItemGroup>

tests/UnitTests/BCryptTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void TestSecureHashPasswordFwk()
155155
var secureString = AsSecureString(pass);
156156
if(string.IsNullOrEmpty(pass)) continue;
157157
var hash = BCryptSafeString.HashPassword(secureString);
158-
var doesValidateFromSecureString = BCryptSafeString.VerifyPassword(secureString, hash);
158+
var doesValidateFromSecureString = BCryptSafeString.Verify(secureString, hash);
159159
Assert.True(doesValidateFromSecureString);
160160
var doesValidate = BCrypt.Verify(pass, hash);
161161
Assert.True(doesValidate);

0 commit comments

Comments
 (0)