blob: 5b54821b8256bb448d33df9f0c7d7b770588d73b [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A small ASN.1 parsing library for Rust. In particular, this library is used to translate the binary DER encoding of an ASN.1-formatted document into the core primitives of ASN.1. It is assumed that you can do what you need to from there."><meta name="keywords" content="rust, rustlang, rust-lang, simple_asn1"><title>simple_asn1 - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../simple_asn1/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../simple_asn1/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate simple_asn1</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.4.1</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">simple_asn1</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/simple_asn1/lib.rs.html#1-1651">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A small ASN.1 parsing library for Rust. In particular, this library is used
to translate the binary DER encoding of an ASN.1-formatted document into the
core primitives of ASN.1. It is assumed that you can do what you need to
from there.</p>
<p>The critical items for this document are the traits <code>ToASN1</code> and <code>FromASN1</code>.
The first takes your data type and encodes it into a <code>Vec</code> of simple ASN.1
structures (<code>ASN1Block</code>s). The latter inverts the process.</p>
<p>Items that implement <code>ToASN1</code> can be used with the function <code>der_encode</code>
to provide single-step encoding of a data type to binary DER encoding.
Similarly, items that are <code>FromASN</code> can be single-step decoded using
the helper function <code>der_decode</code>.</p>
<p>You can implement one or both traits, depending on your needs. If you do
implement both, the obvious encode/decode quickcheck property is strongly
advised.</p>
<p>For decoding schemes that require the actual bytes associated with the
binary representation, we also provide <code>FromASN1WithBody</code>. This can be
used with the offset information in the primitive <code>ASN1Block</code>s to, for
example, validate signatures in X509 documents.</p>
<p>Finally, this library supports ASN.1 class information. I’m still not sure
why it’s useful, but there it is.</p>
<p>Please send any bug reports, patches, and curses to the GitHub repository
at <code>https://github.com/acw/simple_asn1</code>.</p>
</div></details><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.oid.html" title="simple_asn1::oid macro">oid</a></div><div class="item-right docblock-short">A handy macro for generating OIDs from a sequence of <code>u64</code>s.</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BigInt.html" title="simple_asn1::BigInt struct">BigInt</a></div><div class="item-right docblock-short">A big signed integer type.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BigUint.html" title="simple_asn1::BigUint struct">BigUint</a></div><div class="item-right docblock-short">A big unsigned integer type.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.OID.html" title="simple_asn1::OID struct">OID</a></div><div class="item-right docblock-short">An ASN.1 OID.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.ASN1Block.html" title="simple_asn1::ASN1Block enum">ASN1Block</a></div><div class="item-right docblock-short">A primitive block from ASN.1.</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.ASN1Class.html" title="simple_asn1::ASN1Class enum">ASN1Class</a></div><div class="item-right docblock-short">An ASN.1 block class.</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.ASN1DecodeErr.html" title="simple_asn1::ASN1DecodeErr enum">ASN1DecodeErr</a></div><div class="item-right docblock-short">An error that can arise decoding ASN.1 primitive blocks.</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.ASN1EncodeErr.html" title="simple_asn1::ASN1EncodeErr enum">ASN1EncodeErr</a></div><div class="item-right docblock-short">An error that can arise encoding ASN.1 primitive blocks.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.FromASN1.html" title="simple_asn1::FromASN1 trait">FromASN1</a></div><div class="item-right docblock-short">A trait defining types that can be decoded from an <code>ASN1Block</code> stream.
Any member of this trait is also automatically a member of
<code>FromASN1WithBody</code>, as it can obviously just ignore the body.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.FromASN1WithBody.html" title="simple_asn1::FromASN1WithBody trait">FromASN1WithBody</a></div><div class="item-right docblock-short">A trait defining types that can be decoded from an <code>ASN1Block</code> stream,
assuming they also have access to the underlying bytes making up the
stream.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.ToASN1.html" title="simple_asn1::ToASN1 trait">ToASN1</a></div><div class="item-right docblock-short">The set of types that can automatically converted into a sequence
of <code>ASN1Block</code>s. You should probably use to_asn1() but implement
to_asn1_class(). The former has a default implementation that passes
<code>ASN1Class::Universal</code> as the tag to use, which should be good for
most people.</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.der_decode.html" title="simple_asn1::der_decode fn">der_decode</a></div><div class="item-right docblock-short">Automatically decode a type via DER encoding, assuming that the type
is a member of <code>FromASN1</code> or <code>FromASN1WithBody</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.der_encode.html" title="simple_asn1::der_encode fn">der_encode</a></div><div class="item-right docblock-short">Automatically encode a type into binary via DER encoding, assuming
that the type is a member of <code>ToASN1</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.from_der.html" title="simple_asn1::from_der fn">from_der</a></div><div class="item-right docblock-short">Translate a binary blob into a series of <code>ASN1Block</code>s, or provide an
error if it didn’t work.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.to_der.html" title="simple_asn1::to_der fn">to_der</a></div><div class="item-right docblock-short">Given an <code>ASN1Block</code>, covert it to its DER encoding, or return an error
if something broke along the way.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="simple_asn1" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>