ASN.1 is a highly efficient standardized platform-independent binary encoding used in lots of applications, including telecommunications and cryptographic key exchanges. This just looks amazing, seriously. Huge thanks to @pwnorbitals for letting me know about this.
Some references:
Note: all of the ASN.1 specs below can be tested directly on this playground: https://asn1.io/asn1playground/ .
Benchmark encoding sizes
One issue with the der library is that it does not support the Real type defined in section 2.4 of the specs (PDF).
Rebuilding the REAL type
Built-in
ANISE DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Real ::= SEQUENCE
{
data REAL
}
END
Encode:
value Real ::= {
data 3.141592653589793
}
DER: 26 bytes
Naive
ANISE DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Real ::= SEQUENCE
{
mantissa INTEGER DEFAULT 0,
realbase INTEGER DEFAULT 10,
exponent INTEGER DEFAULT 0
}
END
Encode Pi:
value Real ::= {
mantissa 3141592653589793,
realbase 10,
exponent 15
}
DER: 14 bytes
Full specs
(Took me one hour to fix...)
ANISE DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Normal ::= SEQUENCE
{
mantissa INTEGER DEFAULT 0,
realbase INTEGER DEFAULT 10,
exponent INTEGER DEFAULT 0
}
Subnormal ::= ENUMERATED {
plus-infinity,
neg-infinity
}
Real ::= CHOICE {
as_normal Normal,
as_subnormal Subnormal
}
END
Encoding a normal number:
realdata Real ::= as_normal : {
mantissa 3141592653589793,
realbase 10,
exponent 15
}
DER: 14 bytes ( no overhead it seems!)
Encoding a subnormal number:
realdata Real ::= as_subnormal : plus-infinity
DER: 1 byte (yet, ONE!)
ASN.1 is a highly efficient standardized platform-independent binary encoding used in lots of applications, including telecommunications and cryptographic key exchanges. This just looks amazing, seriously. Huge thanks to @pwnorbitals for letting me know about this.
Some references:
Note: all of the ASN.1 specs below can be tested directly on this playground: https://asn1.io/asn1playground/ .
Benchmark encoding sizes
One issue with the
derlibrary is that it does not support theRealtype defined in section 2.4 of the specs (PDF).Rebuilding the REAL type
Built-in
Encode:
DER: 26 bytes
Naive
Encode Pi:
DER: 14 bytes
Full specs
(Took me one hour to fix...)
Encoding a normal number:
DER: 14 bytes ( no overhead it seems!)
Encoding a subnormal number:
DER: 1 byte (yet, ONE!)