-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed OpenSsl namespace to LibCrypto and added SPDX license informa…
…tion to comply with REUSE software specification. Also added linking exception to GPL for CompactCryptoGroupAlgebra.LibCrypto.
- Loading branch information
Showing
98 changed files
with
2,010 additions
and
1,028 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 28 additions & 2 deletions
30
...upAlgebra.OpenSsl.Tests/BigNumberTests.cs → ...Algebra.LibCrypto.Tests/BigNumberTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
CompactCryptoGroupAlgebra.LibCrypto.Tests/DiffieHellmanIntegrationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
} |
30 changes: 28 additions & 2 deletions
30
...nSsl.Tests/EllipticCurves/ECPointTests.cs → ...ypto.Tests/EllipticCurves/ECPointTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 28 additions & 2 deletions
30
...lipticCurves/EllipticCurveAlgebraTests.cs → ...lipticCurves/EllipticCurveAlgebraTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
CompactCryptoGroupAlgebra.LibCrypto.Tests/EllipticCurves/NISTP256Reference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
CompactCryptoGroupAlgebra.LibCrypto.Tests/EllipticCurves/PointEncodingLengthTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.