Skip to content

Commit

Permalink
Added strong name signing (#117)
Browse files Browse the repository at this point in the history
* Added strong name signing

* Test to verify strong name is correct
  • Loading branch information
gfoidl authored Mar 17, 2020
1 parent d81bf01 commit 56c45f1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<AssemblyVersion>$(VersionMajor).$(VersionMinor).$(BuildNumber).$(VersionPatch)</AssemblyVersion>
</PropertyGroup>

<PropertyGroup>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)gfoidl.Base64.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup>
<LangVersion>latest</LangVersion>
<StandardTfms>netcoreapp3.0;netstandard2.1;netstandard2.0</StandardTfms>
Expand Down
Binary file added gfoidl.Base64.snk
Binary file not shown.
11 changes: 8 additions & 3 deletions source/gfoidl.Base64/InternalsVisibleTo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("gfoidl.Base64.Benchmarks")]
[assembly: InternalsVisibleTo("gfoidl.Base64.FuzzTests")]
[assembly: InternalsVisibleTo("gfoidl.Base64.Tests")]
[assembly: InternalsVisibleTo("gfoidl.Base64.Benchmarks, Publickey=" + Keys.SignKey)]
[assembly: InternalsVisibleTo("gfoidl.Base64.FuzzTests, Publickey=" + Keys.SignKey)]
[assembly: InternalsVisibleTo("gfoidl.Base64.Tests, Publickey=" + Keys.SignKey)]

internal static class Keys
{
public const string SignKey = "00240000048000009400000006020000002400005253413100040000010001009102c074550e276c36b61e473783fb81bece760951fe0d55c21fe7d8296e174cb41fb4f57a91544f3d597ba044e0278fb2fbb5af1b6fa697e20ca1707f907bb687b73b6ef8ec578404ed49d2206d0f485d4073b88722d92e1f1018e2467800e760b1a8ee478aec551b2975e01ae25140debfae1680042cdd4c80950909a8e8fc";
}
27 changes: 27 additions & 0 deletions tests/gfoidl.Base64.Tests/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Text.RegularExpressions;
using NUnit.Framework;

namespace gfoidl.Base64.Tests
{
[TestFixture]
public class Assembly
{
[Test]
public void StrongName_is_correct()
{
Type type = typeof(Base64);
string assemblyName = type.Assembly.FullName;

Match match = Regex.Match(assemblyName, @"^gfoidl\.Base64, Version=[^,]*, Culture=neutral, PublicKeyToken=(.*)$");

Assert.Multiple(() =>
{
Assert.IsTrue(match.Success);

string publicKeyToken = match.Groups[1].Value;
Assert.AreEqual("6a1c26790d4ba8ae", publicKeyToken);
});
}
}
}

0 comments on commit 56c45f1

Please sign in to comment.