Encrypted fields + OnCalcFields

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Rastislav
Posts: 15
Joined: Tue 03 Apr 2018 10:18

Encrypted fields + OnCalcFields

Post by Rastislav » Tue 03 Apr 2018 13:08

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 :)

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Encrypted fields + OnCalcFields

Post by ViktorV » Tue 03 Apr 2018 15:25

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.

Rastislav
Posts: 15
Joined: Tue 03 Apr 2018 10:18

Re: Encrypted fields + OnCalcFields

Post by Rastislav » Wed 04 Apr 2018 14:08

Hello Viktor,
just I sent it ...

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Encrypted fields + OnCalcFields

Post by ViktorV » Thu 05 Apr 2018 14:54

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

Rastislav
Posts: 15
Joined: Tue 03 Apr 2018 10:18

Re: Encrypted fields + OnCalcFields

Post by Rastislav » Fri 06 Apr 2018 14:58

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 ...

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Encrypted fields + OnCalcFields

Post by ViktorV » Fri 06 Apr 2018 15:28

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.

Post Reply