Skip to content

fix: Use PKCS7 padding for cookie cryptor#62

Merged
Andrew-Lees11 merged 2 commits intomasterfrom
pkcs7Padding
Mar 11, 2019
Merged

fix: Use PKCS7 padding for cookie cryptor#62
Andrew-Lees11 merged 2 commits intomasterfrom
pkcs7Padding

Conversation

@Andrew-Lees11
Copy link
Copy Markdown
Contributor

This PR is In response to issue #61.
In cookie cryptor, we were ecrypting the session Id using aes with our own implementation of padding where we would add 0x00 until it was the correct block size. Then when decrypting we would only take the first 36 bytes. This will only give us our original plaintext back if the input was 36 bytes long (The size of a UUID).
This was working since we consistently used the shortened data however this is fragile and if an input of less than 16 bytes was used then it would crash on trying to decrypt.

This PR changes our encode and decode to use BlueCryptor PKCS7 padding so that we can encrypt and decrypt and length and the original plaintext will be returned.

@Andrew-Lees11
Copy link
Copy Markdown
Contributor Author

@Lukasa
I agree that we should be using PKCS7 padding. Just wanted to check that this PR is what you had in mind.

@Lukasa
Copy link
Copy Markdown

Lukasa commented Mar 11, 2019

Yup, that looks a lot better.

@Andrew-Lees11 Andrew-Lees11 merged commit 6e73282 into master Mar 11, 2019
@ianpartridge ianpartridge deleted the pkcs7Padding branch March 11, 2019 14:50
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.

3 participants