{"by":"ncruces","descendants":50,"id":40208800,"kids":[40212190,40212315,40214315,40221926,40222188,40215007,40215694,40215900,40212504,40232791,40221536],"score":99,"text":"SQLite encryption at-rest is a hot requested feature of both the <i>“default”</i> CGo driver [1] and the transpiled alternative driver [2]. So, this is a feature I wanted to bring to my own Wasm based Go driver&#x2F;bindings [3].<p>Open-source SQLite encryption extensions have had a troubled last few years. For whatever reason, in 2020 the (undocumented) feature that made it easy to offer page-level encryption was removed [4]. Some solutions are stuck with SQLite 3.31.1, but Ulrich Telle stepped up with a VFS approach [5].<p>Still, their solution seemed harder than something I&#x27;d want to maintain, as it requires understanding the structure of what&#x27;s being written to disk at the VFS layer. So, I looked at full disk encryption for something with less of an impedance mismatch.<p>Specifically, I&#x27;m using the Adiantum tweakable and length-preserving encryption (with 4K blocks, matching the default SQLite page size), and encrypting whole files (rather than page content).<p>I&#x27;m not a cryptographer, so I&#x27;d really appreciate some roasting before release.<p>There is nothing very Go specific about this (apart from the implementation) so if there are no obvious flaws, it may make sense to port it to C&#x2F;Rust&#x2F;etc and make it a loadable extension.<p>[1] <a href=\"https:&#x2F;&#x2F;github.com&#x2F;mattn&#x2F;go-sqlite3&#x2F;pull&#x2F;1109\">https:&#x2F;&#x2F;github.com&#x2F;mattn&#x2F;go-sqlite3&#x2F;pull&#x2F;1109</a><p>[2] <a href=\"https:&#x2F;&#x2F;gitlab.com&#x2F;cznic&#x2F;sqlite&#x2F;-&#x2F;issues&#x2F;105\" rel=\"nofollow\">https:&#x2F;&#x2F;gitlab.com&#x2F;cznic&#x2F;sqlite&#x2F;-&#x2F;issues&#x2F;105</a><p>[3] <a href=\"https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;go-sqlite3&#x2F;issues&#x2F;55\">https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;go-sqlite3&#x2F;issues&#x2F;55</a><p>[4] <a href=\"https:&#x2F;&#x2F;github.com&#x2F;sqlite&#x2F;sqlite&#x2F;commit&#x2F;b48c0d59\">https:&#x2F;&#x2F;github.com&#x2F;sqlite&#x2F;sqlite&#x2F;commit&#x2F;b48c0d59</a><p>[5] <a href=\"https:&#x2F;&#x2F;github.com&#x2F;utelle&#x2F;SQLite3MultipleCiphers\">https:&#x2F;&#x2F;github.com&#x2F;utelle&#x2F;SQLite3MultipleCiphers</a>","time":1714468347,"title":"Show HN: Roast my SQLite encryption at-rest","type":"story","url":"https://github.com/ncruces/go-sqlite3/tree/main/vfs/adiantum"}