This should be ObjectIdentifier not strictly ASN.1

This commit is contained in:
Matt Nadareski
2025-09-24 10:47:00 -04:00
parent 91785eab1f
commit 8f775dbb3b
7 changed files with 28 additions and 28 deletions

View File

@@ -1,13 +1,13 @@
using SabreTools.Serialization.ASN1;
using SabreTools.Serialization.ObjectIdentifier;
using Xunit;
namespace SabreTools.Serialization.Test.ASN1
namespace SabreTools.Serialization.Test.ObjectIdentifier
{
// These tests are known to be incomplete due to the sheer number
// of possible OIDs that exist. The tests below are a minimal
// representation of functionality to guarantee proper behavior
// not necessarily absolute outputs
public class ObjectIdentifierTests
public class ParserTests
{
#region ASN.1
@@ -15,7 +15,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void ASN1Notation_AlwaysNull()
{
ulong[]? values = null;
string? actual = ObjectIdentifier.ParseOIDToASN1Notation(values);
string? actual = Parser.ParseOIDToASN1Notation(values);
Assert.Null(actual);
}
@@ -27,7 +27,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void DotNotation_NullValues_Null()
{
ulong[]? values = null;
string? actual = ObjectIdentifier.ParseOIDToDotNotation(values);
string? actual = Parser.ParseOIDToDotNotation(values);
Assert.Null(actual);
}
@@ -35,7 +35,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void DotNotation_EmptyValues_Null()
{
ulong[]? values = [];
string? actual = ObjectIdentifier.ParseOIDToDotNotation(values);
string? actual = Parser.ParseOIDToDotNotation(values);
Assert.Null(actual);
}
@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Test.ASN1
{
string expected = "0.1.2.3";
ulong[]? values = [0, 1, 2, 3];
string? actual = ObjectIdentifier.ParseOIDToDotNotation(values);
string? actual = Parser.ParseOIDToDotNotation(values);
Assert.Equal(expected, actual);
}
@@ -56,7 +56,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void ModifiedOIDIRI_NullValues_Null()
{
ulong[]? values = null;
string? actual = ObjectIdentifier.ParseOIDToModifiedOIDIRI(values);
string? actual = Parser.ParseOIDToModifiedOIDIRI(values);
Assert.Null(actual);
}
@@ -64,7 +64,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void ModifiedOIDIRI_EmptyValues_Null()
{
ulong[]? values = [];
string? actual = ObjectIdentifier.ParseOIDToModifiedOIDIRI(values);
string? actual = Parser.ParseOIDToModifiedOIDIRI(values);
Assert.Null(actual);
}
@@ -73,7 +73,7 @@ namespace SabreTools.Serialization.Test.ASN1
{
string expected = "/ITU-T/[question]/2/3";
ulong[]? values = [0, 1, 2, 3];
string? actual = ObjectIdentifier.ParseOIDToModifiedOIDIRI(values);
string? actual = Parser.ParseOIDToModifiedOIDIRI(values);
Assert.Equal(expected, actual);
}
@@ -85,7 +85,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void OIDIRI_NullValues_Null()
{
ulong[]? values = null;
string? actual = ObjectIdentifier.ParseOIDToOIDIRINotation(values);
string? actual = Parser.ParseOIDToOIDIRINotation(values);
Assert.Null(actual);
}
@@ -93,7 +93,7 @@ namespace SabreTools.Serialization.Test.ASN1
public void OIDIRI_EmptyValues_Null()
{
ulong[]? values = [];
string? actual = ObjectIdentifier.ParseOIDToOIDIRINotation(values);
string? actual = Parser.ParseOIDToOIDIRINotation(values);
Assert.Null(actual);
}
@@ -102,7 +102,7 @@ namespace SabreTools.Serialization.Test.ASN1
{
string expected = "/ITU-T/1/2/3";
ulong[]? values = [0, 1, 2, 3];
string? actual = ObjectIdentifier.ParseOIDToOIDIRINotation(values);
string? actual = Parser.ParseOIDToOIDIRINotation(values);
Assert.Equal(expected, actual);
}

View File

@@ -2,7 +2,7 @@ using System;
using System.Numerics;
using System.Text;
using SabreTools.Models.ASN1;
using SabreTools.Serialization.ASN1;
using SabreTools.Serialization.ObjectIdentifier;
namespace SabreTools.Serialization.Extensions
{
@@ -107,11 +107,11 @@ namespace SabreTools.Serialization.Extensions
/// <see cref="http://snmpsharpnet.com/index.php/2009/03/02/ber-encoding-and-decoding-oid-values/"/>
case ASN1Type.V_ASN1_OBJECT:
// Derive array of values
ulong[] objectNodes = ObjectIdentifier.ParseDERIntoArray(valueAsByteArray, tlv.Length);
ulong[] objectNodes = Parser.ParseDERIntoArray(valueAsByteArray, tlv.Length);
// Append the dot and modified OID-IRI notations
string? dotNotationString = ObjectIdentifier.ParseOIDToDotNotation(objectNodes);
string? oidIriString = ObjectIdentifier.ParseOIDToOIDIRINotation(objectNodes);
string? dotNotationString = Parser.ParseOIDToDotNotation(objectNodes);
string? oidIriString = Parser.ParseOIDToOIDIRINotation(objectNodes);
formatBuilder.Append($", Value: {dotNotationString} ({oidIriString})");
break;
@@ -157,4 +157,4 @@ namespace SabreTools.Serialization.Extensions
return formatBuilder.ToString();
}
}
}
}

View File

@@ -1,9 +1,9 @@
namespace SabreTools.Serialization.ASN1
namespace SabreTools.Serialization.ObjectIdentifier
{
/// <summary>
/// Methods related to Object Identifiers (OID) and ASN.1 notation
/// </summary>
public static partial class ObjectIdentifier
public static partial class Parser
{
/// <summary>
/// Parse an OID in separated-value notation into ASN.1 notation

View File

@@ -4,12 +4,12 @@ using System.Text;
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0164 // This label has not been referenced
namespace SabreTools.Serialization.ASN1
namespace SabreTools.Serialization.ObjectIdentifier
{
/// <summary>
/// Methods related to Object Identifiers (OID) and OID-IRI formatting
/// </summary>
public static partial class ObjectIdentifier
public static partial class Parser
{
/// <summary>
/// Parse an OID in separated-value notation into modified OID-IRI notation

View File

@@ -1,12 +1,12 @@
using System;
using System.Text;
namespace SabreTools.Serialization.ASN1
namespace SabreTools.Serialization.ObjectIdentifier
{
/// <summary>
/// Methods related to Object Identifiers (OID) and OID-IRI formatting
/// </summary>
public static partial class ObjectIdentifier
public static partial class Parser
{
/// <summary>
/// Parse an OID in separated-value notation into OID-IRI notation

View File

@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
namespace SabreTools.Serialization.ASN1
namespace SabreTools.Serialization.ObjectIdentifier
{
/// <summary>
/// Methods related to Object Identifiers (OID)
/// </summary>
public static partial class ObjectIdentifier
public static partial class Parser
{
// TODO: ulong[] isn't going to work. If we can use .NET 7, we can use UInt128
// We might want to look into storing all values as GUID? I don't remember if

View File

@@ -1,11 +1,11 @@
using System;
namespace SabreTools.Serialization.ASN1
namespace SabreTools.Serialization.ObjectIdentifier
{
/// <summary>
/// Methods related to Object Identifiers (OID) and dot notation
/// </summary>
public static partial class ObjectIdentifier
public static partial class Parser
{
/// <summary>
/// Parse an OID in separated-value notation into dot notation