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,72 @@
using System.Collections;
using Org.BouncyCastle.Asn1.Sec;
using Org.BouncyCastle.Asn1.X9;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Collections;
namespace Org.BouncyCastle.Asn1.Nist;
public sealed class NistNamedCurves
{
private static readonly IDictionary objIds;
private static readonly IDictionary names;
public static IEnumerable Names => new EnumerableProxy(names.Values);
private NistNamedCurves()
{
}
private static void DefineCurveAlias(string name, DerObjectIdentifier oid)
{
objIds.Add(Platform.ToUpperInvariant(name), oid);
names.Add(oid, name);
}
static NistNamedCurves()
{
objIds = Platform.CreateHashtable();
names = Platform.CreateHashtable();
DefineCurveAlias("B-163", SecObjectIdentifiers.SecT163r2);
DefineCurveAlias("B-233", SecObjectIdentifiers.SecT233r1);
DefineCurveAlias("B-283", SecObjectIdentifiers.SecT283r1);
DefineCurveAlias("B-409", SecObjectIdentifiers.SecT409r1);
DefineCurveAlias("B-571", SecObjectIdentifiers.SecT571r1);
DefineCurveAlias("K-163", SecObjectIdentifiers.SecT163k1);
DefineCurveAlias("K-233", SecObjectIdentifiers.SecT233k1);
DefineCurveAlias("K-283", SecObjectIdentifiers.SecT283k1);
DefineCurveAlias("K-409", SecObjectIdentifiers.SecT409k1);
DefineCurveAlias("K-571", SecObjectIdentifiers.SecT571k1);
DefineCurveAlias("P-192", SecObjectIdentifiers.SecP192r1);
DefineCurveAlias("P-224", SecObjectIdentifiers.SecP224r1);
DefineCurveAlias("P-256", SecObjectIdentifiers.SecP256r1);
DefineCurveAlias("P-384", SecObjectIdentifiers.SecP384r1);
DefineCurveAlias("P-521", SecObjectIdentifiers.SecP521r1);
}
public static X9ECParameters GetByName(string name)
{
DerObjectIdentifier oid = GetOid(name);
if (oid != null)
{
return GetByOid(oid);
}
return null;
}
public static X9ECParameters GetByOid(DerObjectIdentifier oid)
{
return SecNamedCurves.GetByOid(oid);
}
public static DerObjectIdentifier GetOid(string name)
{
return (DerObjectIdentifier)objIds[Platform.ToUpperInvariant(name)];
}
public static string GetName(DerObjectIdentifier oid)
{
return (string)names[oid];
}
}

View File

