Skip to content

Padding bytes may not be zero.#19

Open
uunicorn wants to merge 1 commit into
schlatterbeck:masterfrom
uunicorn:fix-non-zero-pad
Open

Padding bytes may not be zero.#19
uunicorn wants to merge 1 commit into
schlatterbeck:masterfrom
uunicorn:fix-non-zero-pad

Conversation

@uunicorn

Copy link
Copy Markdown

Fixes #18

See pkcs1pad2 in JS_RSA.js:
...
while(n > 2) { // random non-zero pad
x[0] = 0;
while(x[0] == 0) rng.nextBytes(x);
ba[--n] = x[0];
}
...

Fixes schlatterbeck#18

See pkcs1pad2 in JS_RSA.js:
...
  while(n > 2) { // random non-zero pad
    x[0] = 0;
    while(x[0] == 0) rng.nextBytes(x);
    ba[--n] = x[0];
  }
...
@kukenc

kukenc commented Mar 24, 2020

Copy link
Copy Markdown

It works for me. GJ

@lalmeras

lalmeras commented Nov 6, 2023

Copy link
Copy Markdown

This fix allows to get rid of Unexpected response, looking for MultiChallenge or Portal messages. As I understand it, theses messages are triggered when os.urandom emits b'\0' values. As this char is a separator, it must not be present in random value.

Surely because I currently run the script with python2.7 (not sure), I need to use:

r.append (bytes(bytearray([int(x.encode('hex'), 16) % 255 + 1 for x in os.urandom (n)])))

instead of proposal:

r.append (bytes([x % 255 + 1 for x in os.urandom (n)]))

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.

Authentication intermittently fails due to incorrect padding.

3 participants