| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import base64 | 6 import base64 |
| 7 import copy | 7 import copy |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import tempfile | 10 import tempfile |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 s += attr_modifier + ',' | 37 s += attr_modifier + ',' |
| 38 s += '%s:"%s"\n' % (attr_value_type, attr_value) | 38 s += '%s:"%s"\n' % (attr_value_type, attr_value) |
| 39 | 39 |
| 40 return s | 40 return s |
| 41 | 41 |
| 42 | 42 |
| 43 class NameGenerator: | 43 class NameGenerator: |
| 44 def __init__(self): | 44 def __init__(self): |
| 45 self.rdns = [] | 45 self.rdns = [] |
| 46 | 46 |
| 47 def token(self): |
| 48 return "NAME" |
| 49 |
| 47 def add_rdn(self): | 50 def add_rdn(self): |
| 48 rdn = RDN() | 51 rdn = RDN() |
| 49 self.rdns.append(rdn) | 52 self.rdns.append(rdn) |
| 50 return rdn | 53 return rdn |
| 51 | 54 |
| 52 def __str__(self): | 55 def __str__(self): |
| 53 s = 'asn1 = SEQUENCE:rdnSequence\n\n[rdnSequence]\n' | 56 s = 'asn1 = SEQUENCE:rdnSequence%i\n\n[rdnSequence%i]\n' % ( |
| 57 id(self), id(self)) |
| 54 for n, rdn in enumerate(self.rdns): | 58 for n, rdn in enumerate(self.rdns): |
| 55 s += 'rdn%i = SET:rdnSet%i\n' % (n, n) | 59 s += 'rdn%i = SET:rdnSet%i_%i\n' % (n, id(self), n) |
| 56 | 60 |
| 57 s += '\n' | 61 s += '\n' |
| 58 | 62 |
| 59 for n, rdn in enumerate(self.rdns): | 63 for n, rdn in enumerate(self.rdns): |
| 60 s += '[rdnSet%i]\n%s\n' % (n, rdn) | 64 s += '[rdnSet%i_%i]\n%s\n' % (id(self), n, rdn) |
| 61 | 65 |
| 62 return s | 66 return s |
| 63 | 67 |
| 64 | 68 |
| 65 def generate(s, fn): | 69 def generate(s, fn): |
| 66 out_fn = os.path.join('..', 'names', fn + '.pem') | 70 out_fn = os.path.join('..', 'names', fn + '.pem') |
| 67 conf_tempfile = tempfile.NamedTemporaryFile() | 71 conf_tempfile = tempfile.NamedTemporaryFile() |
| 68 conf_tempfile.write(str(s)) | 72 conf_tempfile.write(str(s)) |
| 69 conf_tempfile.flush() | 73 conf_tempfile.flush() |
| 70 der_tmpfile = tempfile.NamedTemporaryFile() | 74 der_tmpfile = tempfile.NamedTemporaryFile() |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 rdn0 = SET:rdnSet0 | 325 rdn0 = SET:rdnSet0 |
| 322 [rdnSet0] | 326 [rdnSet0] |
| 323 attrTypeAndValue0=SEQUENCE:attrTypeAndValueSequence0_0 | 327 attrTypeAndValue0=SEQUENCE:attrTypeAndValueSequence0_0 |
| 324 [attrTypeAndValueSequence0_0] | 328 [attrTypeAndValueSequence0_0] |
| 325 type=OID:countryName | 329 type=OID:countryName |
| 326 value=PRINTABLESTRING:"US" | 330 value=PRINTABLESTRING:"US" |
| 327 """, "valid-minimal") | 331 """, "valid-minimal") |
| 328 | 332 |
| 329 if __name__ == '__main__': | 333 if __name__ == '__main__': |
| 330 main() | 334 main() |
| OLD | NEW |