init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.IO;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Cms;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Utilities;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Operators;
public class Asn1CipherBuilderWithKey : ICipherBuilderWithKey, ICipherBuilder
{
private readonly KeyParameter encKey;
private AlgorithmIdentifier algorithmIdentifier;
public object AlgorithmDetails => algorithmIdentifier;
public ICipherParameters Key => encKey;
public Asn1CipherBuilderWithKey(DerObjectIdentifier encryptionOID, int keySize, SecureRandom random)
{
if (random == null)
{
random = new SecureRandom();
}
CipherKeyGenerator cipherKeyGenerator = CipherKeyGeneratorFactory.CreateKeyGenerator(encryptionOID, random);
encKey = new KeyParameter(cipherKeyGenerator.GenerateKey());
algorithmIdentifier = AlgorithmIdentifierFactory.GenerateEncryptionAlgID(encryptionOID, encKey.GetKey().Length * 8, random);
}
public int GetMaxOutputSize(int inputLen)
{
throw new NotImplementedException();
}
public ICipher BuildCipher(Stream stream)
{
object obj = EnvelopedDataHelper.CreateContentCipher(forEncryption: true, encKey, algorithmIdentifier);
if (obj is IStreamCipher)
{
obj = new BufferedStreamCipher((IStreamCipher)obj);
}
if (stream == null)
{
stream = new MemoryStream();
}
return new BufferedCipherWrapper((IBufferedCipher)obj, stream);
}
}

View File

