Skip to content
Open
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
4 changes: 2 additions & 2 deletions BlazorSodium/BlazorSodium.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.2.2</Version>
<PackageVersion>1.2.2</PackageVersion>
<Version>1.2.5</Version>
<PackageVersion>1.2.5</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
43 changes: 24 additions & 19 deletions BlazorSodium/Sodium/Hash.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

namespace BlazorSodium.Sodium
{
public static partial class Hash
{
/// <summary>
/// Internal method.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_hash.json"/>
[JSImport("sodium.crypto_hash", "blazorSodium")]
internal static partial byte[] Crypto_Hash_Interop(byte[] message);
public static partial class Hash
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know 3 spaces is weird, but I'd prefer to not introduce white space changes.

{
/// <summary>
/// Internal method.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_hash.json"/>
[JSImport("sodium.crypto_hash", "blazorSodium")]
internal static partial byte[] Crypto_Hash_Interop(byte[] message);

/// <summary>
/// Internal method.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_hash.json"/>
[JSImport("sodium.crypto_hash", "blazorSodium")]
internal static partial byte[] Crypto_Hash_Interop(string message);
}
/// <summary>
/// Internal method.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_hash.json"/>
[JSImport("sodium.crypto_hash", "blazorSodium")]
internal static partial byte[] Crypto_Hash_Interop(string message);


[JSImport("sodium.crypto_hash_sha256", "blazorSodium")]
internal static partial byte[] Crypto_Hash_Sha256_Interop(byte[] message);

}
}
27 changes: 16 additions & 11 deletions BlazorSodium/Sodium/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ public static byte[] Crypto_Hash(byte[] message)
public static byte[] Crypto_Hash(string message)
=> Crypto_Hash_Interop(message);

/* Missing from the sodium module:
* - crypto_hash_sha256
* - crypto_hash_sha256_final
* - crypto_hash_sha256_init
* - crypto_hash_sha256_update
* - crypto_hash_sha512
* - crypto_hash_sha512_final
* - crypto_hash_sha512_init
* - crypto_hash_sha512_update
*/
}

public static byte[] Crypto_Hash_Sha256(byte[] message)
=> Crypto_Hash_Sha256_Interop(message);


/* Missing from the sodium module:
* - crypto_hash_sha256
* - crypto_hash_sha256_final
* - crypto_hash_sha256_init
* - crypto_hash_sha256_update
* - crypto_hash_sha512
* - crypto_hash_sha512_final
* - crypto_hash_sha512_init
* - crypto_hash_sha512_update
*/
}
}
12 changes: 6 additions & 6 deletions BlazorSodium/Sodium/ScalarMultiplication.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ public static partial class ScalarMultiplication
public static partial byte[] Crypto_ScalarMult_Ed25519(byte[] privateKey, byte[] publicKey);
*/

/* Missing from the sodium module

/// <summary>
/// Compute the public key for the provided private key.
/// </summary>
/// <param name="privateKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult_ed25519_base.json"/>
[JSImport("sodium.crypto_scalarmult_ed25519_base", "blazorSodium")]
public static partial byte[] Crypto_ScalarMult_Ed25519_Base(byte[] privateKey);
*/
public static partial byte[] Crypto_ScalarMult_Ed25519_Base_Interop(byte[] privateKey);


/* Missing from the sodium module

/// <summary>
/// Compute the public key for the provided private key.
/// </summary>
/// <param name="privateKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult_ed25519_base_noclamp.json"/>
[JSImport("sodium.crypto_scalarmult_ed25519_base_noclamp", "blazorSodium")]
public static partial byte[] Crypto_ScalarMult_Ed25519_Base_NoClamp(byte[] privateKey);
*/
public static partial byte[] Crypto_ScalarMult_Ed25519_Base_NoClamp_Interop(byte[] privateKey);


/* Missing from the sodium module
/// <summary>
Expand Down
66 changes: 44 additions & 22 deletions BlazorSodium/Sodium/ScalarMultiplication.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
using System.Runtime.Versioning;
using System.Runtime.InteropServices.JavaScript;
using System.Runtime.Versioning;
using static System.Net.WebRequestMethods;

namespace BlazorSodium.Sodium
{
[SupportedOSPlatform("browser")]
public static partial class ScalarMultiplication
{
/// <summary>
/// Compute a shared secret given one user's private key and another user's public key.
/// </summary>
/// <param name="privateKey"></param>
/// <param name="publicKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult.json"/>
public static byte[] Crypto_ScalarMult(byte[] privateKey, byte[] publicKey)
=> Crypto_ScalarMult_Interop(privateKey, publicKey);
[SupportedOSPlatform("browser")]
public static partial class ScalarMultiplication
{
/// <summary>
/// Compute a shared secret given one user's private key and another user's public key.
/// </summary>
/// <param name="privateKey"></param>
/// <param name="publicKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult.json"/>
public static byte[] Crypto_ScalarMult(byte[] privateKey, byte[] publicKey)
=> Crypto_ScalarMult_Interop(privateKey, publicKey);

/// <summary>
/// Compute the public key for the provided private key.
/// </summary>
/// <param name="privateKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult_base.json"/>
public static byte[] Crypto_ScalarMult_Base(byte[] privateKey)
=> Crypto_ScalarMult_Base_Interop(privateKey);
}
/// <summary>
/// Compute the public key for the provided private key.
/// </summary>
/// <param name="privateKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult_base.json"/>
public static byte[] Crypto_ScalarMult_Base(byte[] privateKey)
=> Crypto_ScalarMult_Base_Interop(privateKey);

/// <summary>
/// Compute the public key for the provided private key.
/// </summary>
/// <param name="privateKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult_ed25519_base.json"/>
public static byte[] Crypto_ScalarMult_Ed25519_Base(byte[] privateKey)
=> Crypto_ScalarMult_Ed25519_Base_Interop(privateKey);


/// <summary>
/// Compute the public key for the provided private key.
/// </summary>
/// <param name="privateKey"></param>
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_scalarmult_ed25519_base_noclamp.json"/>

public static byte[] Crypto_ScalarMult_Ed25519_Base_NoClamp(byte[] privateKey)
=> Crypto_ScalarMult_Ed25519_Base_NoClamp_Interop(privateKey);
}
}
Loading