LCOV - differential code coverage report
Current view: top level - proxy/src/scram - key.rs (source / functions) Coverage Total Hit CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 100.0 % 13 13 13
Current Date: 2024-01-09 02:06:09 Functions: 100.0 % 7 7 7
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           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          74 : #[derive(Clone, Default, PartialEq, Eq)]
      10                 : #[repr(transparent)]
      11                 : pub struct ScramKey {
      12                 :     bytes: [u8; SCRAM_KEY_LEN],
      13                 : }
      14                 : 
      15                 : impl ScramKey {
      16              58 :     pub fn sha256(&self) -> Self {
      17              58 :         super::sha256([self.as_ref()]).into()
      18              58 :     }
      19                 : 
      20              71 :     pub fn as_bytes(&self) -> [u8; SCRAM_KEY_LEN] {
      21              71 :         self.bytes
      22              71 :     }
      23                 : }
      24                 : 
      25                 : impl From<[u8; SCRAM_KEY_LEN]> for ScramKey {
      26                 :     #[inline(always)]
      27             367 :     fn from(bytes: [u8; SCRAM_KEY_LEN]) -> Self {
      28             367 :         Self { bytes }
      29             367 :     }
      30                 : }
      31                 : 
      32                 : impl AsRef<[u8]> for ScramKey {
      33                 :     #[inline(always)]
      34             150 :     fn as_ref(&self) -> &[u8] {
      35             150 :         &self.bytes
      36             150 :     }
      37                 : }
        

Generated by: LCOV version 2.1-beta