Files
ichni_Official/Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/cms/PKCS5Scheme2UTF8PBEKey.cs

52 lines
1.3 KiB
C#
Raw Normal View History

2026-06-15 18:18:16 +08:00
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Cms
{
/**
* PKCS5 scheme-2 - password converted to bytes using UTF-8.
*/
public class Pkcs5Scheme2Utf8PbeKey
: CmsPbeKey
{
public Pkcs5Scheme2Utf8PbeKey(
char[] password,
byte[] salt,
int iterationCount)
: base(password, salt, iterationCount)
{
}
public Pkcs5Scheme2Utf8PbeKey(
char[] password,
AlgorithmIdentifier keyDerivationAlgorithm)
: base(password, keyDerivationAlgorithm)
{
}
internal override KeyParameter GetEncoded(
string algorithmOid)
{
Pkcs5S2ParametersGenerator gen = new Pkcs5S2ParametersGenerator();
gen.Init(
PbeParametersGenerator.Pkcs5PasswordToUtf8Bytes(password),
salt,
iterationCount);
return (KeyParameter) gen.GenerateDerivedParameters(
algorithmOid,
CmsEnvelopedHelper.Instance.GetKeySize(algorithmOid));
}
}
}
#pragma warning restore
#endif