Initial Commit

This commit is contained in:
2023-06-21 12:46:23 -04:00
commit c70248a520
1352 changed files with 336780 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Misc
{
public class Cast5CbcParameters
: Asn1Encodable
{
private readonly DerInteger keyLength;
private readonly Asn1OctetString iv;
public static Cast5CbcParameters GetInstance(
object o)
{
if (o is Cast5CbcParameters)
{
return (Cast5CbcParameters) o;
}
if (o is Asn1Sequence)
{
return new Cast5CbcParameters((Asn1Sequence) o);
}
throw new ArgumentException("unknown object in Cast5CbcParameters factory");
}
public Cast5CbcParameters(
byte[] iv,
int keyLength)
{
this.iv = new DerOctetString(iv);
this.keyLength = new DerInteger(keyLength);
}
private Cast5CbcParameters(
Asn1Sequence seq)
{
if (seq.Count != 2)
throw new ArgumentException("Wrong number of elements in sequence", "seq");
iv = (Asn1OctetString) seq[0];
keyLength = (DerInteger) seq[1];
}
public byte[] GetIV()
{
return Arrays.Clone(iv.GetOctets());
}
public int KeyLength
{
get { return keyLength.Value.IntValue; }
}
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* cast5CBCParameters ::= Sequence {
* iv OCTET STRING DEFAULT 0,
* -- Initialization vector
* keyLength Integer
* -- Key length, in bits
* }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
return new DerSequence(iv, keyLength);
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
using Org.BouncyCastle.Asn1;
namespace Org.BouncyCastle.Asn1.Misc
{
public class IdeaCbcPar
: Asn1Encodable
{
internal Asn1OctetString iv;
public static IdeaCbcPar GetInstance(
object o)
{
if (o is IdeaCbcPar)
{
return (IdeaCbcPar) o;
}
if (o is Asn1Sequence)
{
return new IdeaCbcPar((Asn1Sequence) o);
}
throw new ArgumentException("unknown object in IDEACBCPar factory");
}
public IdeaCbcPar(
byte[] iv)
{
this.iv = new DerOctetString(iv);
}
private IdeaCbcPar(
Asn1Sequence seq)
{
if (seq.Count == 1)
{
iv = (Asn1OctetString) seq[0];
}
}
public byte[] GetIV()
{
return iv == null ? null : iv.GetOctets();
}
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* IDEA-CBCPar ::= Sequence {
* iv OCTET STRING OPTIONAL -- exactly 8 octets
* }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (iv != null)
{
v.Add(iv);
}
return new DerSequence(v);
}
}
}

View File

@@ -0,0 +1,48 @@
using Org.BouncyCastle.Asn1;
namespace Org.BouncyCastle.Asn1.Misc
{
public abstract class MiscObjectIdentifiers
{
//
// Netscape
// iso/itu(2) joint-assign(16) us(840) uscompany(1) Netscape(113730) cert-extensions(1) }
//
public static readonly DerObjectIdentifier Netscape = new DerObjectIdentifier("2.16.840.1.113730.1");
public static readonly DerObjectIdentifier NetscapeCertType = new DerObjectIdentifier(Netscape + ".1");
public static readonly DerObjectIdentifier NetscapeBaseUrl = new DerObjectIdentifier(Netscape + ".2");
public static readonly DerObjectIdentifier NetscapeRevocationUrl = new DerObjectIdentifier(Netscape + ".3");
public static readonly DerObjectIdentifier NetscapeCARevocationUrl = new DerObjectIdentifier(Netscape + ".4");
public static readonly DerObjectIdentifier NetscapeRenewalUrl = new DerObjectIdentifier(Netscape + ".7");
public static readonly DerObjectIdentifier NetscapeCAPolicyUrl = new DerObjectIdentifier(Netscape + ".8");
public static readonly DerObjectIdentifier NetscapeSslServerName = new DerObjectIdentifier(Netscape + ".12");
public static readonly DerObjectIdentifier NetscapeCertComment = new DerObjectIdentifier(Netscape + ".13");
//
// Verisign
// iso/itu(2) joint-assign(16) us(840) uscompany(1) verisign(113733) cert-extensions(1) }
//
internal const string Verisign = "2.16.840.1.113733.1";
//
// CZAG - country, zip, age, and gender
//
public static readonly DerObjectIdentifier VerisignCzagExtension = new DerObjectIdentifier(Verisign + ".6.3");
// D&B D-U-N-S number
public static readonly DerObjectIdentifier VerisignDnbDunsNumber = new DerObjectIdentifier(Verisign + ".6.15");
//
// Novell
// iso/itu(2) country(16) us(840) organization(1) novell(113719)
//
public static readonly string Novell = "2.16.840.1.113719";
public static readonly DerObjectIdentifier NovellSecurityAttribs = new DerObjectIdentifier(Novell + ".1.9.4.1");
//
// Entrust
// iso(1) member-body(16) us(840) nortelnetworks(113533) entrust(7)
//
public static readonly string Entrust = "1.2.840.113533.7";
public static readonly DerObjectIdentifier EntrustVersionExtension = new DerObjectIdentifier(Entrust + ".65.0");
}
}

View File

@@ -0,0 +1,54 @@
using Org.BouncyCastle.Asn1;
namespace Org.BouncyCastle.Asn1.Misc
{
/**
* The NetscapeCertType object.
* <pre>
* NetscapeCertType ::= BIT STRING {
* SSLClient (0),
* SSLServer (1),
* S/MIME (2),
* Object Signing (3),
* Reserved (4),
* SSL CA (5),
* S/MIME CA (6),
* Object Signing CA (7) }
* </pre>
*/
public class NetscapeCertType
: DerBitString
{
public const int SslClient = (1 << 7);
public const int SslServer = (1 << 6);
public const int Smime = (1 << 5);
public const int ObjectSigning = (1 << 4);
public const int Reserved = (1 << 3);
public const int SslCA = (1 << 2);
public const int SmimeCA = (1 << 1);
public const int ObjectSigningCA = (1 << 0);
/**
* Basic constructor.
*
* @param usage - the bitwise OR of the Key Usage flags giving the
* allowed uses for the key.
* e.g. (X509NetscapeCertType.sslCA | X509NetscapeCertType.smimeCA)
*/
public NetscapeCertType(int usage)
: base(GetBytes(usage), GetPadBits(usage))
{
}
public NetscapeCertType(DerBitString usage)
: base(usage.GetBytes(), usage.PadBits)
{
}
public override string ToString()
{
byte[] data = GetBytes();
return "NetscapeCertType: 0x" + (data[0] & 0xff).ToString("X");
}
}
}

View File

@@ -0,0 +1,18 @@
using Org.BouncyCastle.Asn1;
namespace Org.BouncyCastle.Asn1.Misc
{
public class NetscapeRevocationUrl
: DerIA5String
{
public NetscapeRevocationUrl(DerIA5String str)
: base(str.GetString())
{
}
public override string ToString()
{
return "NetscapeRevocationUrl: " + this.GetString();
}
}
}

View File

@@ -0,0 +1,18 @@
using Org.BouncyCastle.Asn1;
namespace Org.BouncyCastle.Asn1.Misc
{
public class VerisignCzagExtension
: DerIA5String
{
public VerisignCzagExtension(DerIA5String str)
: base(str.GetString())
{
}
public override string ToString()
{
return "VerisignCzagExtension: " + this.GetString();
}
}
}