Forum Discussion
Harold_Deadman_
Nimbostratus
Apr 13, 2007AES decryption returning empty string
I am working on encrypting some cookies but I must be doing something wrong because I get empty strings when I decrypt the cookie. I have made the following example to demonstrate what I am seeing. Does anyone see what I am doing wrong? This is on 9.4. Thanks.
when RULE_INIT {
set ::key [AES::key 256]
set stringtoencrypt "Testing encryption"
set encrypted [b64encode [AES::encrypt $::key $stringtoencrypt]]
log local0. "Encrypted and encoded $encrypted"
set decrypted [AES::decrypt $::key [b64decode $encrypted]]
log local0. "Decrypted and decoded $decrypted"
}
From the local logfile, note the decrypted value is empty:
Fri Apr 13 19:43:24 BST 2007 tmm tmm[1579] Rule : Decrypted and decoded
Fri Apr 13 19:43:24 BST 2007 tmm tmm[1579] Rule : Encrypted and encoded Ppoyd/a17LTVDQgmjJ39rXstNUNCLmJpDJvOlymi0allgb/MviS9JloTerv/ZrlefNnosSpI=
- Harold_Deadman_
Nimbostratus
The problem appears to be that the encrypted value doesn't survive the base 64 encoding/decoding process. If I do this: - Harold_Deadman_
Nimbostratus
There are a couple wiki entries and a blog entry on this site that appear to be doing what my simple test i-rule is doing on init. F5 tech support wasn't able to give me any information beyond verifying my syntax so I am asking this forum again if anyone can verify that they have successfully encrypted and base 64 encoded cookies in 9.4 (and then decoded and decrypted the original value). When I have tried to decrypt AES encryption in other languages I get errors related to "padding". Might that be happening here? - Deb_Allen_18Historic F5 AccountHi Hal --
- Harold_Deadman_
Nimbostratus
I will have someone switch our box back to 9.2 and confirm the test i-rule works on 9.2 and then re-open our support ticket. This wouldn't be the only problem we have seen on 9.4 that doesn't happen on 9.2. - Harold_Deadman_
Nimbostratus
I confirmed that it works on 9.2.2 so I will re-open our support issue and see if I can get a reason why it doesn't work on 9.4. - Scott_Larson
Nimbostratus
I am experiencing the same problems with 9.4. I haven't tested back on 9.2 yet, but count me among the disappointed...and please let me know if/when a patch is released! - Chad_Mentzer_14
Nimbostratus
The issue appears to happen in v9.3, too. We are moving from v9.0.4 to v9.3 and have found our iRules using AES encryption are no longer working. The base64 encode / decode appears to be changing something. - Scott_Larson
Nimbostratus
F5 support has confirmed this is a known bug that is fixed in hotfix 9.4.1 - Deb_Allen_18Historic F5 AccountThanks for the follow up, that's very helpful info to share.
- Deb_Allen_18Historic F5 AccountOops, hit Submit too soon -- updating the wiki page now with version specific details.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects