Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Crypt32 committed Jun 12, 2021
1 parent 1c83af9 commit 8959b54
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Asn1Parser/Asn1Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using SysadminsLV.Asn1Parser.Universal;

Expand Down Expand Up @@ -257,7 +256,7 @@ public static class Asn1Utils {
public static Byte[] EncodeObjectIdentifier(Oid oid) {
if (oid == null) { throw new ArgumentNullException(); }
if (String.IsNullOrEmpty(oid.Value)) { throw new ArgumentException("oid"); }
return CryptoConfig.EncodeOID(oid.Value);
return new Asn1ObjectIdentifier(oid).RawData;
}
/// <summary>
/// Decodes ASN.1-encoded object identifier to an instance of generic <see cref="Oid"/> class.
Expand All @@ -269,10 +268,7 @@ public static class Asn1Utils {
public static Oid DecodeObjectIdentifier(Byte[] rawData) {
if (rawData == null) { throw new ArgumentNullException(); }
try {
Byte[] raw = Encode(rawData, 48);
AsnEncodedData asnencoded = new AsnEncodedData(raw);
X509EnhancedKeyUsageExtension eku = new X509EnhancedKeyUsageExtension(asnencoded, false);
return eku.EnhancedKeyUsages[0];
return new Asn1ObjectIdentifier(rawData).Value;
} catch { throw new InvalidDataException("Input data is not valid ASN-encoded Oid."); }
}
/// <summary>
Expand Down

0 comments on commit 8959b54

Please sign in to comment.