| 1 |
// Copyright (C) 2021, Cloudflare, Inc. |
| 2 |
// All rights reserved. |
| 3 |
// |
| 4 |
// Redistribution and use in source and binary forms, with or without |
| 5 |
// modification, are permitted provided that the following conditions are |
| 6 |
// met: |
| 7 |
// |
| 8 |
// * Redistributions of source code must retain the above copyright notice, |
| 9 |
// this list of conditions and the following disclaimer. |
| 10 |
// |
| 11 |
// * Redistributions in binary form must reproduce the above copyright |
| 12 |
// notice, this list of conditions and the following disclaimer in the |
| 13 |
// documentation and/or other materials provided with the distribution. |
| 14 |
// |
| 15 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
| 16 |
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 17 |
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 |
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 19 |
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 |
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 |
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 |
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 23 |
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 24 |
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 |
|
| 27 |
use serde::Deserialize; |
| 28 |
use serde::Serialize; |
| 29 |
|
| 30 |
use super::Bytes; |
| 31 |
|
| 32 |
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, Default)] |
| 33 |
#[serde(rename_all = "snake_case")] |
| 34 |
pub enum KeyType { |
| 35 |
ServerInitialSecret, |
| 36 |
ClientInitialSecret, |
| 37 |
|
| 38 |
ServerHandshakeSecret, |
| 39 |
ClientHandshakeSecret, |
| 40 |
|
| 41 |
#[serde(rename = "server_0rtt_secret")] |
| 42 |
Server0RttSecret, |
| 43 |
#[serde(rename = "client_0rtt_secret")] |
| 44 |
Client0RttSecret, |
| 45 |
#[serde(rename = "server_1rtt_secret")] |
| 46 |
Server1RttSecret, |
| 47 |
#[serde(rename = "client_1rtt_secret")] |
| 48 |
Client1RttSecret, |
| 49 |
|
| 50 |
#[default] |
| 51 |
Unknown, |
| 52 |
} |
| 53 |
|
| 54 |
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)] |
| 55 |
#[serde(rename_all = "snake_case")] |
| 56 |
pub enum KeyUpdateOrRetiredTrigger { |
| 57 |
Tls, |
| 58 |
RemoteUpdate, |
| 59 |
LocalUpdate, |
| 60 |
} |
| 61 |
|
| 62 |
#[serde_with::skip_serializing_none] |
| 63 |
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, Default)] |
| 64 |
pub struct KeyUpdated { |
| 65 |
pub key_type: KeyType, |
| 66 |
|
| 67 |
pub old: Option<Bytes>, |
| 68 |
pub new: Bytes, |
| 69 |
|
| 70 |
pub generation: Option<u32>, |
| 71 |
|
| 72 |
pub trigger: Option<KeyUpdateOrRetiredTrigger>, |
| 73 |
} |
| 74 |
|
| 75 |
#[serde_with::skip_serializing_none] |
| 76 |
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)] |
| 77 |
pub struct KeyDiscarded { |
| 78 |
pub key_type: KeyType, |
| 79 |
pub key: Option<Bytes>, |
| 80 |
|
| 81 |
pub generation: Option<u32>, |
| 82 |
|
| 83 |
pub trigger: Option<KeyUpdateOrRetiredTrigger>, |
| 84 |
} |