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