themis icon indicating copy to clipboard operation
themis copied to clipboard

react-native-themis - Sealed encryption crashes for empty string

Open tom-at-pixel opened this issue 2 years ago • 1 comments

Describe the bug When secureCellSealWithSymmetricKeyEncrypt64() is called on an empty string, a native exception is thrown. If this is by design, it should be documented. Themis should consider handling this condition internally, since empty fields are a common occurrence for field-level encryption scenarios (e.g. imagine a user creating a to-do with an empty description field, and all user content-generated fields are encrypted).

To Reproduce Steps to reproduce the behavior:

  1. In a React Native project with react-native-themis installed, run the following code:
const key = "ANY_BYTE_ARRAY";
const emptyText = "";

// This code will throw a native exception
await secureCellSealWithSymmetricKeyEncrypt64(key, emptyText);
  1. Observe the exception:

image

Expected behavior The encryption should no-op in Themis for empty strings.

Environment (please complete the following information):

  • OS: iOS 15.2
  • Hardware: iOS Simulator
  • Themis version: react-native-themis 0.14.4
  • Installation way:
    • [x] via package manager
    • [ ] built from source

tom-at-pixel avatar Jul 21 '22 17:07 tom-at-pixel

Thank you, @tom-at-pixel! We'll take a look.

vixentael avatar Jul 22 '22 08:07 vixentael

i guess it's fixed in the latest release 0.14.7 https://github.com/cossacklabs/themis/releases/tag/0.14.7

@tom-at-pixel please take a look

vixentael avatar Aug 19 '22 14:08 vixentael

Thanks @vixentael, that's great!

tom-at-pixel avatar Aug 25 '22 17:08 tom-at-pixel