-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stability: Persistent state (key mappings) #394
Comments
About current data stabilityThe key mappings (and in the future maybe other kind of data) is a database containing information about a specific key:
In the near future, we might want to add "6. its authenticator" to the list to handle #271. "6" would be a stable "1" and "3" are stable UTF-8 strings. "2" might need to switch to UUID for stability and if dynamic provider ID are introduced (see #404). Changing the store mediumTo better scale, stabilise and make Parsec more robust we might want to move from our custom file and directory based model (the On-Disk Key Info Manager) to a system based on a pre-existing database software product.
Finally, performance is important but not critical as the time it takes to execute CRUD operations on the store might be negligible with the time needed to execute some crypto operations on real-hardware. For those reasons, using SQLite through A table with the following columns can be created:
This would mean that we would create a new key-info manager and leave that as an option in the configuration file. TestingFor testing, the service should try on the CI to load a reasonable amount of different old mappings. |
During the community meeting, it was decided that a new KIM is not strictly needed for a baseline stability. This requirement is mostly about ensuring that current users of the KIM will still be able to use it in the future. For that we should have tests where we try to successfully read old mappings. |
Currently our only tests around this are the persistence tests:
What I propose (and that will cover this comment) is:
|
I will create a new issue "Create a SQLite Key Info Manager" from this one when closed. |
I tried to see if Serde could cope with unbreaking changes in the use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct StructToto {
toto1: u32,
toto2: u32,
// Was commented out to generate struct_encoded
toto3: u32,
}
#[derive(Serialize, Deserialize, Debug)]
enum EnumToto {
Toto1,
Toto2,
// Was commented out to generate enum_encoded
Toto3,
}
fn main() {
/*
let enum_toto = EnumToto::Toto2;
let struct_toto = StructToto {
toto1: 23,
toto2: 78,
};
let struct_encoded: Vec<u8> = bincode::serialize(&struct_toto).unwrap();
let enum_encoded: Vec<u8> = bincode::serialize(&enum_toto).unwrap();
println!("let struct_encoded = {:?};", struct_encoded);
println!("let enum_encoded = {:?};", enum_encoded);
*/
let struct_encoded = [23, 0, 0, 0, 78, 0, 0, 0];
let enum_encoded = [1, 0, 0, 0];
let enum_decoded: EnumToto = bincode::deserialize(&enum_encoded[..]).unwrap();
println!("let enum_decoded = {:?};", enum_decoded);
// prints:
// let enum_decoded = Toto2;
let struct_decoded: StructToto = bincode::deserialize(&struct_encoded[..]).unwrap();
// panics:
// thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Kind(UnexpectedEof))', src/main.rs:42:80
println!("let struct_decoded = {:?};", struct_decoded);
} Adding new enum variants is OK but new fields makes the code panic. That would mean:
|
Definition: Old key mappings should still be read correctly by future stable Parsec versions.
Enforcement: The way the KIM persistently stores the mappings need to be backward-compatible in regards with reading/writing.
Enforcement Check
Mappings between KeyTriple and KeyInfo are persistently stored somewhere. New stable Parsec versions should successfully load old mappings and store current ones (of the same KeyInfoManager).
For the OnDiskKeyInfoManager:
psa-crypto
crate, (de)serialised by SerdeStability:
ListClients
andDeleteClient
are based on that. Stable.Attributes
structure is modified, then deserialisiation will fail for old mappings. The protobuf version could be used for more stability.4 and 5. If Serde modifies the way it (de)serialise data, then old mappings won't be read as well.
#271: if multiple authenticators are to be supported simultaneously, that will also probably impact the mappings, specially the OnDiskKeyInfoManager. The same application name should yield different keys under different authenticators.
Testing
Different version of the service should successfully load old mappings and store new ones.
From @ionut-arm in #386:
The text was updated successfully, but these errors were encountered: