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,66 @@
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1;
public class DerGeneralString : DerStringBase
{
private readonly string str;
public static DerGeneralString GetInstance(object obj)
{
if (obj == null || obj is DerGeneralString)
{
return (DerGeneralString)obj;
}
throw new ArgumentException("illegal object in GetInstance: " + Platform.GetTypeName(obj));
}
public static DerGeneralString GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
Asn1Object asn1Object = obj.GetObject();
if (isExplicit || asn1Object is DerGeneralString)
{
return GetInstance(asn1Object);
}
return new DerGeneralString(((Asn1OctetString)asn1Object).GetOctets());
}
public DerGeneralString(byte[] str)
: this(Strings.FromAsciiByteArray(str))
{
}
public DerGeneralString(string str)
{
if (str == null)
{
throw new ArgumentNullException("str");
}
this.str = str;
}
public override string GetString()
{
return str;
}
public byte[] GetOctets()
{
return Strings.ToAsciiByteArray(str);
}
internal override void Encode(DerOutputStream derOut)
{
derOut.WriteEncoded(27, GetOctets());
}
protected override bool Asn1Equals(Asn1Object asn1Object)
{
if (!(asn1Object is DerGeneralString derGeneralString))
{
return false;
}
return str.Equals(derGeneralString.str);
}
}