Skip to content

Commit a4259bd

Browse files
committed
update README.md
1 parent 6e4f1cc commit a4259bd

File tree

3 files changed

+107
-24
lines changed

3 files changed

+107
-24
lines changed

README.md

Lines changed: 101 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,98 @@
44
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
55
[![Java](https://img.shields.io/badge/Java-17-orange.svg)](https://openjdk.org/projects/jdk/17/)
66

7-
**eNot** (**Encoding Notations**) is a general purpose templating engine that serializes structured data into binary formats such as **ASN.1** and **BER-TLV**.
7+
**eNot** (**Encoding Notations**) is a JSON-driven templating engine that serializes structured data into binary formats — primarily **ASN.1 DER**, with **BER-TLV** support showing the design is not limited to a single format.
88

9-
A template describes the binary structure declaratively in JSON. At serialization time, placeholders are resolved from a parameter map, control structures (loops, conditions) are evaluated, and the result is encoded into the target binary format.
9+
---
10+
11+
## The problem it solves
12+
13+
If you have ever written PKI tooling, you know the drill: encoding a Subject Distinguished Name, a Subject Alternative Name extension, or an X.509 Validity block means either reaching for a heavy framework that makes all the structural decisions for you, or writing low-level ASN.1 code that is brittle, hard to review, and even harder to reuse.
14+
15+
eNot takes a different approach. The binary structure is described as a plain JSON template:
16+
17+
```json
18+
{
19+
"type": "asn.1",
20+
"attributes": { "tag": "utf8_string" },
21+
"body": "${common_name}"
22+
}
23+
```
24+
25+
At serialization time you supply the values:
26+
27+
```java
28+
Enot enot = new Enot(registry, objectMapper);
29+
List<byte[]> der = enot.serialize(templateJson,
30+
new SerializationContext.Builder(objectMapper)
31+
.withParam("common_name", "Alice")
32+
.build());
33+
```
34+
35+
That's it. The engine resolves `${common_name}`, encodes the UTF-8 string as DER, and returns the bytes. No hard-coded structures, no framework lock-in.
36+
37+
---
38+
39+
## Going further — loops, conditions, and composition
40+
41+
Real certificate structures are not flat. eNot handles this with built-in control-flow elements.
42+
43+
**Loops** iterate over an array of parameters and produce one encoded element per entry — useful for multi-valued SANs or Organizational Unit lists:
44+
45+
```json
46+
{
47+
"type": "system",
48+
"attributes": { "kind": "loop", "items_name": "dns_name" },
49+
"body": {
50+
"type": "asn.1",
51+
"attributes": { "tag": "tagged_object", "implicit": 2 },
52+
"body": {
53+
"type": "asn.1",
54+
"attributes": { "tag": "ia5_string" },
55+
"body": "${value}"
56+
}
57+
}
58+
}
59+
```
60+
61+
**Conditions** encode a body only when an expression evaluates to `true` — for example, choosing between `UTCTime` and `GeneralizedTime` based on whether a date falls before or after 2050 (exactly as RFC 5280 requires):
62+
63+
```json
64+
{
65+
"type": "system",
66+
"attributes": {
67+
"kind": "condition",
68+
"expression": "${expires_on} < '2050-01-01T00:00:00Z'"
69+
},
70+
"body": {
71+
"type": "asn.1",
72+
"attributes": { "tag": "utc_time" },
73+
"body": "${expires_on}"
74+
}
75+
}
76+
```
77+
78+
**References** let one template include another by identifier at parse time, so large structures (like a full SAN extension) are assembled from smaller, independently testable pieces rather than one monolithic file.
79+
80+
---
81+
82+
## Why templates in JSON?
83+
84+
The format was a deliberate choice:
85+
- Templates are **plain text** — version-controlled, diff-able, reviewable in a pull request
86+
- The structure mirrors the binary output — a `sequence` wrapping a `set` wrapping a `utf8_string` is exactly how it looks in the JSON tree
87+
- The engine is **format-agnostic** — the same parser and serializer infrastructure drives both the `asn.1` and `ber-tlv` type systems; new formats plug in via `EnotRegistry`
88+
- Placeholder resolution, condition evaluation, and loop iteration are all **handled by the engine**, not scattered across application code
1089

1190
---
1291

13-
## Why eNot?
92+
## Status
1493

15-
Most PKI and smart-card tooling either hard-codes binary structures or requires developers to work directly with low-level ASN.1 / BER-TLV APIs. eNot sits in between: templates are human-readable JSON files that can be version-controlled, reviewed, and reused, while the engine handles all binary encoding details.
94+
> **eNot is not yet published to Maven Central.** Build locally first:
95+
> ```
96+
> mvn install
97+
> ```
98+
> Then reference the snapshot version (see [Quick Start](docs/quick-start.md)).
1699
17100
---
18101
@@ -21,36 +104,33 @@ Most PKI and smart-card tooling either hard-codes binary structures or requires
21104
| Module | Description |
22105
|--------|-------------|
23106
| `core` | Parser, serializer, expression engine, type registry |
24-
| `ber-tlv` | BER-TLV extension (PoC — shows eNot is not ASN.1-only) |
25-
| `web-tool` | Browser-based template editor and serializer (planned) |
107+
| `ber-tlv` | BER-TLV type extension — proof that the engine is not tied to ASN.1 |
26108
27109
---
28110
29-
## Quick start
111+
## Building
30112
31-
**[Quick Start Guide](docs/quick-start.md)**
113+
Requirements: **Java 17+**, **Maven 3.8+**
114+
115+
```
116+
mvn install # build and run all tests
117+
mvn -pl core test # run only core module tests
118+
```
32119
33120
---
34121
35122
## Documentation
36123
37-
| Document | Description |
38-
|-------------------------------------------------|-------------|
39-
| [Quick Start](docs/quick-start.md) | Add the dependency, parse a template, serialize with parameters |
40-
| [Format overview](docs/format/README.md) | Element structure, values, placeholders |
41-
| [ASN.1 elements](docs/format/asn1.md) | All ASN.1 tags and accepted body types |
42-
| [System elements](docs/format/system.md) | loop, condition, bit_map, sha1, hex_to_bin, bin_to_hex, … |
124+
| Document | Description |
125+
|----------|-------------|
126+
| [Quick Start](docs/quick-start.md) | Dependency, first template, serialization |
127+
| [Format overview](docs/format/README.md) | Element structure, values, placeholders, scoping |
128+
| [ASN.1 elements](docs/format/asn1.md) | All tags and accepted body types |
129+
| [System elements](docs/format/system.md) | loop, condition, group, reference, bit_map, sha1, … |
43130
| [Expression syntax](docs/format/expressions.md) | Operators, functions, type rules |
44131
45132
---
46133
47-
## Requirements
48-
49-
- Java 17+
50-
- Maven 3.8+
51-
52-
---
53-
54134
## License
55135
56136
Apache License 2.0 — see [LICENSE](LICENSE).
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.github.flexca.enot.core.types.system.serializer;
2+
3+
public class SystemBitMapSerializer {
4+
}

core/src/main/java/com/github/flexca/enot/core/types/system/serializer/SystemLoopSerializer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
import com.github.flexca.enot.core.EnotContext;
44
import com.github.flexca.enot.core.element.EnotElement;
55
import com.github.flexca.enot.core.exception.EnotSerializationException;
6-
import com.github.flexca.enot.core.expression.ConditionExpressionEvaluator;
76
import com.github.flexca.enot.core.parser.EnotJsonError;
87
import com.github.flexca.enot.core.parser.EnotParser;
9-
import com.github.flexca.enot.core.registry.EnotRegistry;
108
import com.github.flexca.enot.core.serializer.BaseElementSerializer;
119
import com.github.flexca.enot.core.serializer.ElementSerializationResult;
1210
import com.github.flexca.enot.core.serializer.EnotSerializer;
1311
import com.github.flexca.enot.core.serializer.context.SerializationContext;
1412
import com.github.flexca.enot.core.types.system.attribute.SystemAttribute;
1513

16-
import java.util.*;
14+
import java.util.ArrayList;
15+
import java.util.List;
1716

1817
public class SystemLoopSerializer extends BaseElementSerializer {
1918

0 commit comments

Comments
 (0)