diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-02-21 18:04:07 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-02-21 18:04:07 +0700 |
commit | b204309029cd6bd92d8a20e5778e6cf328bf7745 (patch) | |
tree | da220b61292493a744a210c2c7e00740468838a2 /crypto/src/asn1/tsp/TSTInfo.cs | |
parent | Improvements to permitted sub-trees (diff) | |
download | BouncyCastle.NET-ed25519-b204309029cd6bd92d8a20e5778e6cf328bf7745.tar.xz |
Update ASN.1 GetInstance methods
Diffstat (limited to 'crypto/src/asn1/tsp/TSTInfo.cs')
-rw-r--r-- | crypto/src/asn1/tsp/TSTInfo.cs | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/crypto/src/asn1/tsp/TSTInfo.cs b/crypto/src/asn1/tsp/TSTInfo.cs index ee4dd67f1..3f5ab28bb 100644 --- a/crypto/src/asn1/tsp/TSTInfo.cs +++ b/crypto/src/asn1/tsp/TSTInfo.cs @@ -21,35 +21,13 @@ namespace Org.BouncyCastle.Asn1.Tsp private readonly GeneralName tsa; private readonly X509Extensions extensions; - public static TstInfo GetInstance( - object o) + public static TstInfo GetInstance(object obj) { - if (o == null || o is TstInfo) - { - return (TstInfo) o; - } - - if (o is Asn1Sequence) - { - return new TstInfo((Asn1Sequence) o); - } - - if (o is Asn1OctetString) - { - try - { - byte[] octets = ((Asn1OctetString)o).GetOctets(); - return GetInstance(Asn1Object.FromByteArray(octets)); - } - catch (IOException) - { - throw new ArgumentException( - "Bad object format in 'TstInfo' factory."); - } - } - - throw new ArgumentException( - "Unknown object in 'TstInfo' factory: " + Platform.GetTypeName(o)); + if (obj is TstInfo) + return (TstInfo)obj; + if (obj == null) + return null; + return new TstInfo(Asn1Sequence.GetInstance(obj)); } private TstInfo( |