|
1 dergen.pl |
|
2 ********* |
|
3 This Perl application recursively parses a set of text files translating the |
|
4 contents into a DER encoding. This should now support all of the ASN.1 |
|
5 tags required to create a PKCS#12 file. |
|
6 |
|
7 Syntax: |
|
8 |
|
9 * key value format |
|
10 * one key per line |
|
11 * tabs + whitespace up to command ignored |
|
12 * comment is // |
|
13 * $1 .. $N for textual substitution of args |
|
14 * escape character is \ |
|
15 * case insensitive |
|
16 |
|
17 Simple types are of the form |
|
18 SIMPLE_COMMAND=arg1,arg2,arg3 |
|
19 |
|
20 simple types |
|
21 ************ |
|
22 BITSTRING |
|
23 Output an DER bit string |
|
24 ARG0=A sequence of 0s and 1s. |
|
25 BMPSTRING |
|
26 Encodes ascii text as BMPSTRING |
|
27 ARG0=ascii text to encode |
|
28 BMPSTRING_FILE |
|
29 Includes a BMPSTRING file as a BMPSTRING element |
|
30 ARG0=name of file to include |
|
31 ENUMERATED |
|
32 Encodes and enumerated value |
|
33 ARG0=integer value of enum |
|
34 IA5STRING |
|
35 Encodes ascii text as BMPSTRING |
|
36 ARG0=ascii text to encode |
|
37 IA5STRING_FILE |
|
38 Includes a IA5STRING file as an IA5STRING element |
|
39 ARG0=name of file to include |
|
40 INCLUDE_BINARY_FILE |
|
41 Includes raw binary data from a file |
|
42 ARG0=filename to include |
|
43 INTEGER|INT |
|
44 Outputs an integer |
|
45 ARG0=Integer in decimal or hex format (leading 0x) |
|
46 NULL |
|
47 A null entry (no args) |
|
48 OID |
|
49 An ASN.1 object identifier |
|
50 ARG0=Raw form (1.2.840.113549.1) or one of the defined key words (look in the source) |
|
51 PRINTABLESTRING |
|
52 Encodes ascii text as PRINTABLESTRING |
|
53 ARG0=ascii text to encode |
|
54 UTF8STRING_FILE |
|
55 Includes a UTF8STRING file as an UTF8STRING element |
|
56 ARG0=name of file to include |
|
57 RAW |
|
58 Allows raw hex to be inserted into the file |
|
59 ARG0=AA:BB:CC:DD:EE:FF |
|
60 UTCTIME |
|
61 Encodes a utc time. N.B. no attempt is made to validate the format of the time. |
|
62 ARG0=time in ascii |
|
63 UTF8STRING |
|
64 Encodes ascii text as UTF8STRING |
|
65 ARG0=ascii text to encode |
|
66 UTF8STRING_FILE |
|
67 Includes a UTF8STRING file as an UTF8STRING element |
|
68 ARG0=name of file to include |
|
69 ********** |
|
70 |
|
71 Compound types are of the form and apply an encoding to the result of |
|
72 recursively concatenating the embedded types. |
|
73 |
|
74 COMPOUND_TYPE |
|
75 SIMPLE_TYPE |
|
76 COMPOUND_TYPE |
|
77 SIMPLE_TYPE |
|
78 END |
|
79 SIMPLE_TYPE |
|
80 END |
|
81 |
|
82 compound types |
|
83 ************** |
|
84 BITSTRING_WRAPPER |
|
85 Wraps the nested content inside a BITSTRING |
|
86 INCLUDE |
|
87 Allows nesting of dergen script file. Arguments may also be passed for textual substitution. Refer to arguments as $1 .. $N |
|
88 ARG0=filename to include |
|
89 ARG1 (optional)=argument to subtitute for $1 in include file |
|
90 ARGN (optional)=argument |
|
91 |
|
92 IMPLICIT |
|
93 Changes the tag of the embedded type according to the tag number and class arguments. |
|
94 The default tag number is 0 and the default class is CONTEXT-SPECIFIC. |
|
95 ARG1 (optional)=tag nummber (in hex) |
|
96 ARG2 (optional)=class (UNIVERSAL,APPLICATION,CONTEXT-SPECIFIC,PRIVATE) |
|
97 |
|
98 ENCRYPT |
|
99 Encrypts the nested data. (Requires OpenSSL) |
|
100 ARG0=cipher (as defined by openssl without the leading hyphen) |
|
101 ARG1=key (in hex) |
|
102 ARG2=iv (in hex) |
|
103 EXPLICIT |
|
104 Wraps the embedded type with a new tag defined by the tag number and class arguments. |
|
105 The default tag number is 0 and the default class is CONTEXT-SPECIFIC. |
|
106 ARG0 (optional)=tag nummber (in hex) |
|
107 ARG1 (optional)class (UNIVERSAL,APPLICATION,CONTEXT-SPECIFIC,PRIVATE) |
|
108 HASH |
|
109 Embeds the hash of the nested data. (Requries OpenSSL) |
|
110 ARG0=algorithm (as defined by OpenSSL without the leading hyphen) |
|
111 HMAC |
|
112 Embeds a HMAC for the nested data. |
|
113 ARG0=algorithm (SHA1|MD5) |
|
114 ARG1=key (in kex) |
|
115 OCTETSTRING |
|
116 Wraps the nested content in an OCTETSTRING tag |
|
117 OUTPUT_BINARY_FILE |
|
118 Outputs the nested data in binary form to the named file and optionally includes the nested data in the |
|
119 encoding stream as well. |
|
120 ARG0=The filename to write the data to |
|
121 ARG1=Set this to 1 to also include the binary content int he output stream (Optional) |
|
122 SEQ |
|
123 Embeds content in a SEQ tag |
|
124 SIGN Creates a PKCS#7 signed data object of the nested data using OpenSSL's SMIME command |
|
125 ARG0=signing certificate filename (PEM format) |
|
126 ARG1=signing key filename (PEM format) |
|
127 SET |
|
128 Embeds content in a SET tag |
|
129 SHELL |
|
130 Executes an arbitrary shell command |
|
131 ARG0=program to run |
|
132 ARG1 (optional)=first argument to shell command |
|
133 ARGN (optional)=last largument to shell command |
|
134 |
|
135 command line arguments |
|
136 ********************** |
|
137 --in <filename> : script file |
|
138 --out <filename> : output file |
|
139 --hex : output hex instead of binary |
|
140 --debug : set the debug level. 0=off,1=parsing information,2=parsing & encoding information,3=everything |
|
141 |
|
142 other |
|
143 **** |
|
144 If it doesn't work then then try setting the DEBUG global variable to 1 (or 2 |
|
145 or 3 for more increased verbosity) |