Skip to content

Conversation

@JanKuczma
Copy link
Collaborator

No description provided.

@JanKuczma JanKuczma requested a review from Copilot August 4, 2025 16:27
Copy link

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

This PR adds validation to prevent buffer underflow errors by checking ciphertext length before attempting to decrypt data. The change ensures that ciphertext has at least 45 bytes before attempting to extract the ephemeral public key (33 bytes) and initialization vector (12 bytes).

Key Changes

  • Added length validation in both TypeScript and Rust decrypt functions
  • Consistent error messaging across both implementations for invalid ciphertext length

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ts/lib/src/index.ts Added ciphertext length validation with error throwing in TypeScript decrypt function
rust/lib/src/lib.rs Added ciphertext length validation with Result error return in Rust decrypt function
Comments suppressed due to low confidence (1)

ts/lib/src/index.ts:199

  • [nitpick] The error message format is inconsistent with the Rust implementation. Consider using a period after 'bytes' to match the Rust error message format: 'Invalid ciphertext length X bytes. Expected at least 45 bytes.'
      `Invalid ciphertext length ${ciphertextBytes.length} bytes, expected at least 45 bytes`

@JanKuczma JanKuczma merged commit 36aa4b5 into main Aug 5, 2025
1 check passed
@JanKuczma JanKuczma deleted the ciphertext-len branch August 5, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants