System.Formats.Asn1 10.0.0-rc.1.25451.107

Prefix Reserved
This is a prerelease version of System.Formats.Asn1.
There is a newer version of this package available.
See the version list below for details.
dotnet add package System.Formats.Asn1 --version 10.0.0-rc.1.25451.107
                    
NuGet\Install-Package System.Formats.Asn1 -Version 10.0.0-rc.1.25451.107
                    
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="System.Formats.Asn1" Version="10.0.0-rc.1.25451.107" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="System.Formats.Asn1" Version="10.0.0-rc.1.25451.107" />
                    
Directory.Packages.props
<PackageReference Include="System.Formats.Asn1" />
                    
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 System.Formats.Asn1 --version 10.0.0-rc.1.25451.107
                    
#r "nuget: System.Formats.Asn1, 10.0.0-rc.1.25451.107"
                    
#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 System.Formats.Asn1@10.0.0-rc.1.25451.107
                    
#: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=System.Formats.Asn1&version=10.0.0-rc.1.25451.107&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=System.Formats.Asn1&version=10.0.0-rc.1.25451.107&prerelease
                    
Install as a Cake Tool

About

Provides functionality for parsing, encoding, and decoding data using Abstract Syntax Notation One (ASN.1). ASN.1 is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way.

Key Features

  • Parse ASN.1 data into .NET types.
  • Encode .NET types into ASN.1 format.
  • Support for BER, CER, DER: Handles Basic Encoding Rules (BER), Canonical Encoding Rules (CER), and Distinguished Encoding Rules (DER).

How to Use

Parsing ASN.1 data:

using System.Formats.Asn1;
using System.Numerics;

// Sample ASN.1 encoded data (DER format)
byte[] asn1Data = [0x30, 0x09, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x03];

// Create an AsnReader to parse the data
AsnReader reader = new(asn1Data, AsnEncodingRules.DER);

// Parse the sequence
AsnReader sequenceReader = reader.ReadSequence();

// Read integers from the sequence
BigInteger firstInt = sequenceReader.ReadInteger();
BigInteger secondInt = sequenceReader.ReadInteger();
BigInteger thirdInt = sequenceReader.ReadInteger();

Console.WriteLine($"First integer: {firstInt}");
Console.WriteLine($"Second integer: {secondInt}");
Console.WriteLine($"Third integer: {thirdInt}");

// First integer: 1
// Second integer: 2
// Third integer: 3

Decoding ASN.1 data using AsnDecoder:

using System.Formats.Asn1;
using System.Numerics;
using System.Text;

// Sample ASN.1 encoded data
byte[] booleanData = [0x01, 0x01, 0xFF]; // BOOLEAN TRUE
byte[] integerData = [0x02, 0x01, 0x05]; // INTEGER 5
byte[] octetStringData = [0x04, 0x03, 0x41, 0x42, 0x43]; // OCTET STRING "ABC"
byte[] objectIdentifierData = [0x06, 0x03, 0x2A, 0x03, 0x04]; // OBJECT IDENTIFIER 1.2.3.4
byte[] utf8StringData = [0x0C, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F]; // UTF8String "Hello"

int bytesConsumed;

