Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cas-core-lib
4 changes: 2 additions & 2 deletions cas-dotnet-sdk/Asymmetric/Types/RsaKeyPairResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class RsaKeyPairResult
{
public string PublicKey { get; set; }
public string PrivateKey { get; set; }
public string PublicKey { get; set; } = string.Empty;
public string PrivateKey { get; set; } = string.Empty;
}
}
4 changes: 2 additions & 2 deletions cas-dotnet-sdk/Asymmetric/Types/RsaSignResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class RsaSignResult
{
public string Signature { get; set; }
public string PublicKey { get; set; }
public string Signature { get; set; } = string.Empty;
public string PublicKey { get; set; } = string.Empty;
}
}
4 changes: 2 additions & 2 deletions cas-dotnet-sdk/Helpers/NativeString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static string ReadAndFree(byte* ptr)
{
if (ptr == null)
{
return null;
return string.Empty;
}
string value = Marshal.PtrToStringUTF8((IntPtr)ptr);
string value = Marshal.PtrToStringUTF8((IntPtr)ptr) ?? string.Empty;
NativeMethods.free_cstring(ptr);
return value;
}
Expand Down
10 changes: 6 additions & 4 deletions cas-dotnet-sdk/Hybrid/Types/HpkeEncryptResult.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace CasDotnetSdk.Hybrid.Types
using System;

namespace CasDotnetSdk.Hybrid.Types
{
public class HpkeEncryptResult
{
public byte[] EncappedKey { get; set; }
public byte[] Ciphertext { get; set; }
public byte[] Tag { get; set; }
public byte[] EncappedKey { get; set; } = Array.Empty<byte>();
public byte[] Ciphertext { get; set; } = Array.Empty<byte>();
public byte[] Tag { get; set; } = Array.Empty<byte>();
}
}
10 changes: 6 additions & 4 deletions cas-dotnet-sdk/Hybrid/Types/HpkeKeyPairResult.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace CasDotnetSdk.Hybrid.Types
using System;

namespace CasDotnetSdk.Hybrid.Types
{
public class HpkeKeyPairResult
{
public byte[] PrivateKey { get; set; }
public byte[] PublicKey { get; set; }
public byte[] InfoStr { get; set; }
public byte[] PrivateKey { get; set; } = Array.Empty<byte>();
public byte[] PublicKey { get; set; } = Array.Empty<byte>();
public byte[] InfoStr { get; set; } = Array.Empty<byte>();
}
}
8 changes: 5 additions & 3 deletions cas-dotnet-sdk/KeyExchange/Types/X25519SecretPublicKey.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace CasDotnetSdk.KeyExchange.Types
using System;

namespace CasDotnetSdk.KeyExchange.Types
{
public class X25519SecretPublicKey
{
public byte[] SecretKey { get; set; }
public byte[] PublicKey { get; set; }
public byte[] SecretKey { get; set; } = Array.Empty<byte>();
public byte[] PublicKey { get; set; } = Array.Empty<byte>();
}
}
6 changes: 4 additions & 2 deletions cas-dotnet-sdk/KeyExchange/Types/X25519SharedSecret.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace CasDotnetSdk.KeyExchange.Types
using System;

namespace CasDotnetSdk.KeyExchange.Types
{
public class X25519SharedSecret
{
public byte[] SharedSecret { get; set; }
public byte[] SharedSecret { get; set; } = Array.Empty<byte>();
}
}
6 changes: 4 additions & 2 deletions cas-dotnet-sdk/PQC/Types/SLHDSAKeyPair.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;

namespace CasDotnetSdk.PQC.Types
{
public class SLHDSAKeyPair
{
public byte[] SigningKey { get; set; }
public byte[] VerificationKey { get; set; }
public byte[] SigningKey { get; set; } = Array.Empty<byte>();
public byte[] VerificationKey { get; set; } = Array.Empty<byte>();
}
}
23 changes: 9 additions & 14 deletions cas-dotnet-sdk/PasswordHashers/PasswordHasherFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace CasDotnetSdk.PasswordHashers
using System;

