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

InvalidKeyException when setting encrypt-data = true #9

Closed
mlangc opened this issue Apr 4, 2016 · 3 comments
Closed

InvalidKeyException when setting encrypt-data = true #9

mlangc opened this issue Apr 4, 2016 · 3 comments

Comments

@mlangc
Copy link

mlangc commented Apr 4, 2016

I get

java.security.InvalidKeyException: Invalid AES key length: 18 bytes
    at com.sun.crypto.provider.AESCipher.engineGetKeySize(AESCipher.java:495)
    at javax.crypto.Cipher.passCryptoPermCheck(Cipher.java:1067)
    at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1025)
    at javax.crypto.Cipher.implInit(Cipher.java:801)
    at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
    at javax.crypto.Cipher.init(Cipher.java:1249)
    at javax.crypto.Cipher.init(Cipher.java:1186)
    at com.softwaremill.session.Crypto$.encrypt_AES(Crypto.scala:29)
    at com.softwaremill.session.BasicSessionEncoder.encode(SessionEncoder.scala:34)
    at com.softwaremill.session.ClientSessionManager$class.encode(SessionManager.scala:60)
    at com.softwaremill.session.SessionManager$$anon$1.encode(SessionManager.scala:14)
    at com.softwaremill.session.ClientSessionManager$class.createCookie(SessionManager.scala:40)
    at com.softwaremill.session.SessionManager$$anon$1.createCookie(SessionManager.scala:14)
    at com.softwaremill.session.OneOffSessionDirectives$class.setOneOffSession(SessionDirectives.scala:104)
    at com.softwaremill.session.SessionDirectives$.setOneOffSession(SessionDirectives.scala:85)
    at com.softwaremill.session.SessionDirectives$class.setSession(SessionDirectives.scala:20)
    at com.softwaremill.session.SessionDirectives$.setSession(SessionDirectives.scala:85)

when setting encrypt-data = true. Without encryption, the library works fine. I'm using

"com.softwaremill.akka-http-session" %% "core" % "0.2.4"

with Scala-2.11.8.

@adamw
Copy link
Member

adamw commented Apr 4, 2016

Can you try 0.2.5-SNAPSHOT? The secret was incorrectly shortened to 16 bytes, things broke when a character was multiple-byte (as I suppose is the case with your secret)

@mlangc
Copy link
Author

mlangc commented Apr 4, 2016

Upgrading to 0.2.5-SNAPSHOT does indeed solve my problem, thanks!

@adamw
Copy link
Member

adamw commented Apr 4, 2016

Great, 0.2.5 should be in central soon

@adamw adamw closed this as completed Apr 4, 2016
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

No branches or pull requests

2 participants