LCOV - differential code coverage report
Current view: top level - proxy/src/scram - key.rs (source / functions) Coverage Total Hit CBC
Current: f6946e90941b557c917ac98cd5a7e9506d180f3e.info Lines: 100.0 % 13 13 13
Current Date: 2023-10-19 02:04:12 Functions: 100.0 % 6 6 6
Baseline: c8637f37369098875162f194f92736355783b050.info
Baseline Date: 2023-10-18 20:25:20

           TLA  Line data    Source code
       1                 : //! Tools for client/server/stored key management.
       2                 : 
       3                 : /// Faithfully taken from PostgreSQL.
       4                 : pub const SCRAM_KEY_LEN: usize = 32;
       5                 : 
       6                 : /// One of the keys derived from the [password](super::password::SaltedPassword).
       7                 : /// We use the same structure for all keys, i.e.
       8                 : /// `ClientKey`, `StoredKey`, and `ServerKey`.
       9 CBC          32 : #[derive(Default, PartialEq, Eq)]
      10                 : #[repr(transparent)]
      11                 : pub struct ScramKey {
      12                 :     bytes: [u8; SCRAM_KEY_LEN],
      13                 : }
      14                 : 
      15                 : impl ScramKey {
      16              37 :     pub fn sha256(&self) -> Self {
      17              37 :         super::sha256([self.as_ref()]).into()
      18              37 :     }
      19                 : 
      20              49 :     pub fn as_bytes(&self) -> [u8; SCRAM_KEY_LEN] {
      21              49 :         self.bytes
      22              49 :     }
      23                 : }
      24                 : 
      25                 : impl From<[u8; SCRAM_KEY_LEN]> for ScramKey {
      26                 :     #[inline(always)]
      27             133 :     fn from(bytes: [u8; SCRAM_KEY_LEN]) -> Self {
      28             133 :         Self { bytes }
      29             133 :     }
      30                 : }
      31                 : 
      32                 : impl AsRef<[u8]> for ScramKey {
      33                 :     #[inline(always)]
      34             103 :     fn as_ref(&self) -> &[u8] {
      35             103 :         &self.bytes
      36             103 :     }
      37                 : }
        

Generated by: LCOV version 2.1-beta