namespace CasDotnetSdk.PasswordHashers
{
public enum PasswordHasherType
{
Expand All @@ -11,20 +13,13 @@ public static class PasswordHasherFactory
{
public static IPasswordHasherBase Get(PasswordHasherType type)
{
IPasswordHasherBase hasher = null;
switch (type)
return type switch
{
case PasswordHasherType.Argon2:
hasher = new Argon2Wrapper();
break;
case PasswordHasherType.BCrypt:
hasher = new BcryptWrapper();
break;
case PasswordHasherType.SCrypt:
hasher = new SCryptWrapper();
break;
}
return hasher;
PasswordHasherType.Argon2 => new Argon2Wrapper(),
PasswordHasherType.BCrypt => new BcryptWrapper(),
PasswordHasherType.SCrypt => new SCryptWrapper(),
_ => throw new ArgumentOutOfRangeException(nameof(type), type, "Unsupported password hasher type.")
};
}
}
}
12 changes: 6 additions & 6 deletions cas-dotnet-sdk/Signatures/ED25519Wrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public Ed25519ByteSignatureResult SignBytes(byte[] keyBytes, byte[] dataToSign)
/// </summary>
public bool VerifyBytes(byte[] keyPair, byte[] signature, byte[] dataToVerify)
{
if (keyPair?.Length == 0)
if (keyPair == null || keyPair.Length == 0)
{
throw new Exception("You must provide allocated key pair data to Verify Bytes with ED25519-Dalek");
}
if (signature?.Length == 0)
if (signature == null || signature.Length == 0)
{
throw new Exception("You must provide allocated signature data to Verify Bytes with ED25519-Dalek");
}
if (dataToVerify?.Length == 0)
if (dataToVerify == null || dataToVerify.Length == 0)
{
throw new Exception("You must provide allocated data to Verify with ED25519-Dalek");
}
Expand All @@ -89,15 +89,15 @@ public bool VerifyBytes(byte[] keyPair, byte[] signature, byte[] dataToVerify)
/// </summary>
public bool VerifyWithPublicKeyBytes(byte[] publicKey, byte[] signature, byte[] dataToVerify)
{
if (publicKey?.Length == 0)
if (publicKey == null || publicKey.Length == 0)
{
throw new Exception("You must provide allocated data for the public key to verify with ED25519-Dalek");
}
if (signature?.Length == 0)
if (signature == null || signature.Length == 0)
{
throw new Exception("You must provide allocated data for the signature to verify with ED25519-Dalek");
}
if (dataToVerify?.Length == 0)
if (dataToVerify == null || dataToVerify.Length == 0)
{
throw new Exception("You must provide allocated data to verify for the signature to verify with ED25519-Dalek");
}
Expand Down
8 changes: 5 additions & 3 deletions cas-dotnet-sdk/Signatures/Types/Ed25519ByteSignatureResult.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace CasDotnetSdk.Signatures.Types
using System;

namespace CasDotnetSdk.Signatures.Types
{
public class Ed25519ByteSignatureResult
{
public byte[] Signature { get; set; }
public byte[] PublicKey { get; set; }
public byte[] Signature { get; set; } = Array.Empty<byte>();
public byte[] PublicKey { get; set; } = Array.Empty<byte>();
}
}
8 changes: 5 additions & 3 deletions cas-dotnet-sdk/Signatures/Types/Ed25519KeyPairResult.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace CasDotnetSdk.Signatures.Types
using System;

namespace CasDotnetSdk.Signatures.Types
{
public class Ed25519KeyPairResult
{
public byte[] SigningKey { get; set; }
public byte[] VerifyingKey { get; set; }
public byte[] SigningKey { get; set; } = Array.Empty<byte>();
public byte[] VerifyingKey { get; set; } = Array.Empty<byte>();
}
}
4 changes: 2 additions & 2 deletions cas-dotnet-sdk/Signatures/Types/Ed25519SignatureResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class Ed25519SignatureResult
{
public string Signature { get; set; }
public string PublicKey { get; set; }
public string Signature { get; set; } = string.Empty;
public string PublicKey { get; set; } = string.Empty;
}
}
8 changes: 4 additions & 4 deletions cas-dotnet-sdk/Sponges/AsconWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public byte[] Ascon128Nonce()
/// </summary>
public byte[] Ascon128Encrypt(byte[] nonce, byte[] key, byte[] toEncrypt)
{
if (nonce?.Length == 0)
if (nonce == null || nonce.Length == 0)
{
throw new Exception("You must provide a nonce to encrypt with Ascon 128");
}
if (key?.Length == 0)
if (key == null || key.Length == 0)
{
throw new Exception("You must provide a key to encrypt with Ascon 128");
}
Expand All @@ -61,11 +61,11 @@ public byte[] Ascon128Encrypt(byte[] nonce, byte[] key, byte[] toEncrypt)
/// </summary>
public byte[] Ascon128Decrypt(byte[] nonce, byte[] key, byte[] toDecrypt)
{
if (nonce?.Length == 0)
if (nonce == null || nonce.Length == 0)
{
throw new Exception("You must provide a nonce to decrypt with Ascon 128");
}
if (key?.Length == 0)
if (key == null || key.Length == 0)
{
throw new Exception("You must provide a key to decrypt with Ascon 128");
}
Expand Down
4 changes: 2 additions & 2 deletions cas-dotnet-sdk/Symmetric/Types/AesEncryptResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class AesEncryptResult
{
public string Key { get; set; }
public string CipherText { get; set; }
public string Key { get; set; } = string.Empty;
public string CipherText { get; set; } = string.Empty;
}
}
2 changes: 1 addition & 1 deletion cas-dotnet-sdk/cas-dotnet-sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Title>cas-dotnet-sdk</Title>
<PackageIcon>icon.jpeg</PackageIcon>
<Version>1.9.76</Version>
<Version>1.9.77</Version>
<Authors>Mike Mulchrone</Authors>
<Description>A Nuget package that provides a implementation of the RustCrypto suite of cryptographic algorithms.</Description>
<RepositoryUrl>https://github.com/Cryptographic-API-Services/cas-dotnet-sdk</RepositoryUrl>
Expand Down
Loading
Loading