Any experts here? Here comes the use case for abov...
# room
u
Any experts here? Here comes the use case for above question: With an app update I need to rekey a room database with a stronger key. Now rekeying and storing the key in a safe place obviously can not happen atomically. So I decided for the following algorithm: 1. If
oldKey
exists, read it a. Open Room DB with
oldKey
b. Create and store
newKey
c. Rekey database with
newKey
d. Delete
oldKey
2. If oldKey does not exist, read or create
newKey
a. Open or create Room DB with
newKey
If failure happens between (1.b) and (1.c) the DB is still encrypted with the
oldKey
. If things fail between (1.c) and (1.d) it is already rekeyed with
newKey
. Both cases are indistinguishable without ‘trying the keys’. How can I recover from that state back to a ‘known’ state?