This commit is contained in:
2026-06-15 18:18:16 +08:00
parent 97c9fba14e
commit 2b9f134e5f
4164 changed files with 386922 additions and 79 deletions

View File

@@ -0,0 +1,62 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
{
/// <summary>Blake3 Parameters.</summary>
public sealed class Blake3Parameters
: ICipherParameters
{
private const int KeyLen = 32;
private byte[] m_theKey;
private byte[] m_theContext;
/// <summary>Create a key parameter.</summary>
/// <param name="pContext">the context</param>
/// <returns>the parameter</returns>
public static Blake3Parameters Context(byte[] pContext)
{
if (pContext == null)
throw new ArgumentNullException(nameof(pContext));
Blake3Parameters myParams = new Blake3Parameters();
myParams.m_theContext = Arrays.Clone(pContext);
return myParams;
}
/// <summary>Create a key parameter.</summary>
/// <param name="pKey">the key</param>
/// <returns>the parameter</returns>
public static Blake3Parameters Key(byte[] pKey)
{
if (pKey == null)
throw new ArgumentNullException(nameof(pKey));
if (pKey.Length != KeyLen)
throw new ArgumentException("Invalid key length", nameof(pKey));
Blake3Parameters myParams = new Blake3Parameters();
myParams.m_theKey = Arrays.Clone(pKey);
return myParams;
}
/// <summary>Obtain the key.</summary>
/// <returns>the key</returns>
public byte[] GetKey() => Arrays.Clone(m_theKey);
/// <summary>Clear the key bytes.</summary>
public void ClearKey()
{
Arrays.Fill(m_theKey, 0);
}
/// <summary>Obtain the salt.</summary>
/// <returns>the salt</returns>
public byte[] GetContext() => Arrays.Clone(m_theContext);
}
}
#pragma warning restore
#endif