Comments (5)
Hey, some update. I have a basic BER decoder working now, also working on adding support for arbitrary large integer to the decoder which will be useful for ASN.1. and make it more useful for certificates and crypto related things i think. Hope i can push something in the next few days.
from fq.
Hi, yes that is a good idea. It would also require figuring out a nice way of passing in a grammar file to the decoder.
If you want to work on this i would recommend having a look at the protobutf decoder https://github.com/wader/fq/blob/master/format/protobuf/protobuf.go. It does not support passing in schemas but other decoders can pass it something schema-like internally to improve the decode output.
from fq.
Thanks. I will take a look if I have time in January.
from fq.
π There are some other issues #25 #24 that will share som issues with this like how to provide an external description file and how to model the decoded value tree.
from fq.
Hey, now there is basic ASN1 BER support in master and also some kind of torepr
support.
To make it a bit easer to work with PEM there is also frompem
/topem
now.
Any feedback what could be done differently or bugs are much appreciated.
Example reading PEM file, decode it and display it as decode tree, JSON and torepr JSON:
$ fq -o line_bytes=10 -d raw '(. | tobytes | tostring | println), (frompem | asn1_ber | d, tovalue, torepr)' format/asn1/testdata/test.pem
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMYfnvWtC8Id5bPKae5yXSxQTt
+Zpul6AnnZWfI2TtIarvjHBFUtXRo96y7hoL4VWOPKGCsRqMFDkrbeUjRrx8iL91
4/srnyf6sh9c8Zk04xEOpK1ypvBz+Ks4uZObtjnnitf0NBGdjMKxveTq+VE7BWUI
yQjtQ8mbDOsiLLvh7wIDAQAB
-----END PUBLIC KEY-----
β00 01 02 03 04 05 06 07 08 09β0123456789β.{}: (asn1_ber)
0x00β30 β0 β class: "universal" (0)
0x00β30 β0 β form: "constructed" (1)
0x00β30 β0 β tag: "sequence" (0x10)
0x00β 81 9f β .. β length: 159
β β β constructed[0:2]:
β β β [0]{}:
0x00β 30 β 0 β class: "universal" (0)
0x00β 30 β 0 β form: "constructed" (1)
0x00β 30 β 0 β tag: "sequence" (0x10)
0x00β 0d β . β length: 13
β β β constructed[0:2]:
β β β [0]{}:
0x00β 06 β . β class: "universal" (0)
0x00β 06 β . β form: "primitive" (0)
0x00β 06 β . β tag: "object_identifier" (0x6)
0x00β 09 β . β length: 9
β β β value[0:7]:
0x00β 2a β * β [0]: 1
0x00β 2a β * β [1]: 2
0x00β 86 48β .Hβ [2]: 840
0x0aβ86 f7 0d β... β [3]: 113549
0x0aβ 01 β . β [4]: 1
0x0aβ 01 β . β [5]: 1
0x0aβ 01 β . β [6]: 1
β β β [1]{}:
0x0aβ 05 β . β class: "universal" (0)
0x0aβ 05 β . β form: "primitive" (0)
0x0aβ 05 β . β tag: "null" (0x5)
0x0aβ 00 β . β length: "indefinite" (0)
β β β value: null
β β β [1]{}:
0x0aβ 03 β . β class: "universal" (0)
0x0aβ 03 β . β form: "primitive" (0)
0x0aβ 03 β . β tag: "bit_string" (0x3)
0x0aβ 81β .β length: 141
0x14β8d β. β
0x14β 00 β . β unused_bits_count: 0
0x14β 30 81 89 02 81 81 00 ccβ 0.......β value: raw bits
0x1eβ61 f9 ef 5a d0 bc 21 de 5b 3cβa..Z..!.[<β
0x28βa6 9e e7 25 d2 c5 04 ed f9 9aβ...%......β
* βuntil 0xa1.7 (end) (140) β β
{
"class": "universal",
"constructed": [
{
"class": "universal",
"constructed": [
{
"class": "universal",
"form": "primitive",
"length": 9,
"tag": "object_identifier",
"value": [
1,
2,
840,
113549,
1,
1,
1
]
},
{
"class": "universal",
"form": "primitive",
"length": "indefinite",
"tag": "null",
"value": null
}
],
"form": "constructed",
"length": 13,
"tag": "sequence"
},
{
"class": "universal",
"form": "primitive",
"length": 141,
"tag": "bit_string",
"unused_bits_count": 0,
"value": "<140>MIGJAoGBAMxh+e9a0Lwh3ls8pp7nJdLFBO35mm6XoCedlZ8jZO0hqu+McEVS1dGj3rLuGgvhVY48oYKxGowUOStt5SNGvHyIv3Xj+yufJ/qyH1zxmTTjEQ6krXKm8HP4qzi5k5u2OeeK1/Q0EZ2MwrG95Or5UTsFZQjJCO1DyZsM6yIsu+HvAgMBAAE="
}
],
"form": "constructed",
"length": 159,
"tag": "sequence"
}
[
[
[
1,
2,
840,
113549,
1,
1,
1
],
null
],
"<0b10001100>MIGJAoGBAMxh+e9a0Lwh3ls8pp7nJdLFBO35mm6XoCedlZ8jZO0hqu+McEVS1dGj3rLuGgvhVY48oYKxGowUOStt5SNGvHyIv3Xj+yufJ/qyH1zxmTTjEQ6krXKm8HP4qzi5k5u2OeeK1/Q0EZ2MwrG95Or5UTsFZQjJCO1DyZsM6yIsu+HvAgMBAAE="
]
from fq.
Related Issues (20)
- demo.svg looks wired in my environment HOT 11
- [feature] shell completions HOT 3
- [Feature request] Support cwf, swf, zwf HOT 1
- [Feature request] Support pdf HOT 1
- [Feature] Support for Doom WAD Files HOT 5
- [feature] add decimal floating-point number support HOT 2
- mp3 file with id3 2.4.0 got killed from console output HOT 6
- typo HOT 3
- [Documentation] Any interest in creating a man page? HOT 5
- Feature request: zero-length start/end properties HOT 7
- Support for non-canonical tags with html HOT 5
- Color output is unreadable on terminals using light backgrounds. HOT 4
- make use of kaitai struct for additional formats? HOT 4
- [Feature request] Support image/bmp HOT 1
- Format Decoder Conventions HOT 3
- zip: last_modification_date and last_modification_time are mislabeled or swapped HOT 2
- gzip files can contain multiple concatenated gzips HOT 8
- Investigate Data Format Description Language (DFDL) HOT 4
- Consider relicensing internal/mathex/float80.go HOT 3
- Enhancing Stream Processing Capabilities for Real-Time Binary Data Analysis HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fq.