Skip to content

feat(wasm-demo): Add a section to inspect devolutions-crypto data#384

Merged
Sébastien Duquette (sduquette-devolutions) merged 2 commits into
masterfrom
wasm-inspect
May 20, 2026
Merged

feat(wasm-demo): Add a section to inspect devolutions-crypto data#384
Sébastien Duquette (sduquette-devolutions) merged 2 commits into
masterfrom
wasm-inspect

Conversation

@sduquette-devolutions
Copy link
Copy Markdown
Contributor

The Inspect sections decodes a devolutions-crypto string and displays the header values and data of this object.

The Inspect sections decodes a devolutions-crypto string and displays the header values and data of this object.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an “Inspect (Debug)” page to the WASM demo so a devolutions-crypto base64 string can be decoded and its header + payload structure displayed for debugging.

Changes:

  • Introduces a new standalone InspectComponent that base64-decodes input and parses/display header + payload fields.
  • Adds the /inspect route and a navigation link in the demo sidebar.
  • Adds dedicated HTML/CSS for the inspector UI (tables, badges, error styling).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wrappers/wasm/demo/src/app/inspect/inspect.component.ts Implements decode + header/payload parsing logic for the inspector view.
wrappers/wasm/demo/src/app/inspect/inspect.component.html Renders input form plus parsed header/payload tables and error states.
wrappers/wasm/demo/src/app/inspect/inspect.component.css Styles inspector tables, badges, hex display, and error presentation.
wrappers/wasm/demo/src/app/app.routes.ts Registers the new /inspect route.
wrappers/wasm/demo/src/app/app.component.html Adds a sidebar link to “Inspect (Debug)”.
Comments suppressed due to low confidence (3)

wrappers/wasm/demo/src/app/inspect/inspect.component.ts:258

  • For V2 asymmetric ciphertext, payload.length < 56 is too low: 56 bytes only covers pubkey+nonce and leaves zero bytes for the AEAD tag/ciphertext, which is not a valid XChaCha20-Poly1305 output. Require at least a 16-byte tag after the nonce (i.e., pubkey(32)+nonce(24)+tag(16) => 72 bytes).
    // V2 (or Latest/0 which resolves to V2): XChaCha20-Poly1305
    if (subtype === 2) {
      // Asymmetric: EphemeralPubKey(32) + Nonce(24) + Ciphertext+Tag(var)
      if (payload.length < 56) {
        fields.push({

wrappers/wasm/demo/src/app/inspect/inspect.component.ts:271

  • ctWithTag can be shorter than 16 bytes with the current validation, but the UI always reports the auth tag as 16 bytes. Either tighten the length validation to ensure ctWithTag.length >= 16, or set the displayed tag size based on tag.length (and surface an error for malformed payloads) so the inspector doesn’t misreport offsets/sizes.
      const ctWithTag = payload.slice(56);
      const ct = ctWithTag.length > 16 ? ctWithTag.slice(0, ctWithTag.length - 16) : new Uint8Array(0);
      const tag = ctWithTag.slice(Math.max(0, ctWithTag.length - 16));

wrappers/wasm/demo/src/app/inspect/inspect.component.ts:304

  • For V2 symmetric ciphertext, payload.length < 24 is too permissive: 24 bytes is only the nonce with no ciphertext/tag. Since XChaCha20-Poly1305 always includes a 16-byte tag, validate that there are at least 16 bytes after the nonce (min 40 bytes total) to avoid showing empty ciphertext/tag fields as if they were valid.
    } else {
      // Symmetric (subtype None=0 or Symmetric=1): Nonce(24) + Ciphertext+Tag(var)
      if (payload.length < 24) {
        fields.push({
          name: 'Error',

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wrappers/wasm/demo/src/app/inspect/inspect.component.ts Outdated
const service: EncryptionServiceInner = await this.encryptionService.innerModule;
const input: string = this.debugForm.value.input?.trim();
if (!input) {
return;
Comment thread wrappers/wasm/demo/src/app/inspect/inspect.component.ts
@mmorrissette-devolutions
Copy link
Copy Markdown
Contributor

Codex (@codex) review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f35e823610

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

): PayloadField[] {
const fields: PayloadField[] = [];

if (version === 1) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop decoding unknown ciphertext versions as V2

parseCiphertextPayload only special-cases version === 1 and then falls through to V2 parsing for every other value, so malformed or future-version ciphertexts are rendered as if they were valid V2 structures. The core library treats unsupported versions as UnknownVersion (rather than coercing them to V2), so this produces misleading inspect output instead of surfacing that the version is unsupported.

Useful? React with 👍 / 👎.

});
} else {
// Symmetric (subtype None=0 or Symmetric=1): Nonce(24) + Ciphertext+Tag(var)
if (payload.length < 24) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Tighten V2 payload length validation before field splitting

The V2 symmetric/asymmetric length guards are too permissive (< 24 and < 56), so payloads that are structurally invalid can still be split into nonce/ciphertext/tag fields and shown as if they were well-formed. In the core parser, these payloads must be longer than nonce-only data (and asymmetric wraps that same constraint after the 32-byte key), so the current checks can misclassify invalid blobs during inspection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@mmorrissette-devolutions mmorrissette-devolutions left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sduquette-devolutions Sébastien Duquette (sduquette-devolutions) merged commit e8f1cfe into master May 20, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants