Commit Graph

29424 Commits

Author SHA1 Message Date
Nicolas Williams 6b5feba91d asn1: Fix printing of bit string named members
Properly print commas between members.
2021-03-09 12:20:23 -06:00
Nicolas Williams 8bc4bae52d asn1: Free template memory leak
New AFL session in progress.
2021-03-09 11:21:54 -06:00
Nicolas Williams 2a826fb331 asn1: Results from latest AFL session 2021-03-09 11:21:47 -06:00
Nicolas Williams a62dd9887f hx509: Fix bug found by clang (wrong enum)
We need to revisit a lot of code in lib/hx509/, lib/krb5/, and kdc/ now
that the ASN.1 compiler properly handles IMPLICIT tagging.  And we
should take advantage of automatic open type handling.
2021-03-08 17:53:50 -06:00
Nicolas Williams 77126b4058 asn1: Update README-X681.md 2021-03-08 16:16:00 -06:00
Nicolas Williams fbb1a4e3ec bx509d: Allow requesting longer cert lifetimes
Add a `lifetime=NUMunit` query parameter.

Also add a krb5.conf parameter to indicate whether this is allowed.
We already have a max lifetime configuration parameter.
2021-03-07 22:20:06 -06:00
Nicolas Williams 00e0475ce2 asn1: Use name not gen_name for JSON enum printing 2021-03-07 16:32:41 -06:00
Nicolas Williams 5d7d1897de asn1: Pretty-print enum values 2021-03-07 13:36:37 -06:00
Nicolas Williams be61d72be3 asn1: Some TPM fields have to be EXPLICIT
The TCG EK cert profile says that the context tags in the
TPMSecurityAssertions type are IMPLICIT.  The sample EK cert we have
has them as EXPLICIT.

What to do?
2021-03-07 00:31:47 -06:00
Nicolas Williams f7a018f002 asn1: Minor compiler performance improvment 2021-03-06 15:20:42 -06:00
Nicolas Williams 3f206d56fb asn1: Add missing cases for ENUMERATED 2021-03-06 15:13:53 -06:00
Nicolas Williams 4010ffa96e asn1: Fix Windows build harder 2021-03-06 14:57:00 -06:00
Nicolas Williams bc51427ec9 asn1: Update JSON in check-gen.c (fix test) 2021-03-06 14:47:49 -06:00
Nicolas Williams a450ef1884 asn1: Note lame JSON printing of ENUMERATEDs 2021-03-06 14:47:24 -06:00
Nicolas Williams 7559f36415 asn1: Add -q option to asn1_print 2021-03-06 14:46:52 -06:00
Nicolas Williams ff571d52a0 asn1: Fix JSON printing bug 2021-03-06 14:46:21 -06:00
Nicolas Williams d263299016 asn1: Fix OID symbolic resolution bug 2021-03-06 14:46:08 -06:00
Nicolas Williams 834b935cc3 asn1: Add miminized corpus for AFL 2021-03-06 12:47:25 -06:00
Nicolas Williams 979dd59ac9 asn1: Fix Windows build (missing symbols) 2021-03-06 01:02:13 -06:00
Nicolas Williams 94a7483243 asn1: Fix dumb bug in JSON printing 2021-03-06 01:01:51 -06:00
Nicolas Williams 88a4c6f444 asn1: Fix leak in asn1_print 2021-03-05 15:53:20 -06:00
Nicolas Williams 4c261911fa asn1: Fix alignment issue in templating open types
And a stray ^a increment of a 0 into a 1.

Found with AFL.
2021-03-05 15:52:30 -06:00
Nicolas Williams 2035efe765 asn1: Fix braino in asn1_print 2021-03-05 14:06:17 -06:00
Nicolas Williams 7bc02e5d5f asn1: Make note about fuzzing in README 2021-03-05 13:24:21 -06:00
Nicolas Williams 6ecab8ce51 asn1: Make asn1_print a fuzzing tool 2021-03-05 13:19:38 -06:00
Nicolas Williams 4502e989f2 asn1: Fix template decode bug found with AFL
The value we initialize a CHOICE's `element` enum field to, prior to
decoding the CHOICE value, needs be one that does not cause
`asn1_free()` to do anything since we've not done anything yet either.
2021-03-05 13:00:03 -06:00
Nicolas Williams f548e5d9c6 asn1: Complete c6fab6c87 (AFL) 2021-03-04 16:15:20 -06:00
Nicolas Williams 114cbc9723 asn1: Document fuzzing in README-template.md 2021-03-04 00:15:54 -06:00
Nicolas Williams c6fab6c871 asn1: Fix open decode bug found by AFL
Should always run AFL before pushing changes to the ASN.1 compiler or
template interpreter!

