2022-09-22 19:32:13 +03:00
|
|
|
$ fq -h asn1_ber
|
|
|
|
asn1_ber: ASN1 BER (basic encoding rules, also CER and DER) decoder
|
|
|
|
|
|
|
|
Decode examples
|
|
|
|
===============
|
|
|
|
|
|
|
|
# Decode file as asn1_ber
|
|
|
|
$ fq -d asn1_ber . file
|
|
|
|
# Decode value as asn1_ber
|
|
|
|
... | asn1_ber
|
|
|
|
|
|
|
|
Supports decoding BER, CER and DER (X.690).
|
|
|
|
|
|
|
|
- Currently no extra validation is done for CER and DER.
|
|
|
|
- Does not support specifying a schema.
|
|
|
|
- Supports torepr but without schema all sequences and sets will be arrays.
|
|
|
|
|
|
|
|
Can be used to decode certificates etc
|
|
|
|
======================================
|
2022-12-21 15:59:54 +03:00
|
|
|
$ fq -d bytes 'from_pem | asn1_ber | d' cert.pem
|
2023-03-03 01:18:31 +03:00
|
|
|
|
2022-09-22 19:32:13 +03:00
|
|
|
Can decode nested values
|
|
|
|
========================
|
|
|
|
$ fq -d asn1_ber '.constructed[1].value | asn1_ber' file.ber
|
2023-03-03 01:18:31 +03:00
|
|
|
|
2022-09-22 19:32:13 +03:00
|
|
|
Manual schema
|
|
|
|
=============
|
|
|
|
$ fq -d asn1_ber 'torepr as $r | ["version", "modulus", "private_exponent", "private_exponen", "prime1", "prime2", "exponent1", "exponent2", "coefficient"] | with_entries({key: .value, value: $r[.key]})' pkcs1.der
|
2023-03-03 01:18:31 +03:00
|
|
|
|
2022-09-22 19:32:13 +03:00
|
|
|
References
|
|
|
|
==========
|
|
|
|
- https://www.itu.int/ITU-T/studygroups/com10/languages/X.690_1297.pdf
|
|
|
|
- https://en.wikipedia.org/wiki/X.690
|
|
|
|
- https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/
|
|
|
|
- https://lapo.it/asn1js/
|