On 04/12/18 16:51, Mark Rotteveel wrote:
On 12-4-2018 15:31, Alex Peshkoff via Firebird-devel wrote:
On 04/12/18 15:18, Mark Rotteveel wrote:
How does the protocol for the database encryption callback work? If
I look at the implementation in Firebird ADO.net, it just tries and
keep sending the same key in a while loop until Firebird responds
with something other than op_crypt_key_callback, which seems a bit
Looks like at the other side there is _VERY_ strange plugin.
Certainly having such behavior in the code is serious bug in ADO.net.
Technically the Firebird client code also uses a loop though.
Yes, but instead of sending same key it's passing data from server to
the passed by client interface and returns an answer from it to server.
In case of no intreface it returns empy answer, and be sure - server
knows that it means 'no key from client'.
Also, IIRC, there was a change for database encryption that led to
wire protocol v14, exactly what changed between wire protocol v13
There was a bug in v.13 - size of respond buffer was not passed over
Ok, so in V13 one would only need to read the data buffer, and in v14
and higher, one would also need to read p_cc_reply value?
Yes, and if you have v13 here you may return empty data to the server at
once - no chance for successfull handshake.
On a related note, when using the native API, it looks like the
encryption callback registration is process-wide instead of
In native API it's provider-specific - after getting an instance of
provider one (who needs to use database encryption) should pass
callback interface to that provider.
In ISC API emulation thread-wide approach is used - handler installed
by fb_database_crypt_callback() will be used by attaches in given
Isn't that a great way to send encryption keys to the wrong system
(if you're using multiple databases and/or systems)?
With right design of plugin this will not happen - interface should
make sure there is correct KeyHolder on the server before sending a
key. Certainly with an approach described by you in ADO key may get
lost. But when crypt is used in this way key may get lost in many
And how would a client do that?
For example - KeyHolder has a private key of RSA pair, client software -
a public one. Before sending something over the wire it's encrypted with
public RSA, to decrypt it private part of pair is needed. Servers that
do not have right private RSA key can receive the message but it's a
garbage for them. Actual protocol should better be more complex - at
least with salt to avoid sending same packet for same key.
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at