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

Padding issue on input strings that are a len multiple of 32 #8

Closed
fairbairn opened this issue Jun 26, 2018 · 2 comments
Closed

Padding issue on input strings that are a len multiple of 32 #8

fairbairn opened this issue Jun 26, 2018 · 2 comments
Labels

Comments

@fairbairn
Copy link

Here’s the issue..

iex(1)> secret = "fJXYWeIEcXMO3tLDheFVezM5QWBVFvkymG80n0Rluqs="
"fJXYWeIEcXMO3tLDheFVezM5QWBVFvkymG80n0Rluqs="
iex(2)> s = "abc"
"abc"
iex(3)> {:ok, _iv, t} = Fernet.generate(s, key: secret)
{:ok,
 <<171, 20, 174, 159, 83, 157, 204, 91, 237, 149, 121, 205, 255, 101, 152, 241>>,
 "gAAAAABbMo1mqxSun1OdzFvtlXnN_2WY8TlATVJvCKC6oPuO_kzHnLSC3YN6uj0b-a0DBzBQYfWmaxdUb28p3-RyFOLV8gBwPQ=="}
iex(4)> t
"gAAAAABbMo1mqxSun1OdzFvtlXnN_2WY8TlATVJvCKC6oPuO_kzHnLSC3YN6uj0b-a0DBzBQYfWmaxdUb28p3-RyFOLV8gBwPQ=="
iex(5)> Fernet.verify(t, key: secret)
{:ok, "abc"}
iex(6)> s = String.pad_trailing("hello", 32)
"hello                           "
iex(7)> {:ok, _iv, t} = Fernet.generate(s, key: secret)
{:ok,
 <<4, 195, 63, 250, 139, 163, 64, 222, 249, 190, 47, 118, 19, 79, 199, 13>>,
 "gAAAAABbMo2BBMM_-oujQN75vi92E0_HDf-TWTLLZYX6S3sqDyJh4QL9Qqi4oPP47mEcc5OBQ2qUmqJfJVmt1UBuRBK096V8Rp5M-f-sjS79HKJedlg9Ay4="}
iex(8)> Fernet.verify(t, key: secret)
{:error, "padding error"}
@kennyp
Copy link
Owner

kennyp commented Jun 27, 2018

@fairbairn I think I have this fixed with PR #9. It also gave me a chance to a property based test that we always can verify what we generate.

@kennyp kennyp added the bug label Jun 27, 2018
@kennyp
Copy link
Owner

kennyp commented Jun 27, 2018

@fairbairn v0.3.1 has been released. Let me know if you have any more issues.

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

No branches or pull requests

2 participants