Skip to content

@aws-crypto/client-browser Buffer usage in raw2der causing ReferenceError when decrypting #1050

Open

Description

@hunterabraham

Problem:

When using @aws-crypto/client-browser version 3.1.1, calling decrypt() will result in a ReferenceError. decrypt calls raw2der, which includes a reference to global Buffer type. The buffer npm package is not listed as a dependency in the package.json.

Solution:

Either decouple the browser and node ecdsa_signature.ts helpers and use a Uint8Array instance instead of Buffer or add the buffer dependency to the package.

Activity

  1. changed the title [-]@aws-crypto/client-browser Buffer usage in raw2der [/-] on Nov 7, 2022
  2. lavaleri commented on Nov 10, 2022

    @lavaleri
    Contributor

    Hi @hunterabraham,

    We have some examples of doing this in https://github.com/aws/aws-encryption-sdk-javascript/tree/master/modules/example-browser. Can you tell us how you are packaging your code for the browser so that we can repro and fix this?

  3. hunterabraham commented on Nov 17, 2022

    @hunterabraham
    Author

    Thanks for getting back to me, @lavaleri. We are using yarn for package management in our React app. This error occurs when I'm building locally using yarn run start. I have the following version in my package.json "@aws-crypto/client-browser": "^3.1.1". Our implementation is very simple encryption mirroring the kms_simple.ts example in the example repo.

  4. texastony commented on Nov 21, 2022

    @texastony
    Contributor

    @hunterabraham

    The AWS Encryption SDK for Java Script (ESDK-JS) is not built for nor tested in a React Native environment.
    The issue you are bumping into maybe fixed by your proposed solution,
    but I fear that it is the tip of the iceberg.

    A challenge with React Native is supplying the Cryptographic Primitives.
    Are you using msrCrypto for the primitives or another library?

    Can you share a repository that uses the ESDK-JS in a React Native application?
    (Ideally, something bare bones, and with this issue).
    If you could share something for us to work from, we could move this issue forward faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions