Skip to content

Commit

Permalink
Renamed OpenSsl namespace to LibCrypto and added SPDX license informa…
Browse files Browse the repository at this point in the history
…tion to comply with REUSE software specification.

Also added linking exception to GPL for CompactCryptoGroupAlgebra.LibCrypto.
  • Loading branch information
lumip committed Mar 21, 2021
1 parent d5d1a6e commit cab2f06
Show file tree
Hide file tree
Showing 98 changed files with 2,010 additions and 1,028 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: Lukas Prediger

*/bin/*
*/obj/*
*.suo
/packages/*
/testPackages/*
.vs
.vs*
project.lock.json
CoverageReport/
*coverage*.xml
__Instrumented/
*Coverage*/
small_*curve_check.py
.reuse*
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: Lukas Prediger

language: csharp
os: linux
dist: bionic
Expand All @@ -15,6 +18,6 @@ install:
- dotnet tool install coveralls.net --version 2.0.0 --framework netcoreapp3.1 --tool-path testPackages
script:
- dotnet test CompactCryptoGroupAlgebra.Tests --logger "trx;LogFileName=TestResults.trx" --logger "nunit;LogFileName=TestResults.xml" --results-directory ./CompactCryptoGroupAlgebra.Tests/Coverage /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./Coverage/ /p:Exclude="[nunit.*]*"
- dotnet test CompactCryptoGroupAlgebra.OpenSsl.Tests --logger "trx;LogFileName=TestResults.trx" --logger "nunit;LogFileName=TestResults.xml" --results-directory ./CompactCryptoGroupAlgebra.OpenSsl.Tests/Coverage /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./Coverage/ /p:Exclude=\"[nunit.*]*,[CompactCryptoGroupAlgebra]*,[CompactCryptoGroupAlgebra.Tests]*\" /p:Include="CompactCryptoGroupAlgebra.OpenSsl*"
- dotnet test CompactCryptoGroupAlgebra.LibCrypto.Tests --logger "trx;LogFileName=TestResults.trx" --logger "nunit;LogFileName=TestResults.xml" --results-directory ./CompactCryptoGroupAlgebra.LibCrypto.Tests/Coverage /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./Coverage/ /p:Exclude=\"[nunit.*]*,[CompactCryptoGroupAlgebra]*,[CompactCryptoGroupAlgebra.Tests]*\" /p:Include="CompactCryptoGroupAlgebra.LibCrypto*"
after_success:
- testPackages/csmacnz.Coveralls --useRelativePaths --multiple -i "opencover=CompactCryptoGroupAlgebra.Tests/Coverage/coverage.netcoreapp3.1.opencover.xml;opencover=CompactCryptoGroupAlgebra.OpenSsl.Tests/Coverage/coverage.netcoreapp3.1.opencover.xml" --serviceName travis-ci --jobId $TRAVIS_JOB_ID --commitId $TRAVIS_COMMIT --commitBranch $TRAVIS_BRANCH --commitAuthor "$AUTHOR_NAME" --commitEmail "$COMMITTER_EMAIL" --commitMessage "$TRAVIS_COMMIT_MESSAGE" --pullRequest $TRAVIS_PULL_REQUEST
- testPackages/csmacnz.Coveralls --useRelativePaths --multiple -i "opencover=CompactCryptoGroupAlgebra.Tests/Coverage/coverage.netcoreapp3.1.opencover.xml;opencover=CompactCryptoGroupAlgebra.LibCrypto.Tests/Coverage/coverage.netcoreapp3.1.opencover.xml" --serviceName travis-ci --jobId $TRAVIS_JOB_ID --commitId $TRAVIS_COMMIT --commitBranch $TRAVIS_BRANCH --commitAuthor "$AUTHOR_NAME" --commitEmail "$COMMITTER_EMAIL" --commitMessage "$TRAVIS_COMMIT_MESSAGE" --pullRequest $TRAVIS_PULL_REQUEST
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: Lukas Prediger

- 2.0.0-alpha
- Fix: MultiplicativeGroupAlgebra.Negate now works correctly for all elements
in the prime field, not only the subgroup.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
// CompactCryptoGroupAlgebra.LibCrypto - OpenSSL libcrypto implementation of CompactCryptoGroupAlgebra interfaces

// SPDX-FileCopyrightText: 2021 Lukas Prediger <lumip@lumip.de>
// SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
// SPDX-FileType: SOURCE

// CompactCryptoGroupAlgebra.LibCrypto is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CompactCryptoGroupAlgebra.LibCrypto is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify CompactCryptoGroupAlgebra.LibCrypto, or any covered work, by linking or combining it
// with the OpenSSL library (or a modified version of that library), containing parts covered by the
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
// grant you additional permission to convey the resulting work.

using NUnit.Framework;

using System;
using System.Numerics;

using CompactCryptoGroupAlgebra.OpenSsl.Internal.Native;
using CompactCryptoGroupAlgebra.LibCrypto.Internal.Native;

