Coverage Report

Created: 2025-07-23 06:21

/src/spdm-rs/external/ring/src/aead/gcm/clmulavxmovbe.rs
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2018-2024 Brian Smith.
2
//
3
// Permission to use, copy, modify, and/or distribute this software for any
4
// purpose with or without fee is hereby granted, provided that the above
5
// copyright notice and this permission notice appear in all copies.
6
//
7
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15
#![cfg(target_arch = "x86_64")]
16
17
use super::{HTable, KeyValue, UpdateBlock, UpdateBlocks, Xi, BLOCK_LEN};
18
use crate::{cpu::intel, polyfill::slice::AsChunks};
19
20
#[derive(Clone)]
21
pub struct Key {
22
    h_table: HTable,
23
}
24
25
impl Key {
26
    #[inline(never)]
27
0
    pub(in super::super) fn new(
28
0
        value: KeyValue,
29
0
        _required_cpu_features: (intel::ClMul, intel::Avx, intel::Movbe),
30
0
    ) -> Self {
31
0
        Self {
32
0
            h_table: unsafe { htable_new!(gcm_init_avx, value) },
33
0
        }
34
0
    }
35
36
0
    pub(super) fn inner(&self) -> &HTable {
37
0
        &self.h_table
38
0
    }
39
}
40
41
impl UpdateBlock for Key {
42
0
    fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) {
43
0
        self.update_blocks(xi, (&a).into())
44
0
    }
45
}
46
47
impl UpdateBlocks for Key {
48
0
    fn update_blocks(&self, xi: &mut Xi, input: AsChunks<u8, BLOCK_LEN>) {
49
0
        unsafe { ghash!(gcm_ghash_avx, xi, self.inner(), input) }
50
0
    }
51
}