MiniBer 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package MiniBer --version 1.0.2
                    
NuGet\Install-Package MiniBer -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MiniBer" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiniBer" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="MiniBer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MiniBer --version 1.0.2
                    
#r "nuget: MiniBer, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MiniBer@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MiniBer&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=MiniBer&version=1.0.2
                    
Install as a Cake Tool

MiniBer

Versatile ASN.1 parser for .NET (BER/DER/CER/TLV).

NuGet version Target Framework License: MIT

Overview

MiniBer is a developer-friendly library designed to parse and navigate ASN.1 binary structures. It provides a straightforward way to handle Tag-Length-Value (TLV) data, supporting the most common encoding rules used in cryptography, telecommunications, and digital certificates.

Features

  • Multi-Standard Support: decode data encoded with BER (Basic), DER (Distinguished), and CER (Canonical) rules.
  • TLV Navigation: simple API to traverse complex and nested ASN.1 trees.
  • Flexible Compatibility: works with both modern .NET 8.0+ applications and legacy .NET Standard 2.0 projects.
  • AOT Ready: works with projects published using AOT (Ahead-Of-Time), supports trimming.
  • Lightweight: zero external dependencies.

Installation

Install via NuGet:

dotnet add package MiniBer

Usage

Quick start: decoding data

byte[] data = [
    0x01, 0x01, 0xFF,                        // ELEMENT #1
    0x9F, 0x1A, 0x02, 0x12, 0x34,            // ELEMENT #2
    0x5C, 0x00,                              // ELEMENT #3
    0xDF, 0x02, 0x81, 0x02, 0xAB, 0xCD,      // ELEMENT #4
    0xE1, 0x05, 0x30, 0x03, 0x02, 0x01, 0x01 // ELEMENT #5
];

MiniBer.Nodes nodes = MiniBer.Decoder.Decode(
    data: data);

Parsed nodes: | TagNumber | IdentifierOctets | Class | ContentType | Length | Contents | |-----------|------------------|-----------------|-------------|--------|------------------------------| | 0x01 | 0x01 | Universal | Primitive | 1 | 0xFF | | 0x1A | 0x9F, 0x1A | ContextSpecific | Primitive | 2 | 0x12, 0x34 | | 0x1C | 0x5C | Application | Primitive | 0 | | | 0x02 | 0xDF, 0x02 | Private | Primitive | 2 | 0xAB, 0xCD | | 0x01 | 0xE1 | Private | Constructed | 5 | 0x30, 0x03, 0x02, 0x01, 0x01 |

Searching nodes by TagNumber

Searches a Nodes objects, looking for nodes with a specific TagNumber property.

MiniBer.Nodes foundNodes = nodes.Search(
    tagNumber: 0x01);

Found nodes: | TagNumber | IdentifierOctets | Class | ContentType | Length | Contents | |-----------|------------------|-----------------|-------------|--------|------------------------------| | 0x01 | 0x01 | Universal | Primitive | 1 | 0xFF | | 0x01 | 0xE1 | Private | Constructed | 5 | 0x30, 0x03, 0x02, 0x01, 0x01 |

Searching nodes by IdentifierOctects

Searches a Nodes objects, looking for nodes with a specific TagNumber property.

MiniBer.Nodes foundNodes1 = nodes.Search(
    identifierOctects: [0xDF, 0x02]);

Or:

MiniBer.Nodes foundNodes2 = nodes[0xDF, 0x02];

Found node: | TagNumber | IdentifierOctets | Class | ContentType | Length | Contents | |-----------|------------------|-----------------|-------------|--------|------------------------------| | 0x02 | 0xDF, 0x02 | Private | Primitive | 2 | 0xAB, 0xCD |

Looking for a subnode, knowing it's index

MiniBer.Node? node = nodes.SearchPath(4, 0, 0);

Or:

MiniBer.Node node2 = nodes[4].Nodes[0].Nodes[0];

Found node: | TagNumber | IdentifierOctets | Class | ContentType | Length | Contents | |-----------|------------------|-----------------|-------------|--------|------------------------------| | 0x02 | 0x02 | Universal | Primitive | 1 | 0x01 |

API Reference

Object MiniBer.Decoder

Method Return type Description
Decode(byte[] data, DecodeOptions decodeOptions) Nodes Decodes data, specifing decoding options.
Decode(byte[] data) Nodes Same as Decode(data, DecodeOptions.None).

Object MiniBer.Nodes

Method Return type Description
Search(int tagNumber) Nodes Search all nodes based on TagNumber property.
Search(byte[] identifierOctects) Nodes Search all nodes, based on IdentifierOctects property.
this[params byte[] identifierOctects] Nodes Same as Search(byte[] identifierOctects).
SearchPath(params int[] path) Node? Searches a node on a path of indexes.

Object MiniBer.Node

Property Type Description
TagNumber int The elaborated tag number.
IdentifierOctets List<byte>? The original identifier octects.
Class Classes Class of the node.
ContentType ContentTypes Content type of the node.
Nodes Nodes? Inner nodes of the node.
Length int The calculated length of the contents.
IndefinitiveLength bool Determines if Lenght is indefinitive.
LengthOctects List<byte>? The original length octects.
Contents byte[]? Data contents.
Method Return type Description
TryParseSubNodes(DecodeOptions decodeOptions) bool Try parse Contents property to the Nodes property.
TryParseSubNodes() bool Same as TryParseSubNodes(decodeOptions: DecodeOptions.None).
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 97 2/6/2026
1.0.2 125 2/5/2026
1.0.1 112 2/5/2026
1.0.0 106 2/5/2026

# Changelog for MiniBer

## Version 1.0.2
- FIX: stop Nodes.Parse() if Data is empty.
- FIX: removed test TLV_Error01().

## Version 1.0.1
- Updated README.md

## Version 1.0.0
- First released version