Page 1 of 1

Encrypted fields + OnCalcFields

Posted: Tue 03 Apr 2018 13:08
by Rastislav
Hello,

I am using encrypted field with IBDAC 6.1.5 in Delphi 10.1. All is working well, but I found one problem :
I want read decrypted value in OnCalcFields event of TIBCTable. All is OK when Options.CacheCalcFields is False,
but when Options.CacheCalcFields is True, I see only encrypted value. It seems, OnCalcFields is executed before
decryption ... How I can see decrypted value in OnCalcFields, when caching is enabled ?

Second think - I tried harm encrypted data in database for testing. I want "see" NULL value in this case.
I set ihSkipData in TIBCEncryptor.InvalidHashAction (DataHeader = ehTagAndHash, EncryptionAlgorithm = eaAES256,
HashAlgorith = haSHA1). But I see not NULL, but harmed encrypted value ...

Thank you in advance for any advice :)

Re: Encrypted fields + OnCalcFields

Posted: Tue 03 Apr 2018 15:25
by ViktorV
For a quicker response, please compose a small sample demonstrating the specified behavior and send it to us using the contact form https://devart.com/company/contactform.html, including scripts for creating and filling database objects.

Re: Encrypted fields + OnCalcFields

Posted: Wed 04 Apr 2018 14:08
by Rastislav
Hello Viktor,
just I sent it ...

Re: Encrypted fields + OnCalcFields

Posted: Thu 05 Apr 2018 14:54
by ViktorV
1. Thank you for the information. We have reproduced the issue when using the CacheCalcFields option and it will be fixed in the next build.
2. Your example does not show the implementation of your behavior. It does not demonstrate the use of the TIBCEncryptor.InvalidHashAction option. To do this, use the value in your sample
C544E5292C9C42A5B94FE2791270290112C33E163802D6CBBE48EFCED98441C9DBEE50BF0F4586E0594FF17F0137B2BC2D6DE3B15C04F328D8F9341348941DADE517923FBC0AA8D0ECF7BAD65F5FACBEF48DBCEB7D8925F0
instead of
---C544E5292C9C42A5B94FE2791270290112C33E163802D6CBBE48EFCED98441C9DBEE50BF0F4586E0594FF17F0137B2BC2D6DE3B15C04F328D8F9341348941DADE517923FBC0AA8D0ECF7BAD65F5FACBEF48DBCEB7D8925FA

Re: Encrypted fields + OnCalcFields

Posted: Fri 06 Apr 2018 14:58
by Rastislav
Hello Viktor,

thank you. I understand now - here can be encrypted and crypted informations in one field and IBDAC will decrypt it only when it have "valid" format. But I think, I found next bug - I tried changed only one character in encoded text (character No.49 changed from "A" to "B" - see example) and application showed error message "Encrypted data is corrupt - Invalid encrypted data".
OK :
C544E5292C9C42A5B94FE27912702901D43DEE4BF7030808A5D71C397925E046532E8C0434AD7A9948FF286E8927511CB180D53747DCF783365B5FFAA4EF1983717FC76CE7F6AE1A5366DB2275BDF82CBC701D4B925C9188
Bad:
C544E5292C9C42A5B94FE27912702901D43DEE4BF7030808B5D71C397925E046532E8C0434AD7A9948FF286E8927511CB180D53747DCF783365B5FFAA4EF1983717FC76CE7F6AE1A5366DB2275BDF82CBC701D4B925C9188
Yes, I know, data are corrupted, but this message was showed also when I set ihSkipData in TIBCEncryptor.InvalidHashAction ...

Re: Encrypted fields + OnCalcFields

Posted: Fri 06 Apr 2018 15:28
by ViktorV
Yes, at the moment this is the correct behavior. We will consider the possibility of changing it and let you know about the results. For a detailed study of the issue, please specify in which cases in your application it is permissible to use explicitly corrupted data.