36 lines
759 B
C#
36 lines
759 B
C#
using System;
|
|
|
|
using Org.BouncyCastle.Crypto;
|
|
using Org.BouncyCastle.Crypto.Generators;
|
|
using Org.BouncyCastle.Crypto.Parameters;
|
|
|
|
namespace Org.BouncyCastle.Cms
|
|
{
|
|
public class Pkcs5Scheme2PbeKey
|
|
: CmsPbeKey
|
|
{
|
|
public Pkcs5Scheme2PbeKey(
|
|
string password,
|
|
byte[] salt,
|
|
int iterationCount)
|
|
: base(password, salt, iterationCount)
|
|
{
|
|
}
|
|
|
|
internal override KeyParameter GetEncoded(
|
|
string algorithmOid)
|
|
{
|
|
Pkcs5S2ParametersGenerator gen = new Pkcs5S2ParametersGenerator();
|
|
|
|
gen.Init(
|
|
PbeParametersGenerator.Pkcs5PasswordToBytes(this.Password),
|
|
this.Salt,
|
|
this.IterationCount);
|
|
|
|
return (KeyParameter) gen.GenerateDerivedParameters(
|
|
algorithmOid,
|
|
CmsEnvelopedHelper.Instance.GetKeySize(algorithmOid));
|
|
}
|
|
}
|
|
}
|