Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typed struct #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions draft-kohbrok-mls-implementation-considerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,37 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
document are to be interpreted as described in BCP 14 {{RFC2119}} {{!RFC8174}}
when, and only when, they appear in all capitals, as shown here.

# Typed structs
In many places, MLS uses a typed pattern of structs, where we have a type `uint`,
followed by a `select` statement that decides the type of the following field based on the preceding type `uint`.
For example the Credential struct:

```
struct {
CredentialType credential_type;
select (Credential.credential_type) {
case basic:
BasicCredential;

case x509:
Certificate chain<1..2^32-1>;
};
} Credential;
```

Other examples are `Content`/`ContentType`, `PSKType` in `PreSharedKey`, `Sender`/`SenderType` and `Proposal`/`ProposalType`.

We can generalise this into a typed struct as follows:

```
struct {
T type;
select(typed<T>.type) {
T.variant1:
Variant1
}
} typed<T>
```

# Security Considerations

Expand Down