TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A New ASN.1 API for Python

171 pointsby woodruffwabout 1 month ago

14 comments

ChuckMcMabout 1 month ago
A small bit of historical context. When I was participating in the PKP meetings at RSADSI, I believe it was Ron who insisted that DER was the only reasonable choice if we were going to encode things with ASN.1 (which we were because both DEC and RSA had already insisted that it had to be OSI compatible or they wouldn&#x27;t support it, my suggestion that we use Sun&#x27;s XDR was soundly rebuked, but hey I had to offer)<p>Generally it was presumed that because these were &#x27;handshake&#x27; type steps (which is to say the prelude to establishing a cryptographic context for what would happen next) performance wasn&#x27;t as important as determinism.
评论 #43732233 未加载
评论 #43732250 未加载
orthecreedenceabout 1 month ago
I was writing a cryptographically-inclined system with serialization in msgpack. At one point, I upgraded the libraries I was using and all my signatures started breaking because the msgpack library started using a different representation under the hood for some of my data structures. That&#x27;s when I did some research and found ASN.1 DER and haven&#x27;t really looked back since switching over to it. If you plan on signing your data structures and don&#x27;t want to implement your own serialization format, give ASN.1 DER a look.
评论 #43734082 未加载
nicceabout 1 month ago
There is also rasn library for Rust that now supports most of the codecs (BER&#x2F;CER&#x2F;DER&#x2F;PER&#x2F;APER&#x2F;OER&#x2F;COER&#x2F;JER&#x2F;XER).<p>Disclaimer: I have contributed a lot recently. OER codec (modern flair of ASN.1) is very optimized (almost as much as it can be with safe Rust and without CPU specific stuff). I am still working with benchmarking results, which I plan to share in close future. But it starts to be the fastest there is in open-source world. It is also faster than Google&#x27;s Protobuf libraries or any Protobuf library in Rust. (naive comparison, no reflection support). Hopefully other codecs could be optimized too.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;librasn&#x2F;rasn">https:&#x2F;&#x2F;github.com&#x2F;librasn&#x2F;rasn</a>
评论 #43734389 未加载
评论 #43733302 未加载
评论 #43730512 未加载
评论 #43730410 未加载
flowerthoughtsabout 1 month ago
Related: if you ever want to create your own serialization format, please at least have a cursory look at the basics of ASN.1. It&#x27;s very complete both in terms of textual descriptions (how it started) and breadth of encoding rules (because it&#x27;s practical.)<p>(You can skip the classes and macros, though they are indeed cool...)
评论 #43731479 未加载
johnisgoodabout 1 month ago
Erlang also has great ASN.1 support. For the rest, I hope OSS Nokalva&#x27;a proprietary solutions will go away, eventually.<p>For Java I used yafred&#x27;s asn1-tool, which is apparently not available anymore. Other than that, it worked well.<p>Originally it was available here: <a href="https:&#x2F;&#x2F;github.com&#x2F;yafred&#x2F;asn1-tool">https:&#x2F;&#x2F;github.com&#x2F;yafred&#x2F;asn1-tool</a> (archived: <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20240416031004&#x2F;https:&#x2F;&#x2F;github.com&#x2F;yafred&#x2F;asn1-tool" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20240416031004&#x2F;https:&#x2F;&#x2F;github.co...</a>)<p>Any recommendations?
评论 #43731151 未加载
评论 #43728959 未加载
评论 #43729231 未加载
dikeiabout 1 month ago
DER is still easy, UPER (unaligned packed encoding rules) is so much harder, yet it&#x27;s prevalent in Telecom industry. Last I checked, there was no freely available tool than can handle UPER l00%
评论 #43728869 未加载
评论 #43728880 未加载
评论 #43730501 未加载
评论 #43732209 未加载
venamresm__about 1 month ago
In the ASN.1 space everyone hopes that someone can dethrone OSS Nokalva&#x27;s proprietary solutions
评论 #43728589 未加载
评论 #43729509 未加载
评论 #43734350 未加载
woodrowbarlowabout 1 month ago
neat!<p>related: you can also create wireshark dissectors from ASN.1 files<p><a href="https:&#x2F;&#x2F;www.wireshark.org&#x2F;docs&#x2F;wsdg_html_chunked&#x2F;ASN1StepByStepInstructions.html" rel="nofollow">https:&#x2F;&#x2F;www.wireshark.org&#x2F;docs&#x2F;wsdg_html_chunked&#x2F;ASN1StepByS...</a>
zzo38computerabout 1 month ago
I do not use Python, but I wrote my own library in C for reading&#x2F;writing DER. (I have made a variant, which adds a few new types such as: key&#x2F;value list, BCD, TRON character code, etc. The program works even if you do not use these new types.)<p>DER does have the advantages they mention in that article, and other advantages.<p>Some people mention that DER is not compact or not efficient; but often what is used instead is formats that are even less compact or less efficient than DER, and&#x2F;or that are significantly more complicated to handle.
mootptrabout 1 month ago
Parser differential exploits are a understated problem, especially with ASN.1, which I didn&#x27;t expect to see anyone thinking about. Kudos on this initiative!
评论 #43733904 未加载
benatkinabout 1 month ago
From the post<p>&gt; with the help of funding from Alpha-Omega<p>From the site:<p>&gt; funded by Microsoft, Google, and Amazon<p>Also it&#x27;s a Linux Foundation project.<p>Interesting. Python&#x27;s a big community, and there&#x27;s some disagreement here over whether this would be better done in pure python. I think it&#x27;s good that there&#x27;s a rust&#x2F;cloud contingent in python land but hope pure python remains popular.
评论 #43737126 未加载
lilyballabout 1 month ago
Oh right, the asn1 crate, which supports CHOICE but only up to 3 alternatives, which means it can&#x27;t even be used to implement X.509 certificate decoding. Makes me wonder what they&#x27;re going to do when they get that far.
评论 #43733638 未加载
time4teaabout 1 month ago
20+ years ago used ASN.1 for talking between micro services. (HTTP Services, as they were called then) Very performant. Had to buy OSS tools licence but other than that quite nice.
dec0dedab0deabout 1 month ago
Does anyone miss when &quot;pure python&quot; was a selling point of your library? I understand the need for speed, but I wish it were more common to ship a compiled binary that does the thing fast, as well as the same algorithm in python to fall back on if it&#x27;s not available.
评论 #43731382 未加载
评论 #43731216 未加载
评论 #43731215 未加载
评论 #43731247 未加载
评论 #43732268 未加载