Skip to content

vvv/under.c

Repository files navigation

`under' utility decodes binary DER data to textual S-expressions
(sexps) and/or encodes sexps back to DER.

DER - Distinguished Encoding Rules [1] - is a ``type-length-value''
binary encoding of hierarchical ASN.1 [2] data. Examples of DER files
are SSL certificates [3], call detail records generated by mobile
switching centers [4], etc.

  [1] http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules
  [2] http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One
  [3] http://en.wikipedia.org/wiki/X.509
  [4] http://en.wikipedia.org/wiki/Network_switching_subsystem

`under' utility can be employed to create custom DER files for testing
DER-processing software.

It is distributed under the GNU General Public License; see the
`COPYING' file for more details.


EXAMPLES:

    $ under sample.der
    (p1
        (p70 "04")
        (p71 "1b")
        (p40 "a1 76 49 13 73 f3")
        (p14
            (p19 "09 07 10")
            (p20
                (p74 "10 13 35"))
            (p17 "18"))
        (u16
            (p9 "91 83 50 10 32 54 76")
            (p39 "81 08 05 67 45 23 f1"))
        (p10 "00 33 20")
        (p73 "41 44 30 37 32 31 37 30 30 33 45")
        (p5
            (p75 "42 4d 53 43 31 33")
            (p12 "00 04 1f"))
        (p4
            (p75 "42 4d 53 43 32 38")
            (p12 "00 02 03"))
        (p25 "13 6e 06"))

    $ under sample.der | under -e | cmp sample.der -
    $

    $ openssl asn1parse -inform DER -i < sample.der
        0:d=0  hl=2 l= 112 cons: priv [ 1 ]
        2:d=1  hl=3 l=   1 prim:  priv [ 70 ]
        6:d=1  hl=3 l=   1 prim:  priv [ 71 ]
       10:d=1  hl=3 l=   6 prim:  priv [ 40 ]
       19:d=1  hl=2 l=  16 cons:  priv [ 14 ]
       21:d=2  hl=2 l=   3 prim:   priv [ 19 ]
       26:d=2  hl=2 l=   6 cons:   priv [ 20 ]
       28:d=3  hl=3 l=   3 prim:    priv [ 74 ]
       34:d=2  hl=2 l=   1 prim:   priv [ 17 ]
       37:d=1  hl=2 l=  19 cons:  SEQUENCE
       39:d=2  hl=2 l=   7 prim:   priv [ 9 ]
       48:d=2  hl=3 l=   7 prim:   priv [ 39 ]
       58:d=1  hl=2 l=   3 prim:  priv [ 10 ]
       63:d=1  hl=3 l=  11 prim:  priv [ 73 ]
       77:d=1  hl=2 l=  14 cons:  priv [ 5 ]
       79:d=2  hl=3 l=   6 prim:   priv [ 75 ]
       88:d=2  hl=2 l=   3 prim:   priv [ 12 ]
       93:d=1  hl=2 l=  14 cons:  priv [ 4 ]
       95:d=2  hl=3 l=   6 prim:   priv [ 75 ]
      104:d=2  hl=2 l=   3 prim:   priv [ 12 ]
      109:d=1  hl=2 l=   3 prim:  priv [ 25 ]

    $ hexdump -C sample.der
    00000000  e1 70 df 46 01 04 df 47  01 1b df 28 06 a1 76 49  |.p.F...G...(..vI|
    00000010  13 73 f3 ee 10 d3 03 09  07 10 f4 06 df 4a 03 10  |.s...........J..|
    00000020  13 35 d1 01 18 30 13 c9  07 91 83 50 10 32 54 76  |.5...0.....P.2Tv|
    00000030  df 27 07 81 08 05 67 45  23 f1 ca 03 00 33 20 df  |.'....gE#....3 .|
    00000040  49 0b 41 44 30 37 32 31  37 30 30 33 45 e5 0e df  |I.AD07217003E...|
    00000050  4b 06 42 4d 53 43 31 33  cc 03 00 04 1f e4 0e df  |K.BMSC13........|
    00000060  4b 06 42 4d 53 43 32 38  cc 03 00 02 03 d9 03 13  |K.BMSC28........|
    00000070  6e 06                                             |n.|
    00000072

About

DER data decoder/encoder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages