barrysteyn / node-scrypt

Scrypt for Node
370 stars 88 forks source link

"data is not a valid scrypt-encrypted block" error is not triggered on xenial #164

Open tamirms opened 6 years ago

tamirms commented 6 years ago

These 2 tests fail on xenial:

  1) Scrypt Node Module Tests Scrypt Hash Function Verify Hash Synchronous functionality with incorrect arguments Will throw an Error if KDF buffer is not a valid scrypt-encrypted block:
     AssertionError: expected [Error] to match /^Error: data is not a valid scrypt-encrypted block$/
      at context.<anonymous> (tests/scrypt-tests.js:493:17)

  2) Scrypt Node Module Tests Scrypt Hash Function Verify Hash Asynchronous functionality with incorrect arguments Will throw an Error if KDF buffer is not a valid scrypt-encrypted block:
     AssertionError: expected [Error] to match /^Error: data is not a valid scrypt-encrypted block$/
      at context.<anonymous> (tests/scrypt-tests.js:558:17)

To reproduce you can build and run this docker image:

FROM ubuntu:16.04

# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN apt-get update \
    && apt-get install -y curl python build-essential git \
    && apt-get -y autoclean

# nvm environment variables
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.9.3

# install nvm
# https://github.com/creationix/nvm#install-script
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

# install node and npm
RUN source $NVM_DIR/nvm.sh \
    && nvm install $NODE_VERSION \
    && nvm alias default $NODE_VERSION \
    && nvm use default

# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

RUN npm install -g node-gyp

RUN git clone https://github.com/barrysteyn/node-scrypt.git
WORKDIR /node-scrypt

RUN npm install
RUN node-gyp configure build

CMD npm test

If you change the base image to ubuntu:14.04 you will find that the tests pass

tamirms commented 6 years ago

If you build the package in trusty and then run in xenial the tests seem to pass. Here's the Dockerfile I used to test that flow:

FROM ubuntu:14.04 AS builder

# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN apt-get update \
    && apt-get install -y curl python build-essential git \
    && apt-get -y autoclean

# nvm environment variables
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.9.3

# install nvm
# https://github.com/creationix/nvm#install-script
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

# install node and npm
RUN source $NVM_DIR/nvm.sh \
    && nvm install $NODE_VERSION \
    && nvm alias default $NODE_VERSION \
    && nvm use default

# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

RUN npm install -g node-gyp

RUN git clone https://github.com/barrysteyn/node-scrypt.git
WORKDIR /node-scrypt

RUN npm install
RUN node-gyp configure build

FROM ubuntu:16.04

# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN apt-get update \
    && apt-get install -y curl python build-essential \
    && apt-get -y autoclean

# nvm environment variables
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.9.3

# install nvm
# https://github.com/creationix/nvm#install-script
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

# install node and npm
RUN source $NVM_DIR/nvm.sh \
    && nvm install $NODE_VERSION \
    && nvm alias default $NODE_VERSION \
    && nvm use default

# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

WORKDIR /node-scrypt

COPY --from=builder /node-scrypt .

CMD npm test
tamirms commented 6 years ago

I was browsing the other issues and I found that this bug is also reported in https://github.com/barrysteyn/node-scrypt/issues/131

I was able to verify that https://github.com/barrysteyn/node-scrypt/pull/133 fixed the issue

@barrysteyn are you still actively maintaining this project? https://github.com/barrysteyn/node-scrypt/pull/133 has been open for over a year?

barrysteyn commented 6 years ago

Hi, I am still maintaining it, however I have not been maintaining it for sometime. Is there still an audience for this?

tamirms commented 6 years ago

@barrysteyn trello's backend runs on nodejs uses node-scrypt. We're in the process of upgrading all our services to run on xenial instead of trusty. This issue is blocking us from doing that

fanatid commented 6 years ago

Sorry for off-topic here, @tamirms can you check https://github.com/cryptocoinjs/scrypt ? :)

tamirms commented 6 years ago

@barrysteyn just a friendly reminder... could you take a look at #133 ? thanks!