Still fuzzing.  There are crashers in the _asn1_print() path, though
right now they cannot affect anything else in Heimdal other than
asn1_print, since that's the only thing calling it yet.
2021-03-03 23:29:25 -06:00
Nicolas Williams 1d2bfd6179 asn1: Fix warnings in asn1_print 2021-03-03 23:28:49 -06:00
Nicolas Williams 4eff66a2cd asn1: Trade template crash for leak (AFL)
Yesterday's fix for an unlikely leak in the template interpreter
introduced a crash found by American Fuzzy Lop (AFL).
2021-03-03 10:19:31 -06:00
Nicolas Williams a0f542486e asn1: Fix open type decode crash (AFL)
Found with American Fuzzy Lop (AFL).
2021-03-03 10:19:31 -06:00
Nicolas Williams fb5ae095e9 asn1: Fix warnings 2021-03-03 10:15:18 -06:00
Nicolas Williams a68ccb6693 asn1: Add --raw-sequence option to asn1_print 2021-03-02 21:39:00 -06:00
Nicolas Williams f5d9ced33c asn1: Fix broken printing 2021-03-02 21:12:02 -06:00
Nicolas Williams 32974ac421 asn1: Fix leak in asn1_print 2021-03-02 20:56:16 -06:00
Nicolas Williams f780bdc244 asn1: Fix leaks in template printing 2021-03-02 20:55:55 -06:00
Nicolas Williams 8def829f30 asn1: Fix leaks in template decoding 2021-03-02 20:55:41 -06:00
Nicolas Williams 52b48de856 asn1: Further enhancements to asn1_print 2021-03-02 13:58:56 -06:00
Nicolas Williams 779848bf42 asn1: Fix JSON print bug for IMPORTed types 2021-03-02 13:37:40 -06:00
Nicolas Williams f58b145109 asn1: Make CSRs nicely printable (fixup) 2021-03-01 17:34:38 -06:00
Nicolas Williams e8fa948740 asn1: Minor JSON fix 2021-03-01 17:34:04 -06:00
Nicolas Williams e491521782 asn1: Fix Windows build 2021-03-01 16:29:23 -06:00
Nicolas Williams 7ada3d5d48 asn1: Make CSRs nicely printable
For now we just add new types that can auto-decode through open types
in CSRs, but we leave the originals as they were to avoid having to
update lib/hx509/req.c for now.
2021-03-01 15:27:45 -06:00
Nicolas Williams a712d4157a asn1: Remove incorrect comment 2021-03-01 15:27:20 -06:00
Nicolas Williams 2f925d8b09 asn1: Don't crash compiler on unknown actual param 2021-03-01 15:26:41 -06:00
Nicolas Williams bb3499aa53 hxtool: Add print --raw-json option
Add a `--raw-json` to `hxtool print` that uses the new ASN.1 value
printer functionality from libasn1.
2021-02-28 18:15:57 -06:00
Nicolas Williams 7f941b220b asn1: Basic validation of objects / object sets
- Validate that required value fields have values specified in objects

 - Validate that unique value fields have unique values within any
   object set
2021-02-28 18:15:57 -06:00
Nicolas Williams d128597cf7 asn1: Add News section to README.md 2021-02-28 18:15:56 -06:00
Nicolas Williams ece3c688e0 asn1: Enrich asn1_print with schema
Our asn1_print, like OpenSSL's, just knows how to parse and dump DER.
Ours can attempt to decode OCTET STRING and IMPLICIT-tagged constructed
values as DER, which is very useful.

But _now_ it's even better.  Now it knows about all types exported from
all ASN.1 modules in `lib/asn1/` in Heimdal, and if told to print as
some type, it will use the new printing interface to print JSON-like
representations of values:

```
$ ./asn1_print /tmp/t490/ek2.crt Certificate |
  jq '.tbsCertificate.extensions[3]._extnValue[]._values'
[
  {
    "_type": "TPMSpecification",
    "family": "2.0",
    "level": "0",
    "revision": "138"
  }
]
[
  {
    "_type": "TPMSecurityAssertions",
    "version": "0",
    "fieldUpgradable": true,
    "ekGenerationType": "655617",
    "ekGenerationLocation": "655616",
    "ekCertificateGenerationLocation": "655616",
    "ccInfo": {
      "_type": "CommonCriteriaMeasures",
      "version": "3.1",
      "assurancelevel": "4",
      "evaluationStatus": "2",
      "plus": true,
      "strengthOfFunction": null,
      "profileOid": null,
      "profileUri": null,
      "targetOid": null,
      "targetUri": null
    },
    "fipsLevel": {
      "_type": "FIPSLevel",
      "version": "140-2",
      "level": "2",
      "plus": false
    },
    "iso9000Certified": false,
    "iso9000Uri": null
  }
]
```
2021-02-28 18:15:25 -06:00