Comments (2)
Hi!
I think I understand how this could be confusing.
There's a couple parts to this which I will attempt to illustrate. I've also created a new test which validates the behavior is as I describe below.
base64 encoders work by taking ever 6 bits of an input and mapping those to an ASCII character. If the number of bits in the input is not evenly divisible by 6, then the encoder must pad the resulting output with some number of unused bits.
Example:
$echo 'a' | base64
YQ=
ASCII a
is 0x61
, or 01100001
and requires 8 bits to represent, so we have to use two 6 bit base64 digits to represent it.
ASCII: | a |
binary: |011000|010000|
base 10: | 24 | 16 |
base 64: | Y | Q |
The encoder will normally then pad the number of base64 digits out to a multiple of 4 with =
s, but ectoken strips those.
That those last 4 bits (in this example) are discarded means that I can do this echo 'YZ==' | base64 -d
and still get a
.
ASCII: | a |
binary: |011000|011001|
base 10: | 24 | 25 |
base 64: | Y | Z |
If you try changing the first character in the token it should fail completely.
I'm going to post my new tests soon, they run very slowly because they basically brute force changing base64 encoded bytes in the token and validate that the decryption fails properly unless the changed bits are in the discarded padding. I'll leave this open until that's merged.
from ectoken.
Thanks, @AbhishekTripathi . We'll investigate this issue and provide an update shortly.
from ectoken.
Related Issues (12)
- Binaries not found HOT 3
- allowedUrls parameter of C# EncryptV3 parameter doesn't get passed to overloaded method
- NodeJS support HOT 5
- Elixir Support
- Go Support HOT 2
- PHP implementation requires a PHP extension HOT 1
- Rust Support HOT 2
- License Inconsistencies... HOT 2
- Does not work with .net core. HOT 7
- Slightly off results in .net core HOT 1
- Nuget package for the lib HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ectoken.