bool booleanValue = AsnDecoder.ReadBoolean(booleanData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded BOOLEAN value: {booleanValue}, Bytes consumed: {bytesConsumed}");
// Decoded BOOLEAN value: True, Bytes consumed: 3

BigInteger integerValue = AsnDecoder.ReadInteger(integerData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded INTEGER value: {integerValue}, Bytes consumed: {bytesConsumed}");
// Decoded INTEGER value: 5, Bytes consumed: 3

byte[] octetStringValue = AsnDecoder.ReadOctetString(octetStringData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded OCTET STRING value: {Encoding.ASCII.GetString(octetStringValue)}, Bytes consumed: {bytesConsumed}");
// Decoded OCTET STRING value: ABC, Bytes consumed: 5

string objectIdentifierValue = AsnDecoder.ReadObjectIdentifier(objectIdentifierData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded OBJECT IDENTIFIER value: {objectIdentifierValue}, Bytes consumed: {bytesConsumed}");
// Decoded OBJECT IDENTIFIER value: 1.2.3.4, Bytes consumed: 5

string utf8StringValue = AsnDecoder.ReadCharacterString(utf8StringData, AsnEncodingRules.DER, UniversalTagNumber.UTF8String, out bytesConsumed);
Console.WriteLine($"Decoded UTF8String value: {utf8StringValue}, Bytes consumed: {bytesConsumed}");
// Decoded UTF8String value: Hello, Bytes consumed: 7

Encoding ASN.1 data:

// Create an AsnWriter to encode data
AsnWriter writer = new(AsnEncodingRules.DER);

// Create a scope for the sequence
using (AsnWriter.Scope scope = writer.PushSequence())
{
    // Write integers to the sequence
    writer.WriteInteger(1);
    writer.WriteInteger(2);
    writer.WriteInteger(3);
}

// Get the encoded data
byte[] encodedData = writer.Encode();

Console.WriteLine($"Encoded ASN.1 Data: {BitConverter.ToString(encodedData)}");

// Encoded ASN.1 Data: 30-09-02-01-01-02-01-02-02-01-03

Main Types

The main types provided by this library are:

  • System.Formats.Asn1.AsnReader
  • System.Formats.Asn1.AsnWriter
  • System.Formats.Asn1.AsnDecoder
  • System.Formats.Asn1.AsnEncodingRules

Additional Documentation

Feedback & Contributing

System.Formats.Asn1 is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

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 is compatible.  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 is compatible.  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 is compatible.  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.

NuGet packages (473)

Showing the top 5 NuGet packages that depend on System.Formats.Asn1:

Package Downloads
System.Security.Cryptography.Cng

Provides cryptographic algorithm implementations and key management with Windows Cryptographic Next Generation API (CNG). Commonly Used Types: System.Security.Cryptography.RSACng System.Security.Cryptography.ECDsaCng System.Security.Cryptography.CngKey When using NuGet 3.x this package requires at least version 3.4.

System.Security.Cryptography.OpenSsl

Provides cryptographic algorithm implementations and key management for non-Windows systems with OpenSSL. Commonly Used Types: System.Security.Cryptography.RSAOpenSsl When using NuGet 3.x this package requires at least version 3.4.

Microsoft.Identity.Client

This package contains the binaries of the Microsoft Authentication Library for .NET (MSAL.NET). MSAL.NET makes it easy to obtain tokens from the Microsoft identity platform for developers (formerly Azure AD v2.0) signing-in users with work & school accounts, Microsoft personal accounts, and social identities via Azure AD B2C. These tokens provide access to Microsoft Cloud API and any other API secured by the Microsoft identity platform. This version supports adding authentication functionality to your .NET based clients - .NET, .NET Framework, .NET MAUI

System.Security.Cryptography.Pkcs

Provides support for PKCS and CMS algorithms. Commonly Used Types: System.Security.Cryptography.Pkcs.EnvelopedCms

SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.

GitHub repositories (88)

Showing the top 20 popular GitHub repositories that depend on System.Formats.Asn1:

Repository Stars
MonoGame/MonoGame
One framework for creating powerful cross-platform games.
mRemoteNG/mRemoteNG
mRemoteNG is the next generation of mRemote, open source, tabbed, multi-protocol, remote connections manager.
unoplatform/uno
Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
memstechtips/Winhance
Application designed to optimize, customize and enhance your Windows experience.
reactiveui/refit
The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
dotnet/machinelearning
ML.NET is an open source and cross-platform machine learning framework for .NET.
serilog/serilog
Simple .NET logging with fully-structured events
jstedfast/MailKit
A cross-platform .NET library for IMAP, POP3, and SMTP.
EduardoPires/EquinoxProject
Web Application ASP.NET 9 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices
actions/runner
The Runner for GitHub Actions :rocket:
Azure/azure-powershell
Microsoft Azure PowerShell
sshnet/SSH.NET
SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
CommunityToolkit/dotnet
.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
Sergio0694/ComputeSharp
A .NET library to run C# code in parallel on the GPU through DX12, D2D1, and dynamically generated HLSL compute and pixel shaders, with the goal of making GPU computing easy to use for all .NET developers! 🚀
CommunityToolkit/Maui
The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
NuGetPackageExplorer/NuGetPackageExplorer
Create, update and deploy Nuget Packages with a GUI
OrchardCMS/Orchard
Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform. Check out the next generation of this software built on ASP.NET Core: https://github.com/OrchardCMS/OrchardCore
OPCFoundation/UA-.NETStandard
OPC Unified Architecture .NET Standard
ProtonVPN/win-app
Official ProtonVPN Windows app
MichaelGrafnetter/DSInternals
Directory Services Internals (DSInternals) PowerShell Module and Framework
Version Downloads Last Updated
11.0.0-preview.3.26207.106 4,625 4/14/2026
11.0.0-preview.2.26159.112 4,879 3/10/2026
11.0.0-preview.1.26104.118 6,061 2/10/2026
10.0.7 146,390 4/21/2026
10.0.6 275,265 4/14/2026
10.0.5 686,133 3/12/2026
10.0.4 76,937 3/10/2026
10.0.3 750,967 2/10/2026
10.0.2 1,633,785 1/13/2026
10.0.1 906,343 12/9/2025
10.0.0 1,638,596 11/11/2025
10.0.0-rc.2.25502.107 13,670 10/14/2025
10.0.0-rc.1.25451.107 20,517 9/9/2025
9.0.15 267,003 4/14/2026
9.0.14 477,243 3/10/2026
9.0.13 549,195 2/10/2026
9.0.12 858,371 1/13/2026
9.0.11 3,486,128 11/11/2025
9.0.10 6,422,067 10/14/2025
9.0.9 8,458,953 9/9/2025
Loading failed