rhdl_ubft/crypto/
external.rs1use rhdl::prelude::*;
12
13use crate::ports::{Axis64, CryptoIn, CryptoOut, CryptoScheme, idle512, idle_read};
14
15#[derive(Clone, Debug, Synchronous, SynchronousDQ)]
17pub struct External<const SB: usize> {
18 unused: rhdl_fpga::core::dff::DFF<bool>,
19}
20
21impl<const SB: usize> Default for External<SB> {
22 fn default() -> Self {
23 Self { unused: rhdl_fpga::core::dff::DFF::new(false) }
24 }
25}
26
27impl<const SB: usize> CryptoScheme for External<SB> {
28 const SHARE_BEATS: usize = SB;
29 const SCHEME: u8 = 0;
30}
31
32impl<const SB: usize> SynchronousIO for External<SB> {
33 type I = CryptoIn;
34 type O = CryptoOut;
35 type Kernel = external_kernel<SB>;
36}
37
38#[kernel]
40pub fn external_kernel<const SB: usize>(_cr: ClockReset, _i: CryptoIn, q: ExternalQ<SB>) -> (CryptoOut, ExternalD<SB>) {
41 let o = CryptoOut {
42 ready: false,
43 msg: idle_read(),
44 sign_ready: false,
45 sig: idle512(),
46 verify_ready: false,
47 verdict: Axis64 { valid: false, data: b64(0) },
48 fault: false,
49 announce: idle512(),
50 cert_ready: false,
51 };
52 (o, ExternalD::<SB> { unused: q.unused })
53}