diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-04-19 19:17:16 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-04-19 19:17:16 +0700 |
commit | 346c124c149da99ce6470673879ea6c03088f3f4 (patch) | |
tree | 0beb701e442518e010df0f7ae61fa8c7f7032022 /crypto/src/asn1 | |
parent | Refactor TimeStampRequest (diff) | |
download | BouncyCastle.NET-ed25519-346c124c149da99ce6470673879ea6c03088f3f4.tar.xz |
Add some more utility methods around X.509 extensions
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r-- | crypto/src/asn1/x509/X509Extension.cs | 2 | ||||
-rw-r--r-- | crypto/src/asn1/x509/X509Extensions.cs | 28 |
2 files changed, 13 insertions, 17 deletions
diff --git a/crypto/src/asn1/x509/X509Extension.cs b/crypto/src/asn1/x509/X509Extension.cs index 430ce4447..9f9378d14 100644 --- a/crypto/src/asn1/x509/X509Extension.cs +++ b/crypto/src/asn1/x509/X509Extension.cs @@ -35,7 +35,7 @@ namespace Org.BouncyCastle.Asn1.X509 public Asn1OctetString Value { get { return value; } } - public Asn1Encodable GetParsedValue() + public Asn1Object GetParsedValue() { return ConvertValueToObject(this); } diff --git a/crypto/src/asn1/x509/X509Extensions.cs b/crypto/src/asn1/x509/X509Extensions.cs index 6396f9ddc..b5906c2e1 100644 --- a/crypto/src/asn1/x509/X509Extensions.cs +++ b/crypto/src/asn1/x509/X509Extensions.cs @@ -188,15 +188,14 @@ namespace Org.BouncyCastle.Asn1.X509 new Dictionary<DerObjectIdentifier, X509Extension>(); private readonly List<DerObjectIdentifier> m_ordering; - public static X509Extension GetExtension(X509Extensions extensions, DerObjectIdentifier oid) - { - return extensions?.GetExtension(oid); - } + public static X509Extension GetExtension(X509Extensions extensions, DerObjectIdentifier oid) => + extensions?.GetExtension(oid); - public static Asn1Encodable GetExtensionParsedValue(X509Extensions extensions, DerObjectIdentifier oid) - { - return extensions?.GetExtensionParsedValue(oid); - } + public static Asn1Object GetExtensionParsedValue(X509Extensions extensions, DerObjectIdentifier oid) => + extensions?.GetExtensionParsedValue(oid); + + public static Asn1OctetString GetExtensionValue(X509Extensions extensions, DerObjectIdentifier oid) => + extensions?.GetExtensionValue(oid); public static X509Extensions GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { @@ -316,10 +315,8 @@ namespace Org.BouncyCastle.Asn1.X509 * * @return the extension if it's present, null otherwise. */ - public X509Extension GetExtension(DerObjectIdentifier oid) - { - return CollectionUtilities.GetValueOrNull(m_extensions, oid); - } + public X509Extension GetExtension(DerObjectIdentifier oid) => + CollectionUtilities.GetValueOrNull(m_extensions, oid); /** * return the parsed value of the extension represented by the object identifier @@ -327,10 +324,9 @@ namespace Org.BouncyCastle.Asn1.X509 * * @return the parsed value of the extension if it's present, null otherwise. */ - public Asn1Encodable GetExtensionParsedValue(DerObjectIdentifier oid) - { - return GetExtension(oid)?.GetParsedValue(); - } + public Asn1Object GetExtensionParsedValue(DerObjectIdentifier oid) => GetExtension(oid)?.GetParsedValue(); + + public Asn1OctetString GetExtensionValue(DerObjectIdentifier oid) => GetExtension(oid)?.Value; /** * <pre> |