Debian Codegraph @

crt/s2n/bindings/rust/aws-kms-tls-auth/DEVELOPMENT.md

raw symbols SCIP
1 # Managing Algorithm & Format Changes.
2
3 ## Backwards Compatibility: Required
4 Changes must always be backwards compatible. More specifically, servers must always be able to deserialize earlier versions of PskIdentities, otherwise all of the in-flight communications would fail when an upgrade happens.
5
6 ## Forward Compatibility: Customer Responsibility
7 We generally do not promise forwards compatibility: A `0.0.1` V1 enabled server might not be able to handshake with a `0.0.2` V2 enabled client. We will strive to maintain forward compatibility, but if there was ever an upgrade from `AES_256_GCM_SIV` to `AES_512_GCM_SIV`, that would not be forward compatible.
8
9 It would be the customer's responsibility to first deploy version 0.0.2 to all servers, and only then would it be safe to enable `PskVersion::V2`. For further
10 information see the "Versioning" section in the main module docs.
11
12 ## Example Version Changes
13 Below are some examples of scenarios that would require a new version change.
14 - new field: Adding a new field to either PskIdentity or the inner obfuscated fields would require a version change.
15 - new obfuscation algorithm: switch the obfuscation algorithm from AES-256-GCM-SIV to some other AEAD algorithm.
16 - new HMAC algorithm: If s2n-tls exposed a new HMAC based on SHA512, we would need
17 a new PskVersion to take advantage of it.
18
19 All of these version changes could be accomplished with some variation of the following strategy.
20
21 ```rust
22 struct PskIdentity {
23 // This is a "rearranged" version of the existing wire format. As long as the
24 // PskVersion field is first, we can branch on it when parsing.
25 psk_version: PskVersion,
26 psk_identity_value: PskIdentityValue
27 }
28
29 enum PskIdentityValue {
30 V1(PskIdentityV1),
31 V2(PskIdentityV2),
32 }
33
34 impl PskIdentityValue {
35 /// version specific logic can be handled in the method
36 fn deobfuscate_datakey(&self, obfuscation_key: ObfuscationKey) -> Vec<u8> {
37 match self {
38 Self::V1(v1_struct) => {
39 // e.g. assert on the obfuscation_key version or size
40 }
41 }
42 }
43 }
44 ```
45
46 The above code structure would allow the `DecodeValue` and `EncodeValue` traits to work with both variants. Version specific logic can then be handled in the version-specific structs or the `PskIdentityValue` enum.
47
48
49