namespace CompactCryptoGroupAlgebra.OpenSsl
namespace CompactCryptoGroupAlgebra.LibCrypto
{
public class BigNumberTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<!--
CompactCryptoGroupAlgebra - C# implementation of abelian group algebra for experimental cryptography
SPDX-FileCopyrightText: 2020-2021 Lukas Prediger <lumip@lumip.de>
SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
SPDX-FileType: SOURCE
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<AssemblyName>CompactCryptoGroupAlgebra.OpenSsl.Tests</AssemblyName>
<RootNamespace>CompactCryptoGroupAlgebra.OpenSsl</RootNamespace>
<AssemblyName>CompactCryptoGroupAlgebra.LibCrypto.Tests</AssemblyName>
<RootNamespace>CompactCryptoGroupAlgebra.LibCrypto</RootNamespace>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<WarningsAsErrors>CS8602;CS8603;CS8600;CS8625;CS8610</WarningsAsErrors>
<Title>CompactCryptoGroupAlgebra.OpenSsl Unit Tests</Title>
<Title>CompactCryptoGroupAlgebra.LibCrypto Unit Tests</Title>
<Authors>Lukas "lumip" Prediger</Authors>
<Description>Tests for the CompactCryptoGroupAlgebra.OpenSsl Library Extension</Description>
<Description>Tests for the CompactCryptoGroupAlgebra.LibCrypto Library Extension</Description>
<Copyright>Copyright © 2021 Lukas Prediger</Copyright>
</PropertyGroup>

Expand All @@ -28,7 +35,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../CompactCryptoGroupAlgebra.OpenSsl/CompactCryptoGroupAlgebra.OpenSsl.csproj" />
<ProjectReference Include="../CompactCryptoGroupAlgebra.LibCrypto/CompactCryptoGroupAlgebra.LibCrypto.csproj" />
<ProjectReference Include="../CompactCryptoGroupAlgebra.Tests/CompactCryptoGroupAlgebra.Tests.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// CompactCryptoGroupAlgebra.LibCrypto - OpenSSL libcrypto implementation of CompactCryptoGroupAlgebra interfaces

// SPDX-FileCopyrightText: 2021 Lukas Prediger <lumip@lumip.de>
// SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
// SPDX-FileType: SOURCE

// CompactCryptoGroupAlgebra.LibCrypto is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CompactCryptoGroupAlgebra.LibCrypto is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify CompactCryptoGroupAlgebra.LibCrypto, or any covered work, by linking or combining it
// with the OpenSSL library (or a modified version of that library), containing parts covered by the
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
// grant you additional permission to convey the resulting work.

using NUnit.Framework;

using System.Numerics;
using System.Text.RegularExpressions;
using System.Globalization;

using CompactCryptoGroupAlgebra.LibCrypto.EllipticCurves;
using CompactCryptoGroupAlgebra.LibCrypto.Multiplicative;

namespace CompactCryptoGroupAlgebra.LibCrypto
{
public class DiffieHellmanIntegrationTests
{

[Test]
public void TestDiffieHellmanWithNISTPrime256v1Curve()
{
var curveAlgebra = new EllipticCurveAlgebra(EllipticCurveID.Prime256v1);
var group = new CryptoGroup<SecureBigNumber, ECPoint>(curveAlgebra);
CompactCryptoGroupAlgebra.DiffieHellmanIntegrationTests.DoDiffieHellman(group);
}

[Test]
public void TestDiffieHellmanWithMultiplicativeGroup()
{
string primeHex = @"0
FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF";

BigPrime prime = BigPrime.CreateWithoutChecks(
BigInteger.Parse(Regex.Replace(primeHex, @"\s+", ""), NumberStyles.AllowHexSpecifier)
);
BigPrime order = BigPrime.CreateWithoutChecks((prime - 1) / 2);
BigNumber generator = new BigNumber(4);

var algebra = new MultiplicativeGroupAlgebra(prime, order, generator);
var group = new CryptoGroup<SecureBigNumber, BigNumber>(algebra);

CompactCryptoGroupAlgebra.DiffieHellmanIntegrationTests.DoDiffieHellman(group);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
// CompactCryptoGroupAlgebra.LibCrypto - OpenSSL libcrypto implementation of CompactCryptoGroupAlgebra interfaces

// SPDX-FileCopyrightText: 2021 Lukas Prediger <lumip@lumip.de>
// SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
// SPDX-FileType: SOURCE

// CompactCryptoGroupAlgebra.LibCrypto is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CompactCryptoGroupAlgebra.LibCrypto is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify CompactCryptoGroupAlgebra.LibCrypto, or any covered work, by linking or combining it
// with the OpenSSL library (or a modified version of that library), containing parts covered by the
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
// grant you additional permission to convey the resulting work.

using NUnit.Framework;
using System;

using CompactCryptoGroupAlgebra.OpenSsl.Internal.Native;
using CompactCryptoGroupAlgebra.LibCrypto.Internal.Native;

namespace CompactCryptoGroupAlgebra.OpenSsl.EllipticCurves
namespace CompactCryptoGroupAlgebra.LibCrypto.EllipticCurves
{
class ECPointTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
// CompactCryptoGroupAlgebra.LibCrypto - OpenSSL libcrypto implementation of CompactCryptoGroupAlgebra interfaces

// SPDX-FileCopyrightText: 2021 Lukas Prediger <lumip@lumip.de>
// SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
// SPDX-FileType: SOURCE

// CompactCryptoGroupAlgebra.LibCrypto is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CompactCryptoGroupAlgebra.LibCrypto is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify CompactCryptoGroupAlgebra.LibCrypto, or any covered work, by linking or combining it
// with the OpenSSL library (or a modified version of that library), containing parts covered by the
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
// grant you additional permission to convey the resulting work.

using NUnit.Framework;
using System;
using System.Numerics;
using System.Security.Cryptography;

using CompactCryptoGroupAlgebra.OpenSsl.Internal.Native;
using CompactCryptoGroupAlgebra.LibCrypto.Internal.Native;

namespace CompactCryptoGroupAlgebra.OpenSsl.EllipticCurves
namespace CompactCryptoGroupAlgebra.LibCrypto.EllipticCurves
{
class EllipticCurveAlgebraTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// CompactCryptoGroupAlgebra.LibCrypto - OpenSSL libcrypto implementation of CompactCryptoGroupAlgebra interfaces

// SPDX-FileCopyrightText: 2021 Lukas Prediger <lumip@lumip.de>
// SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
// SPDX-FileType: SOURCE

// CompactCryptoGroupAlgebra.LibCrypto is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CompactCryptoGroupAlgebra.LibCrypto is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify CompactCryptoGroupAlgebra.LibCrypto, or any covered work, by linking or combining it
// with the OpenSSL library (or a modified version of that library), containing parts covered by the
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
// grant you additional permission to convey the resulting work.

using System.Numerics;

namespace CompactCryptoGroupAlgebra.LibCrypto.EllipticCurves
{

class NISTP256Reference
{
// Curve parameters, Appendix D: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf

public static BigPrime Prime = BigPrime.CreateWithoutChecks(BigInteger.Parse("0115792089210356248762697446949407573530086143415290314195533631308867097853951", System.Globalization.NumberStyles.Integer));

public static BigPrime Order = BigPrime.CreateWithoutChecks(BigInteger.Parse("0115792089210356248762697446949407573529996955224135760342422259061068512044369", System.Globalization.NumberStyles.Integer));

public static BigInteger generatorX = BigInteger.Parse("06B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", System.Globalization.NumberStyles.HexNumber);

public static BigInteger generatorY = BigInteger.Parse("04FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", System.Globalization.NumberStyles.HexNumber);

public static BigInteger Cofactor = BigInteger.One;

public static int ElementBitLength = NumberLength.GetLength(Prime).InBits;

public static int OrderBitLength = NumberLength.GetLength(Order).InBits;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// CompactCryptoGroupAlgebra.LibCrypto - OpenSSL libcrypto implementation of CompactCryptoGroupAlgebra interfaces

// SPDX-FileCopyrightText: 2021 Lukas Prediger <lumip@lumip.de>
// SPDX-License-Identifier: GPL-3.0-or-later WITH GPL-3.0-linking-exception
// SPDX-FileType: SOURCE

// CompactCryptoGroupAlgebra.LibCrypto is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CompactCryptoGroupAlgebra.LibCrypto is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify CompactCryptoGroupAlgebra.LibCrypto, or any covered work, by linking or combining it
// with the OpenSSL library (or a modified version of that library), containing parts covered by the
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
// grant you additional permission to convey the resulting work.

using NUnit.Framework;

namespace CompactCryptoGroupAlgebra.LibCrypto.EllipticCurves
{

class PointEncodingLengthTests
{
[Test]
public void TestGetEncodingBitLengthCompressed()
{
var elementBitLength = 10;
var expected = 18;

var result = PointEncodingLength.GetEncodingBitLength(PointEncoding.Compressed, elementBitLength);
Assert.That(result == expected);
}

[Test]
public void TestGetEncodingBitLengthUncompressed()
{
var elementBitLength = 10;
var expected = 28;

var result = PointEncodingLength.GetEncodingBitLength(PointEncoding.Uncompressed, elementBitLength);
Assert.That(result == expected);
}

[Test]
public void TestGetEncodingBitLengthHybrid()
{
var elementBitLength = 10;
var expected = 28;

var result = PointEncodingLength.GetEncodingBitLength(PointEncoding.Hybrid, elementBitLength);
Assert.That(result == expected);
}
}

}

0 comments on commit cab2f06

Please sign in to comment.