Crypto engine design enhancements and new library entry point

This commit is contained in:
Gu://em_ 2026-06-15 15:23:41 +02:00
parent cd83af4ef9
commit 693d7cfe51
9 changed files with 132 additions and 45 deletions

View file

@ -1,41 +1,23 @@
// WARNING NOT FUNCTIONAL !!!
// This is just a draft
// TODO
pub const CBC256_Implementation = struct {
pub const DefaultEngine = struct {
pub fn encrypt(data: []u8) void {
pub const BLOCK_SIZE = 16;
pub const KEY_SIZE = 32;
// NOTE: data should be padded to make its length be a multiple of BLOCK_SIZE
encypt: *const fn (key: *const [KEY_SIZE]u8, iv: *const [BLOCK_SIZE]u8, data: *const []u8, ) void,
decrypt: *const fn (key: *const [KEY_SIZE]u8, iv: *const [BLOCK_SIZE]u8, data: *const []u8, ) void,
};
// TODO
pub const CBC265_DefaultImplementation = struct {
pub fn encrypt( key: *const [32]u8, iv: *const [16]u8, data: *const []u8 ) void {
_ = key;
_ = iv;
_ = data;
}
pub fn decrypt( key: *const [32]u8, iv: *const [16]u8, data: *const []u8 ) void {
_ = key;
_ = iv;
_ = data;
}
};
pub fn AesEngine(comptime Provider: anytype) type {
_ = Provider;
return struct {
const Self = @This();
pub const CBC_265 = struct {
const key_length = 256;
// Encrypts the data block using AES 256 CBC
pub fn encrypt(data: []u8, key: [key_length]u8, iv: []u8) void {
_ = data;
_ = key;
_ = iv;
}
};
pub const CBC_128 = struct {
const key_length = 128;
// Encrypts the data block using AES 128 CBC
pub fn encrypt(data: []u8, key: [key_length]u8, iv: []u8) void {
_ = data;
_ = key;
_ = iv;
}
};
};
}