Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMatthewLayton committed Jun 18, 2024
2 parents 2b304fa + 71d3e0f commit bc2a01c
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 8 deletions.
4 changes: 2 additions & 2 deletions OnixLabs.Core/OnixLabs.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<Title>OnixLabs.Core</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Core API for .NET</Description>
<AssemblyVersion>8.12.0</AssemblyVersion>
<AssemblyVersion>8.13.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.12.0</PackageVersion>
<PackageVersion>8.13.0</PackageVersion>
</PropertyGroup>
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
Expand Down
4 changes: 2 additions & 2 deletions OnixLabs.Numerics/OnixLabs.Numerics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Title>OnixLabs.Numerics</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Numerics API for .NET</Description>
<AssemblyVersion>8.12.0</AssemblyVersion>
<AssemblyVersion>8.13.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.12.0</PackageVersion>
<PackageVersion>8.13.0</PackageVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
22 changes: 22 additions & 0 deletions OnixLabs.Security.Cryptography/DigitalSignatureAndPublicKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2020 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace OnixLabs.Security.Cryptography;

/// <summary>
/// Represents a pair of a cryptography digital signature, and a named cryptographic public key.
/// </summary>
/// <param name="Signature">The underlying cryptographic digital signature.</param>
/// <param name="Key">The underlying named cryptographic public key.</param>
public readonly record struct DigitalSignatureAndPublicKey(DigitalSignature Signature, NamedPublicKey Key);
40 changes: 40 additions & 0 deletions OnixLabs.Security.Cryptography/NamedPrivateKey.To.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2020 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using OnixLabs.Core.Text;

namespace OnixLabs.Security.Cryptography;

public readonly partial record struct NamedPrivateKey
{
/// <summary>
/// Gets the underlying <see cref="T:Byte[]"/> representation of the underlying <see cref="NamedPrivateKey"/> instance.
/// </summary>
/// <returns>Return the underlying <see cref="T:Byte[]"/> representation of the underlying <see cref="NamedPrivateKey"/> instance.</returns>
public byte[] ToByteArray() => PrivateKey.ToByteArray();

/// <summary>
/// Returns a <see cref="string"/> that represents the current object.
/// </summary>
/// <param name="provider">The format provider that will be used to determine the format of the string.</param>
/// <returns>Returns a <see cref="string"/> that represents the current object.</returns>
public string ToString(IFormatProvider provider) => $"{AlgorithmName}:{IBaseCodec.GetString(ToByteArray(), provider)}";

/// <summary>
/// Returns a <see cref="string"/> that represents the current object.
/// </summary>
/// <returns>Returns a <see cref="string"/> that represents the current object.</returns>
public override string ToString() => ToString(Base16FormatProvider.Invariant);
}
44 changes: 44 additions & 0 deletions OnixLabs.Security.Cryptography/NamedPrivateKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2020 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace OnixLabs.Security.Cryptography;

/// <summary>
/// Represents a named cryptographic private key.
/// </summary>
public readonly partial record struct NamedPrivateKey : ICryptoPrimitive<NamedPrivateKey>
{
private const string KeyAlgorithmNameNullOrWhiteSpace = "Key algorithm name must not be null or whitespace.";

/// <summary>
/// Initializes a new instance of the <see cref="NamedPrivateKey"/> struct.
/// </summary>
/// <param name="privateKey">The underlying private key value.</param>
/// <param name="algorithmName">The name of the key algorithm that was used to produce the associated private key.</param>
public NamedPrivateKey(PrivateKey privateKey, string algorithmName)
{
PrivateKey = privateKey;
AlgorithmName = RequireNotNullOrWhiteSpace(algorithmName, KeyAlgorithmNameNullOrWhiteSpace);
}

/// <summary>
/// Gets the underlying private key value.
/// </summary>
public PrivateKey PrivateKey { get; }

/// <summary>
/// Gets the name of the key algorithm that was used to produce the associated private key.
/// </summary>
public string AlgorithmName { get; }
}
40 changes: 40 additions & 0 deletions OnixLabs.Security.Cryptography/NamedPublicKey.To.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2020 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using OnixLabs.Core.Text;

namespace OnixLabs.Security.Cryptography;

public readonly partial record struct NamedPublicKey
{
/// <summary>
/// Gets the underlying <see cref="T:Byte[]"/> representation of the underlying <see cref="NamedPublicKey"/> instance.
/// </summary>
/// <returns>Return the underlying <see cref="T:Byte[]"/> representation of the underlying <see cref="NamedPublicKey"/> instance.</returns>
public byte[] ToByteArray() => PublicKey.ToByteArray();

/// <summary>
/// Returns a <see cref="string"/> that represents the current object.
/// </summary>
/// <param name="provider">The format provider that will be used to determine the format of the string.</param>
/// <returns>Returns a <see cref="string"/> that represents the current object.</returns>
public string ToString(IFormatProvider provider) => $"{AlgorithmName}:{IBaseCodec.GetString(ToByteArray(), provider)}";

/// <summary>
/// Returns a <see cref="string"/> that represents the current object.
/// </summary>
/// <returns>Returns a <see cref="string"/> that represents the current object.</returns>
public override string ToString() => ToString(Base16FormatProvider.Invariant);
}
44 changes: 44 additions & 0 deletions OnixLabs.Security.Cryptography/NamedPublicKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2020 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace OnixLabs.Security.Cryptography;

/// <summary>
/// Represents a named cryptographic public key.
/// </summary>
public readonly partial record struct NamedPublicKey : ICryptoPrimitive<NamedPublicKey>
{
private const string KeyAlgorithmNameNullOrWhiteSpace = "Key algorithm name must not be null or whitespace.";

/// <summary>
/// Initializes a new instance of the <see cref="NamedPublicKey"/> struct.
/// </summary>
/// <param name="publicKey">The underlying public key value.</param>
/// <param name="algorithmName">The name of the key algorithm that was used to produce the associated public key.</param>
public NamedPublicKey(PublicKey publicKey, string algorithmName)
{
PublicKey = publicKey;
AlgorithmName = RequireNotNullOrWhiteSpace(algorithmName, KeyAlgorithmNameNullOrWhiteSpace);
}

/// <summary>
/// Gets the underlying public key value.
/// </summary>
public PublicKey PublicKey { get; }

/// <summary>
/// Gets the name of the key algorithm that was used to produce the associated public key.
/// </summary>
public string AlgorithmName { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Title>OnixLabs.Security.Cryptography</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Cryptography API for .NET</Description>
<AssemblyVersion>8.12.0</AssemblyVersion>
<AssemblyVersion>8.13.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.12.0</PackageVersion>
<PackageVersion>8.13.0</PackageVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions OnixLabs.Security/OnixLabs.Security.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Title>OnixLabs.Security</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Security API for .NET</Description>
<AssemblyVersion>8.12.0</AssemblyVersion>
<AssemblyVersion>8.13.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.12.0</PackageVersion>
<PackageVersion>8.13.0</PackageVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down

0 comments on commit bc2a01c

Please sign in to comment.