diff --git a/src/crypto.zig b/src/crypto.zig new file mode 100644 index 0000000..c1500fd --- /dev/null +++ b/src/crypto.zig @@ -0,0 +1,36 @@ +// WARNING NOT FUNCTIONAL !!! +// This is just a draft +// TODO + +///////////////// Imports +// + +const AES = @import("crypto/aes.zig"); + + +///////////////// Public functions +// + +pub fn CryptoEngine(comptime Provider: anytype) type { + return struct { + const Self = @This(); + + pub const Aes = AES.AesEngine(Provider); + }; +} + + +///////////////// Tests +// + +const std = @import("std"); + +test "AES encryption defaults" { + + const crypto = CryptoEngine(); + + var data = [_]u8{ 1, 2, 3, 4 }; + const key = [_]u8{ 1, 2, 3, 4 }; + const iv = [_]u8{ 1, 2, 3, 4 }; + crypto.Aes.CBC_265.encrypt(&data, &key, &iv); +} diff --git a/src/crypto/aes.zig b/src/crypto/aes.zig new file mode 100644 index 0000000..4facf45 --- /dev/null +++ b/src/crypto/aes.zig @@ -0,0 +1,41 @@ +// WARNING NOT FUNCTIONAL !!! +// This is just a draft +// TODO + +pub const DefaultEngine = struct { + pub fn encrypt(data: []u8) void { + _ = 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; + } + }; + + }; +} diff --git a/src/crypto/ed25519.zig b/src/crypto/ed25519.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/crypto/hkdf.zig b/src/crypto/hkdf.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/crypto/hmac.zig b/src/crypto/hmac.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/crypto/sha256.zig b/src/crypto/sha256.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/crypto/sha512.zig b/src/crypto/sha512.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/crypto/x25519.zig b/src/crypto/x25519.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/root.zig b/src/root.zig index 9b202f1..95a57a1 100644 --- a/src/root.zig +++ b/src/root.zig @@ -1 +1,2 @@ pub const packet = @import("packet.zig"); +// pub const crypto = @import("crypto.zig");