@@ -0,0 +1,23 @@
using Org.BouncyCastle.X509;
namespace Org.BouncyCastle.Crypto.Operators;
public class Asn1KeyWrapper : IKeyWrapper
{
private string algorithm;
private IKeyWrapper wrapper;
public object AlgorithmDetails => wrapper.AlgorithmDetails;
public Asn1KeyWrapper(string algorithm, X509Certificate cert)
{
this.algorithm = algorithm;
wrapper = KeyWrapperUtil.WrapperForName(algorithm, cert.GetPublicKey());
}
public IBlockResult Wrap(byte[] keyData)
{
return wrapper.Wrap(keyData);
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Operators;
public class Asn1SignatureFactory : ISignatureFactory
{
private readonly AlgorithmIdentifier algID;
private readonly string algorithm;
private readonly AsymmetricKeyParameter privateKey;
private readonly SecureRandom random;
public object AlgorithmDetails => algID;
public static IEnumerable SignatureAlgNames => X509Utilities.GetAlgNames();
public Asn1SignatureFactory(string algorithm, AsymmetricKeyParameter privateKey)
: this(algorithm, privateKey, null)
{
}
public Asn1SignatureFactory(string algorithm, AsymmetricKeyParameter privateKey, SecureRandom random)
{
if (algorithm == null)
{
throw new ArgumentNullException("algorithm");
}
if (privateKey == null)
{
throw new ArgumentNullException("privateKey");
}
if (!privateKey.IsPrivate)
{
throw new ArgumentException("Key for signing must be private", "privateKey");
}
DerObjectIdentifier algorithmOid = X509Utilities.GetAlgorithmOid(algorithm);
this.algorithm = algorithm;
this.privateKey = privateKey;
this.random = random;
algID = X509Utilities.GetSigAlgID(algorithmOid, algorithm);
}
public IStreamCalculator CreateCalculator()
{
ISigner signer = SignerUtilities.InitSigner(algorithm, forSigning: true, privateKey, random);
return new DefaultSignatureCalculator(signer);
}
}

View File

@@ -0,0 +1,46 @@
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Operators;
public class Asn1VerifierFactory : IVerifierFactory
{
private readonly AlgorithmIdentifier algID;
private readonly AsymmetricKeyParameter publicKey;
public object AlgorithmDetails => algID;
public Asn1VerifierFactory(string algorithm, AsymmetricKeyParameter publicKey)
{
if (algorithm == null)
{
throw new ArgumentNullException("algorithm");
}
if (publicKey == null)
{
throw new ArgumentNullException("publicKey");
}
if (publicKey.IsPrivate)
{
throw new ArgumentException("Key for verifying must be public", "publicKey");
}
DerObjectIdentifier algorithmOid = X509Utilities.GetAlgorithmOid(algorithm);
this.publicKey = publicKey;
algID = X509Utilities.GetSigAlgID(algorithmOid, algorithm);
}
public Asn1VerifierFactory(AlgorithmIdentifier algorithm, AsymmetricKeyParameter publicKey)
{
this.publicKey = publicKey;
algID = algorithm;
}
public IStreamCalculator CreateCalculator()
{
ISigner signer = SignerUtilities.InitSigner(X509Utilities.GetSignatureName(algID), forSigning: false, publicKey, null);
return new DefaultVerifierCalculator(signer);
}
}

View File

@@ -0,0 +1,21 @@
using System.Collections;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Crypto.Operators;
public class Asn1VerifierFactoryProvider : IVerifierFactoryProvider
{
private readonly AsymmetricKeyParameter publicKey;
public IEnumerable SignatureAlgNames => X509Utilities.GetAlgNames();
public Asn1VerifierFactoryProvider(AsymmetricKeyParameter publicKey)
{
this.publicKey = publicKey;
}
public IVerifierFactory CreateVerifierFactory(object algorithmDetails)
{
return new Asn1VerifierFactory((AlgorithmIdentifier)algorithmDetails, publicKey);
}
}

View File

@@ -0,0 +1,29 @@
using System.IO;
using Org.BouncyCastle.Crypto.IO;
namespace Org.BouncyCastle.Crypto.Operators;
public class BufferedCipherWrapper : ICipher
{
private readonly IBufferedCipher bufferedCipher;
private readonly CipherStream stream;
public Stream Stream => stream;
public BufferedCipherWrapper(IBufferedCipher bufferedCipher, Stream source)
{
this.bufferedCipher = bufferedCipher;
stream = new CipherStream(source, bufferedCipher, bufferedCipher);
}
public int GetMaxOutputSize(int inputLen)
{
return bufferedCipher.GetOutputSize(inputLen);
}
public int GetUpdateOutputSize(int inputLen)
{
return bufferedCipher.GetUpdateOutputSize(inputLen);
}
}

View File

@@ -0,0 +1,21 @@
using System.IO;
using Org.BouncyCastle.Crypto.IO;
namespace Org.BouncyCastle.Crypto.Operators;
public class DefaultSignatureCalculator : IStreamCalculator
{
private readonly SignerSink mSignerSink;
public Stream Stream => mSignerSink;
public DefaultSignatureCalculator(ISigner signer)
{
mSignerSink = new SignerSink(signer);
}
public object GetResult()
{
return new DefaultSignatureResult(mSignerSink.Signer);
}
}

View File

@@ -0,0 +1,23 @@
namespace Org.BouncyCastle.Crypto.Operators;
public class DefaultSignatureResult : IBlockResult
{
private readonly ISigner mSigner;
public DefaultSignatureResult(ISigner signer)
{
mSigner = signer;
}
public byte[] Collect()
{
return mSigner.GenerateSignature();
}
public int Collect(byte[] sig, int sigOff)
{
byte[] array = Collect();
array.CopyTo(sig, sigOff);
return array.Length;
}
}

View File

@@ -0,0 +1,21 @@
using System.IO;
using Org.BouncyCastle.Crypto.IO;
namespace Org.BouncyCastle.Crypto.Operators;
public class DefaultVerifierCalculator : IStreamCalculator
{
private readonly SignerSink mSignerSink;
public Stream Stream => mSignerSink;
public DefaultVerifierCalculator(ISigner signer)
{
mSignerSink = new SignerSink(signer);
}
public object GetResult()
{
return new DefaultVerifierResult(mSignerSink.Signer);
}
}

View File

@@ -0,0 +1,24 @@
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Operators;
public class DefaultVerifierResult : IVerifier
{
private readonly ISigner mSigner;
public DefaultVerifierResult(ISigner signer)
{
mSigner = signer;
}
public bool IsVerified(byte[] signature)
{
return mSigner.VerifySignature(signature);
}
public bool IsVerified(byte[] sig, int sigOff, int sigLen)
{
byte[] signature = Arrays.CopyOfRange(sig, sigOff, sigOff + sigLen);
return IsVerified(signature);
}
}

View File

@@ -0,0 +1,32 @@
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Crypto.Operators;
public class GenericKey
{
private readonly AlgorithmIdentifier algorithmIdentifier;
private readonly object representation;
public AlgorithmIdentifier AlgorithmIdentifier => algorithmIdentifier;
public object Representation => representation;
public GenericKey(object representation)
{
algorithmIdentifier = null;
this.representation = representation;
}
public GenericKey(AlgorithmIdentifier algorithmIdentifier, byte[] representation)
{
this.algorithmIdentifier = algorithmIdentifier;
this.representation = representation;
}
public GenericKey(AlgorithmIdentifier algorithmIdentifier, object representation)
{
this.algorithmIdentifier = algorithmIdentifier;
this.representation = representation;
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections;
using Org.BouncyCastle.Asn1.Nist;
using Org.BouncyCastle.Asn1.Oiw;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Operators;
internal class KeyWrapperUtil
{
private static readonly IDictionary providerMap;
static KeyWrapperUtil()
{
providerMap = Platform.CreateHashtable();
providerMap.Add("RSA/NONE/OAEPWITHSHA1ANDMGF1PADDING", new RsaOaepWrapperProvider(OiwObjectIdentifiers.IdSha1));
providerMap.Add("RSA/NONE/OAEPWITHSHA224ANDMGF1PADDING", new RsaOaepWrapperProvider(NistObjectIdentifiers.IdSha224));
providerMap.Add("RSA/NONE/OAEPWITHSHA256ANDMGF1PADDING", new RsaOaepWrapperProvider(NistObjectIdentifiers.IdSha256));
providerMap.Add("RSA/NONE/OAEPWITHSHA384ANDMGF1PADDING", new RsaOaepWrapperProvider(NistObjectIdentifiers.IdSha384));
providerMap.Add("RSA/NONE/OAEPWITHSHA512ANDMGF1PADDING", new RsaOaepWrapperProvider(NistObjectIdentifiers.IdSha512));
}
public static IKeyWrapper WrapperForName(string algorithm, ICipherParameters parameters)
{
WrapperProvider wrapperProvider = (WrapperProvider)providerMap[Strings.ToUpperCase(algorithm)];
if (wrapperProvider == null)
{
throw new ArgumentException("could not resolve " + algorithm + " to a KeyWrapper");
}
return (IKeyWrapper)wrapperProvider.CreateWrapper(forWrapping: true, parameters);
}
public static IKeyUnwrapper UnwrapperForName(string algorithm, ICipherParameters parameters)
{
WrapperProvider wrapperProvider = (WrapperProvider)providerMap[Strings.ToUpperCase(algorithm)];
if (wrapperProvider == null)
{
throw new ArgumentException("could not resolve " + algorithm + " to a KeyUnwrapper");
}
return (IKeyUnwrapper)wrapperProvider.CreateWrapper(forWrapping: false, parameters);
}
}

View File

@@ -0,0 +1,35 @@
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto.Encodings;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Operators;
internal class RsaOaepWrapper : IKeyWrapper, IKeyUnwrapper
{
private readonly AlgorithmIdentifier algId;
private readonly IAsymmetricBlockCipher engine;
public object AlgorithmDetails => algId;
public RsaOaepWrapper(bool forWrapping, ICipherParameters parameters, DerObjectIdentifier digestOid)
{
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(digestOid, DerNull.Instance);
algId = new AlgorithmIdentifier(PkcsObjectIdentifiers.IdRsaesOaep, new RsaesOaepParameters(algorithmIdentifier, new AlgorithmIdentifier(PkcsObjectIdentifiers.IdMgf1, algorithmIdentifier), RsaesOaepParameters.DefaultPSourceAlgorithm));
engine = new OaepEncoding(new RsaBlindedEngine(), DigestUtilities.GetDigest(digestOid));
engine.Init(forWrapping, parameters);
}
public IBlockResult Unwrap(byte[] cipherText, int offset, int length)
{
return new SimpleBlockResult(engine.ProcessBlock(cipherText, offset, length));
}
public IBlockResult Wrap(byte[] keyData)
{
return new SimpleBlockResult(engine.ProcessBlock(keyData, 0, keyData.Length));
}
}

View File

@@ -0,0 +1,18 @@
using Org.BouncyCastle.Asn1;
namespace Org.BouncyCastle.Crypto.Operators;
internal class RsaOaepWrapperProvider : WrapperProvider
{
private readonly DerObjectIdentifier digestOid;
internal RsaOaepWrapperProvider(DerObjectIdentifier digestOid)
{
this.digestOid = digestOid;
}
object WrapperProvider.CreateWrapper(bool forWrapping, ICipherParameters parameters)
{
return new RsaOaepWrapper(forWrapping, parameters, digestOid);
}
}

View File

@@ -0,0 +1,6 @@
namespace Org.BouncyCastle.Crypto.Operators;
internal interface WrapperProvider
{
object CreateWrapper(bool forWrapping, ICipherParameters parameters);
}

View File

@@ -0,0 +1,194 @@
using System.Collections;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.CryptoPro;
using Org.BouncyCastle.Asn1.Nist;
using Org.BouncyCastle.Asn1.Oiw;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.TeleTrust;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Asn1.X9;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Collections;
namespace Org.BouncyCastle.Crypto.Operators;
internal class X509Utilities
{
private static readonly Asn1Null derNull;
private static readonly IDictionary algorithms;
private static readonly IDictionary exParams;
private static readonly ISet noParams;
static X509Utilities()
{
derNull = DerNull.Instance;
algorithms = Platform.CreateHashtable();
exParams = Platform.CreateHashtable();
noParams = new HashSet();
algorithms.Add("MD2WITHRSAENCRYPTION", PkcsObjectIdentifiers.MD2WithRsaEncryption);
algorithms.Add("MD2WITHRSA", PkcsObjectIdentifiers.MD2WithRsaEncryption);
algorithms.Add("MD5WITHRSAENCRYPTION", PkcsObjectIdentifiers.MD5WithRsaEncryption);
algorithms.Add("MD5WITHRSA", PkcsObjectIdentifiers.MD5WithRsaEncryption);
algorithms.Add("SHA1WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha1WithRsaEncryption);
algorithms.Add("SHA1WITHRSA", PkcsObjectIdentifiers.Sha1WithRsaEncryption);
algorithms.Add("SHA224WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha224WithRsaEncryption);
algorithms.Add("SHA224WITHRSA", PkcsObjectIdentifiers.Sha224WithRsaEncryption);
algorithms.Add("SHA256WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha256WithRsaEncryption);
algorithms.Add("SHA256WITHRSA", PkcsObjectIdentifiers.Sha256WithRsaEncryption);
algorithms.Add("SHA384WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha384WithRsaEncryption);
algorithms.Add("SHA384WITHRSA", PkcsObjectIdentifiers.Sha384WithRsaEncryption);
algorithms.Add("SHA512WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512WithRsaEncryption);
algorithms.Add("SHA512WITHRSA", PkcsObjectIdentifiers.Sha512WithRsaEncryption);
algorithms.Add("SHA1WITHRSAANDMGF1", PkcsObjectIdentifiers.IdRsassaPss);
algorithms.Add("SHA224WITHRSAANDMGF1", PkcsObjectIdentifiers.IdRsassaPss);
algorithms.Add("SHA256WITHRSAANDMGF1", PkcsObjectIdentifiers.IdRsassaPss);
algorithms.Add("SHA384WITHRSAANDMGF1", PkcsObjectIdentifiers.IdRsassaPss);
algorithms.Add("SHA512WITHRSAANDMGF1", PkcsObjectIdentifiers.IdRsassaPss);
algorithms.Add("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160);
algorithms.Add("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160);
algorithms.Add("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128);
algorithms.Add("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128);
algorithms.Add("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256);
algorithms.Add("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256);
algorithms.Add("SHA1WITHDSA", X9ObjectIdentifiers.IdDsaWithSha1);
algorithms.Add("DSAWITHSHA1", X9ObjectIdentifiers.IdDsaWithSha1);
algorithms.Add("SHA224WITHDSA", NistObjectIdentifiers.DsaWithSha224);
algorithms.Add("SHA256WITHDSA", NistObjectIdentifiers.DsaWithSha256);
algorithms.Add("SHA384WITHDSA", NistObjectIdentifiers.DsaWithSha384);
algorithms.Add("SHA512WITHDSA", NistObjectIdentifiers.DsaWithSha512);
algorithms.Add("SHA1WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha1);
algorithms.Add("ECDSAWITHSHA1", X9ObjectIdentifiers.ECDsaWithSha1);
algorithms.Add("SHA224WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha224);
algorithms.Add("SHA256WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha256);
algorithms.Add("SHA384WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha384);
algorithms.Add("SHA512WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha512);
algorithms.Add("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94);
algorithms.Add("GOST3411WITHGOST3410-94", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94);
algorithms.Add("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001);
algorithms.Add("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001);
algorithms.Add("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001);
noParams.Add(X9ObjectIdentifiers.ECDsaWithSha1);
noParams.Add(X9ObjectIdentifiers.ECDsaWithSha224);
noParams.Add(X9ObjectIdentifiers.ECDsaWithSha256);
noParams.Add(X9ObjectIdentifiers.ECDsaWithSha384);
noParams.Add(X9ObjectIdentifiers.ECDsaWithSha512);
noParams.Add(X9ObjectIdentifiers.IdDsaWithSha1);
noParams.Add(NistObjectIdentifiers.DsaWithSha224);
noParams.Add(NistObjectIdentifiers.DsaWithSha256);
noParams.Add(NistObjectIdentifiers.DsaWithSha384);
noParams.Add(NistObjectIdentifiers.DsaWithSha512);
noParams.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94);
noParams.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001);
AlgorithmIdentifier hashAlgId = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance);
exParams.Add("SHA1WITHRSAANDMGF1", CreatePssParams(hashAlgId, 20));
AlgorithmIdentifier hashAlgId2 = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha224, DerNull.Instance);
exParams.Add("SHA224WITHRSAANDMGF1", CreatePssParams(hashAlgId2, 28));
AlgorithmIdentifier hashAlgId3 = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha256, DerNull.Instance);
exParams.Add("SHA256WITHRSAANDMGF1", CreatePssParams(hashAlgId3, 32));
AlgorithmIdentifier hashAlgId4 = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha384, DerNull.Instance);
exParams.Add("SHA384WITHRSAANDMGF1", CreatePssParams(hashAlgId4, 48));
AlgorithmIdentifier hashAlgId5 = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha512, DerNull.Instance);
exParams.Add("SHA512WITHRSAANDMGF1", CreatePssParams(hashAlgId5, 64));
}
private static string GetDigestAlgName(DerObjectIdentifier digestAlgOID)
{
if (PkcsObjectIdentifiers.MD5.Equals(digestAlgOID))
{
return "MD5";
}
if (OiwObjectIdentifiers.IdSha1.Equals(digestAlgOID))
{
return "SHA1";
}
if (NistObjectIdentifiers.IdSha224.Equals(digestAlgOID))
{
return "SHA224";
}
if (NistObjectIdentifiers.IdSha256.Equals(digestAlgOID))
{
return "SHA256";
}
if (NistObjectIdentifiers.IdSha384.Equals(digestAlgOID))
{
return "SHA384";
}
if (NistObjectIdentifiers.IdSha512.Equals(digestAlgOID))
{
return "SHA512";
}
if (TeleTrusTObjectIdentifiers.RipeMD128.Equals(digestAlgOID))
{
return "RIPEMD128";
}
if (TeleTrusTObjectIdentifiers.RipeMD160.Equals(digestAlgOID))
{
return "RIPEMD160";
}
if (TeleTrusTObjectIdentifiers.RipeMD256.Equals(digestAlgOID))
{
return "RIPEMD256";
}
if (CryptoProObjectIdentifiers.GostR3411.Equals(digestAlgOID))
{
return "GOST3411";
}
return digestAlgOID.Id;
}
internal static string GetSignatureName(AlgorithmIdentifier sigAlgId)
{
Asn1Encodable parameters = sigAlgId.Parameters;
if (parameters != null && !derNull.Equals(parameters))
{
if (sigAlgId.Algorithm.Equals(PkcsObjectIdentifiers.IdRsassaPss))
{
RsassaPssParameters instance = RsassaPssParameters.GetInstance(parameters);
return GetDigestAlgName(instance.HashAlgorithm.Algorithm) + "withRSAandMGF1";
}
if (sigAlgId.Algorithm.Equals(X9ObjectIdentifiers.ECDsaWithSha2))
{
Asn1Sequence instance2 = Asn1Sequence.GetInstance(parameters);
return GetDigestAlgName((DerObjectIdentifier)instance2[0]) + "withECDSA";
}
}
return sigAlgId.Algorithm.Id;
}
private static RsassaPssParameters CreatePssParams(AlgorithmIdentifier hashAlgId, int saltSize)
{
return new RsassaPssParameters(hashAlgId, new AlgorithmIdentifier(PkcsObjectIdentifiers.IdMgf1, hashAlgId), new DerInteger(saltSize), new DerInteger(1));
}
internal static DerObjectIdentifier GetAlgorithmOid(string algorithmName)
{
algorithmName = Platform.ToUpperInvariant(algorithmName);
if (algorithms.Contains(algorithmName))
{
return (DerObjectIdentifier)algorithms[algorithmName];
}
return new DerObjectIdentifier(algorithmName);
}
internal static AlgorithmIdentifier GetSigAlgID(DerObjectIdentifier sigOid, string algorithmName)
{
if (noParams.Contains(sigOid))
{
return new AlgorithmIdentifier(sigOid);
}
algorithmName = Platform.ToUpperInvariant(algorithmName);
if (exParams.Contains(algorithmName))
{
return new AlgorithmIdentifier(sigOid, (Asn1Encodable)exParams[algorithmName]);
}
return new AlgorithmIdentifier(sigOid, DerNull.Instance);
}
internal static IEnumerable GetAlgNames()
{
return new EnumerableProxy(algorithms.Keys);
}
}