ARS_70214
Mar 17, 2010Nimbostratus
problem to decrypt AES
Hello,
I have currently some problems with to decrypt AES encrypted string in f5 irules.
In fact It works well when I encrypt and decrypt a string in the same irule, but if I want to decrypt an already encrypted string then the AES::decrypt function return an empty string. Of course the key used to decrypt the encrypted string is the key I used to encrypt this one.
when HTTP_REQUEST {
/* Below is the part working */
set ::key be474444865c70f3e13624aec61eb292cef6cf5c4ce1725dd4fa49a93bf997c8
log local0. "key: $::key"
set ::toencrypt "test"
log local0. " $::toencrypt"
set ::encrypted [b64encode [AES::encrypt $::key $::toencrypt]]
log local0. "encrypted: $::encrypted"
set ::decrypted [AES::decrypt $::key [b64decode $::encrypted]]
log local0. "decrypted: $::decrypted"
/* the following example doesn't work */
set ::alreadyencrypted "if5fcuQNslSrend46PiyfBV/Bu60+lfXLAN76wSFxtmk13EnzNi0Zfu/"
log local0. "alreadyencrypted: $::alreadyencrypted"
set ::decrypted2 [AES::decrypt $::key [b64decode $::alreadyencrypted]]
log local0. "alreadydecrypted: $::decrypted2"
}
I'm asking if there is not something else to do to declare the encrypted string (bold line).
Do you know what to do to fix this problem?
Many thanks