Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFB encryption/decryption segment size error may be incorrect #29

Open
rderwin opened this issue Feb 24, 2017 · 8 comments · May be fixed by #97
Open

CFB encryption/decryption segment size error may be incorrect #29

rderwin opened this issue Feb 24, 2017 · 8 comments · May be fixed by #97
Labels

Comments

@rderwin
Copy link

rderwin commented Feb 24, 2017

I am using this library to decrypt a CFB cipher 40 characters long, with a segment size of 16. It fails from this error:

if ((plaintext.length % this.segmentSize) != 0) {
throw new Error('invalid plaintext size (must be segmentSize bytes)');
}

However, when removing these line I am able to successfully decode the string.

Is this error incorrect? I was thinking segmentSize would be in bits and not bytes, so 40 bytes should be divisible into 16 bits without issue.

@ricmoo
Copy link
Owner

ricmoo commented Feb 24, 2017

The library (and my python implementation) have made the assumption it is measured in bytes, but looking at it, I believe you are right, it should absolutely be in bits.

I will update the test cases and adjust the code as needed to support bits. The test cases were specifically generated on byte alignments, but I see now the intention of CBF.

This will be a major version bump.

Thanks! I'll get to this soon.

@johnrickman
Copy link

What's the status of this?

@ricmoo
Copy link
Owner

ricmoo commented May 30, 2017

I haven't had time to get to this yet... It's been a crazy time with Ethereum.

If you create a pull request with the changes and add test cases though, I will verify and commit. Otherwise, it will probably still be a week or so before I can get to this.

@johnrickman
Copy link

I actually realized that this is no longer an issue of mine, as I can use the pkcs7 padding as my input has already been padded.

@ricmoo ricmoo added the bug label Sep 13, 2017
@jvallar
Copy link

jvallar commented Feb 14, 2018

Any news on this one?

@ricmoo
Copy link
Owner

ricmoo commented Feb 15, 2018

Sorry, haven't had a chance to get to this, and this weekend is big hackathon. I will add something to my calendar to look into this next week.

@mikkelvp
Copy link

A fix for this would be much appreciated.

@shanmukhateja shanmukhateja linked a pull request May 23, 2020 that will close this issue
@Saiv46
Copy link

Saiv46 commented Jun 27, 2020

Any progress? I can't use CFB properly - it just returns me a clear random instead of encrypted/decrypted buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants