Vendor asic-rs 0.8.1 (280 crates, offline builds) + wxWidgets 3.3.3 (pristine + patch queue); UI spec + ADR-0003; M1 on asic-rs

This commit is contained in:
2026-09-15 10:41:00 -06:00
parent 6dc77e8eb0
commit a2b65bb47f
16427 changed files with 6972976 additions and 3 deletions
+141
View File
@@ -0,0 +1,141 @@
use cipher::{
crypto_common::{InnerInit, InnerUser},
generic_array::ArrayLength,
inout::InOut,
AlgorithmName, Block, BlockBackend, BlockCipher, BlockClosure, BlockDecryptMut, BlockSizeUser,
ParBlocks, ParBlocksSizeUser,
};
use core::fmt;
/// ECB mode decryptor.
#[derive(Clone)]
pub struct Decryptor<C>
where
C: BlockDecryptMut + BlockCipher,
{
cipher: C,
}
impl<C> BlockSizeUser for Decryptor<C>
where
C: BlockDecryptMut + BlockCipher,
{
type BlockSize = C::BlockSize;
}
impl<C> BlockDecryptMut for Decryptor<C>
where
C: BlockDecryptMut + BlockCipher,
{
fn decrypt_with_backend_mut(&mut self, f: impl BlockClosure<BlockSize = Self::BlockSize>) {
let Self { cipher } = self;
cipher.decrypt_with_backend_mut(Closure { f })
}
}
impl<C> InnerUser for Decryptor<C>
where
C: BlockDecryptMut + BlockCipher,
{
type Inner = C;
}
impl<C> InnerInit for Decryptor<C>
where
C: BlockDecryptMut + BlockCipher,
{
#[inline]
fn inner_init(cipher: C) -> Self {
Self { cipher }
}
}
impl<C> AlgorithmName for Decryptor<C>
where
C: BlockDecryptMut + BlockCipher + AlgorithmName,
{
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("ecb::Decryptor<")?;
<C as AlgorithmName>::write_alg_name(f)?;
f.write_str(">")
}
}
impl<C> fmt::Debug for Decryptor<C>
where
C: BlockDecryptMut + BlockCipher + AlgorithmName,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("ecb::Decryptor<")?;
<C as AlgorithmName>::write_alg_name(f)?;
f.write_str("> { ... }")
}
}
struct Closure<BS, BC>
where
BS: ArrayLength<u8>,
BC: BlockClosure<BlockSize = BS>,
{
f: BC,
}
impl<BS, BC> BlockSizeUser for Closure<BS, BC>
where
BS: ArrayLength<u8>,
BC: BlockClosure<BlockSize = BS>,
{
type BlockSize = BS;
}
impl<BS, BC> BlockClosure for Closure<BS, BC>
where
BS: ArrayLength<u8>,
BC: BlockClosure<BlockSize = BS>,
{
#[inline(always)]
fn call<B: BlockBackend<BlockSize = Self::BlockSize>>(self, backend: &mut B) {
let Self { f } = self;
f.call(&mut Backend { backend });
}
}
struct Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
backend: &'a mut BK,
}
impl<'a, BS, BK> BlockSizeUser for Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
type BlockSize = BS;
}
impl<'a, BS, BK> ParBlocksSizeUser for Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
type ParBlocksSize = BK::ParBlocksSize;
}
impl<'a, BS, BK> BlockBackend for Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
#[inline(always)]
fn proc_block(&mut self, block: InOut<'_, '_, Block<Self>>) {
self.backend.proc_block(block);
}
#[inline(always)]
fn proc_par_blocks(&mut self, blocks: InOut<'_, '_, ParBlocks<Self>>) {
self.backend.proc_par_blocks(blocks);
}
}
+137
View File
@@ -0,0 +1,137 @@
use cipher::{
consts::U1,
crypto_common::{InnerInit, InnerUser},
generic_array::ArrayLength,
inout::InOut,
AlgorithmName, Block, BlockBackend, BlockCipher, BlockClosure, BlockEncryptMut, BlockSizeUser,
ParBlocksSizeUser,
};
use core::fmt;
/// ECB mode encryptor.
#[derive(Clone)]
pub struct Encryptor<C>
where
C: BlockEncryptMut + BlockCipher,
{
cipher: C,
}
impl<C> BlockSizeUser for Encryptor<C>
where
C: BlockEncryptMut + BlockCipher,
{
type BlockSize = C::BlockSize;
}
impl<C> BlockEncryptMut for Encryptor<C>
where
C: BlockEncryptMut + BlockCipher,
{
fn encrypt_with_backend_mut(&mut self, f: impl BlockClosure<BlockSize = Self::BlockSize>) {
let Self { cipher, .. } = self;
cipher.encrypt_with_backend_mut(Closure { f })
}
}
impl<C> InnerUser for Encryptor<C>
where
C: BlockEncryptMut + BlockCipher,
{
type Inner = C;
}
impl<C> InnerInit for Encryptor<C>
where
C: BlockEncryptMut + BlockCipher,
{
#[inline]
fn inner_init(cipher: C) -> Self {
Self { cipher }
}
}
impl<C> AlgorithmName for Encryptor<C>
where
C: BlockEncryptMut + BlockCipher + AlgorithmName,
{
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("ecb::Encryptor<")?;
<C as AlgorithmName>::write_alg_name(f)?;
f.write_str(">")
}
}
impl<C> fmt::Debug for Encryptor<C>
where
C: BlockEncryptMut + BlockCipher + AlgorithmName,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("ecb::Encryptor<")?;
<C as AlgorithmName>::write_alg_name(f)?;
f.write_str("> { ... }")
}
}
struct Closure<BS, BC>
where
BS: ArrayLength<u8>,
BC: BlockClosure<BlockSize = BS>,
{
f: BC,
}
impl<BS, BC> BlockSizeUser for Closure<BS, BC>
where
BS: ArrayLength<u8>,
BC: BlockClosure<BlockSize = BS>,
{
type BlockSize = BS;
}
impl<BS, BC> BlockClosure for Closure<BS, BC>
where
BS: ArrayLength<u8>,
BC: BlockClosure<BlockSize = BS>,
{
#[inline(always)]
fn call<B: BlockBackend<BlockSize = Self::BlockSize>>(self, backend: &mut B) {
let Self { f, .. } = self;
f.call(&mut Backend { backend });
}
}
struct Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
backend: &'a mut BK,
}
impl<'a, BS, BK> BlockSizeUser for Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
type BlockSize = BS;
}
impl<'a, BS, BK> ParBlocksSizeUser for Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
type ParBlocksSize = U1;
}
impl<'a, BS, BK> BlockBackend for Backend<'a, BS, BK>
where
BS: ArrayLength<u8>,
BK: BlockBackend<BlockSize = BS>,
{
#[inline(always)]
fn proc_block(&mut self, block: InOut<'_, '_, Block<Self>>) {
self.backend.proc_block(block);
}
}
+102
View File
@@ -0,0 +1,102 @@
//! [Electronic Codebook][1] (ECB) mode.
//!
//! <img src="https://user-images.githubusercontent.com/7829098/171395128-0ff53e16-1969-4848-8db4-3fc4fd0cbbb4.svg" width="49%" />
//! <img src="https://user-images.githubusercontent.com/7829098/171395113-219f6995-4e2d-4f4a-bb10-d6a229c10989.svg" width="49%"/>
//!
//! Mode functionality is accessed using traits from re-exported [`cipher`] crate.
//!
//! # ⚠️ Security Warning: Hazmat!
//!
//! This crate does not ensure ciphertexts are authentic! Thus ciphertext integrity
//! is not verified, which can lead to serious vulnerabilities!
//!
//! # Example
//! ```
//! # #[cfg(feature = "block-padding")] {
//! use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyInit};
//! use hex_literal::hex;
//!
//! type Aes128EcbEnc = ecb::Encryptor<aes::Aes128>;
//! type Aes128EcbDec = ecb::Decryptor<aes::Aes128>;
//!
//! let key = [0x42; 16];
//! let plaintext = *b"hello world! this is my plaintext.";
//! let ciphertext = hex!(
//! "42b153410851a931eb3e6c048867ae5f"
//! "95eb20b42e176b07840db75688be9c70"
//! "e4670ea0d87a71be5f9f3099b4fff3dc"
//! );
//!
//! // encrypt/decrypt in-place
//! // buffer must be big enough for padded plaintext
//! let mut buf = [0u8; 48];
//! let pt_len = plaintext.len();
//! buf[..pt_len].copy_from_slice(&plaintext);
//! let ct = Aes128EcbEnc::new(&key.into())
//! .encrypt_padded_mut::<Pkcs7>(&mut buf, pt_len)
//! .unwrap();
//! assert_eq!(ct, &ciphertext[..]);
//!
//! let pt = Aes128EcbDec::new(&key.into())
//! .decrypt_padded_mut::<Pkcs7>(&mut buf)
//! .unwrap();
//! assert_eq!(pt, &plaintext);
//!
//! // encrypt/decrypt from buffer to buffer
//! let mut buf = [0u8; 48];
//! let ct = Aes128EcbEnc::new(&key.into())
//! .encrypt_padded_b2b_mut::<Pkcs7>(&plaintext, &mut buf)
//! .unwrap();
//! assert_eq!(ct, &ciphertext[..]);
//!
//! let mut buf = [0u8; 48];
//! let pt = Aes128EcbDec::new(&key.into())
//! .decrypt_padded_b2b_mut::<Pkcs7>(&ct, &mut buf)
//! .unwrap();
//! assert_eq!(pt, &plaintext);
//! # }
//! ```
//!
//! With enabled `alloc` (or `std`) feature you also can use allocating
//! convinience methods:
//! ```
//! # #[cfg(all(feature = "alloc", feature = "block-padding"))] {
//! # use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyInit};
//! # use hex_literal::hex;
//! # type Aes128EcbEnc = ecb::Encryptor<aes::Aes128>;
//! # type Aes128EcbDec = ecb::Decryptor<aes::Aes128>;
//! # let key = [0x42; 16];
//! # let plaintext = *b"hello world! this is my plaintext.";
//! # let ciphertext = hex!(
//! # "42b153410851a931eb3e6c048867ae5f"
//! # "95eb20b42e176b07840db75688be9c70"
//! # "e4670ea0d87a71be5f9f3099b4fff3dc"
//! # );
//! let res = Aes128EcbEnc::new(&key.into())
//! .encrypt_padded_vec_mut::<Pkcs7>(&plaintext);
//! assert_eq!(res[..], ciphertext[..]);
//! let res = Aes128EcbDec::new(&key.into())
//! .decrypt_padded_vec_mut::<Pkcs7>(&res)
//! .unwrap();
//! assert_eq!(res[..], plaintext[..]);
//! # }
//! ```
//!
//! [1]: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#ECB
#![no_std]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg",
html_root_url = "https://docs.rs/ECB/0.1.2"
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
mod decrypt;
mod encrypt;
pub use cipher;
pub use decrypt::Decryptor;
pub use encrypt::Encryptor;