in net/JetBrains.SignatureVerifier/src/Crypt/BC/CMSSignedHelper.cs [364:432]
internal string GetEncOid(
AsymmetricKeyParameter key,
string digestOID)
{
string encOID = null;
if (key is RsaKeyParameters)
{
if (!((RsaKeyParameters)key).IsPrivate)
throw new ArgumentException("Expected RSA private key");
encOID = CmsSignedGenerator.EncryptionRsa;
}
else if (key is DsaPrivateKeyParameters)
{
if (digestOID.Equals(CmsSignedGenerator.DigestSha1))
{
encOID = CmsSignedGenerator.EncryptionDsa;
}
else if (digestOID.Equals(CmsSignedGenerator.DigestSha224))
{
encOID = NistObjectIdentifiers.DsaWithSha224.Id;
}
else if (digestOID.Equals(CmsSignedGenerator.DigestSha256))
{
encOID = NistObjectIdentifiers.DsaWithSha256.Id;
}
else if (digestOID.Equals(CmsSignedGenerator.DigestSha384))
{
encOID = NistObjectIdentifiers.DsaWithSha384.Id;
}
else if (digestOID.Equals(CmsSignedGenerator.DigestSha512))
{
encOID = NistObjectIdentifiers.DsaWithSha512.Id;
}
else
{
throw new ArgumentException("can't mix DSA with anything but SHA1/SHA2");
}
}
else if (key is ECPrivateKeyParameters)
{
ECPrivateKeyParameters ecPrivKey = (ECPrivateKeyParameters)key;
string algName = ecPrivKey.AlgorithmName;
if (algName == "ECGOST3410")
{
encOID = CmsSignedGenerator.EncryptionECGost3410;
}
else
{
// TODO Should we insist on algName being one of "EC" or "ECDSA", as Java does?
encOID = (string)ecAlgorithms[digestOID];
if (encOID == null)
throw new ArgumentException("can't mix ECDSA with anything but SHA family digests");
}
}
else if (key is Gost3410PrivateKeyParameters)
{
encOID = CmsSignedGenerator.EncryptionGost3410;
}
else
{
throw new ArgumentException("Unknown algorithm in CmsSignedGenerator.GetEncOid");
}
return encOID;
}