@@ -0,0 +1,122 @@
namespace Org.BouncyCastle.Asn1.Nist;
public sealed class NistObjectIdentifiers
{
public static readonly DerObjectIdentifier NistAlgorithm = new DerObjectIdentifier("2.16.840.1.101.3.4");
public static readonly DerObjectIdentifier HashAlgs = NistAlgorithm.Branch("2");
public static readonly DerObjectIdentifier IdSha256 = HashAlgs.Branch("1");
public static readonly DerObjectIdentifier IdSha384 = HashAlgs.Branch("2");
public static readonly DerObjectIdentifier IdSha512 = HashAlgs.Branch("3");
public static readonly DerObjectIdentifier IdSha224 = HashAlgs.Branch("4");
public static readonly DerObjectIdentifier IdSha512_224 = HashAlgs.Branch("5");
public static readonly DerObjectIdentifier IdSha512_256 = HashAlgs.Branch("6");
public static readonly DerObjectIdentifier IdSha3_224 = HashAlgs.Branch("7");
public static readonly DerObjectIdentifier IdSha3_256 = HashAlgs.Branch("8");
public static readonly DerObjectIdentifier IdSha3_384 = HashAlgs.Branch("9");
public static readonly DerObjectIdentifier IdSha3_512 = HashAlgs.Branch("10");
public static readonly DerObjectIdentifier IdShake128 = HashAlgs.Branch("11");
public static readonly DerObjectIdentifier IdShake256 = HashAlgs.Branch("12");
public static readonly DerObjectIdentifier IdHMacWithSha3_224 = HashAlgs.Branch("13");
public static readonly DerObjectIdentifier IdHMacWithSha3_256 = HashAlgs.Branch("14");
public static readonly DerObjectIdentifier IdHMacWithSha3_384 = HashAlgs.Branch("15");
public static readonly DerObjectIdentifier IdHMacWithSha3_512 = HashAlgs.Branch("16");
public static readonly DerObjectIdentifier Aes = new DerObjectIdentifier(string.Concat(NistAlgorithm, ".1"));
public static readonly DerObjectIdentifier IdAes128Ecb = new DerObjectIdentifier(string.Concat(Aes, ".1"));
public static readonly DerObjectIdentifier IdAes128Cbc = new DerObjectIdentifier(string.Concat(Aes, ".2"));
public static readonly DerObjectIdentifier IdAes128Ofb = new DerObjectIdentifier(string.Concat(Aes, ".3"));
public static readonly DerObjectIdentifier IdAes128Cfb = new DerObjectIdentifier(string.Concat(Aes, ".4"));
public static readonly DerObjectIdentifier IdAes128Wrap = new DerObjectIdentifier(string.Concat(Aes, ".5"));
public static readonly DerObjectIdentifier IdAes128Gcm = new DerObjectIdentifier(string.Concat(Aes, ".6"));
public static readonly DerObjectIdentifier IdAes128Ccm = new DerObjectIdentifier(string.Concat(Aes, ".7"));
public static readonly DerObjectIdentifier IdAes192Ecb = new DerObjectIdentifier(string.Concat(Aes, ".21"));
public static readonly DerObjectIdentifier IdAes192Cbc = new DerObjectIdentifier(string.Concat(Aes, ".22"));
public static readonly DerObjectIdentifier IdAes192Ofb = new DerObjectIdentifier(string.Concat(Aes, ".23"));
public static readonly DerObjectIdentifier IdAes192Cfb = new DerObjectIdentifier(string.Concat(Aes, ".24"));
public static readonly DerObjectIdentifier IdAes192Wrap = new DerObjectIdentifier(string.Concat(Aes, ".25"));
public static readonly DerObjectIdentifier IdAes192Gcm = new DerObjectIdentifier(string.Concat(Aes, ".26"));
public static readonly DerObjectIdentifier IdAes192Ccm = new DerObjectIdentifier(string.Concat(Aes, ".27"));
public static readonly DerObjectIdentifier IdAes256Ecb = new DerObjectIdentifier(string.Concat(Aes, ".41"));
public static readonly DerObjectIdentifier IdAes256Cbc = new DerObjectIdentifier(string.Concat(Aes, ".42"));
public static readonly DerObjectIdentifier IdAes256Ofb = new DerObjectIdentifier(string.Concat(Aes, ".43"));
public static readonly DerObjectIdentifier IdAes256Cfb = new DerObjectIdentifier(string.Concat(Aes, ".44"));
public static readonly DerObjectIdentifier IdAes256Wrap = new DerObjectIdentifier(string.Concat(Aes, ".45"));
public static readonly DerObjectIdentifier IdAes256Gcm = new DerObjectIdentifier(string.Concat(Aes, ".46"));
public static readonly DerObjectIdentifier IdAes256Ccm = new DerObjectIdentifier(string.Concat(Aes, ".47"));
public static readonly DerObjectIdentifier IdDsaWithSha2 = new DerObjectIdentifier(string.Concat(NistAlgorithm, ".3"));
public static readonly DerObjectIdentifier DsaWithSha224 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".1"));
public static readonly DerObjectIdentifier DsaWithSha256 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".2"));
public static readonly DerObjectIdentifier DsaWithSha384 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".3"));
public static readonly DerObjectIdentifier DsaWithSha512 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".4"));
public static readonly DerObjectIdentifier IdDsaWithSha3_224 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".5"));
public static readonly DerObjectIdentifier IdDsaWithSha3_256 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".6"));
public static readonly DerObjectIdentifier IdDsaWithSha3_384 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".7"));
public static readonly DerObjectIdentifier IdDsaWithSha3_512 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".8"));
public static readonly DerObjectIdentifier IdEcdsaWithSha3_224 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".9"));
public static readonly DerObjectIdentifier IdEcdsaWithSha3_256 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".10"));
public static readonly DerObjectIdentifier IdEcdsaWithSha3_384 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".11"));
public static readonly DerObjectIdentifier IdEcdsaWithSha3_512 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".12"));
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_224 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".13"));
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_256 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".14"));
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_384 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".15"));
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_512 = new DerObjectIdentifier(string.Concat(IdDsaWithSha2, ".16"));
private NistObjectIdentifiers()
{
}
}