This commit is contained in:
David Allemang
2024-03-05 12:48:16 -05:00
parent 3b79a87095
commit 24f32f5725
5 changed files with 35 additions and 113 deletions

3
src/enet.zig Normal file
View File

@@ -0,0 +1,3 @@
pub usingnamespace @cImport({
@cInclude("enet/enet.h");
});

View File

@@ -1,4 +1,5 @@
const std = @import("std");
const enet = @import("enet");
const DH = std.crypto.dh.X25519;
const AES = std.crypto.aead.aes_gcm.Aes256Gcm;
@@ -62,6 +63,9 @@ const Packet = struct {
};
pub fn main() !void {
if (enet.enet_initialize() != 0) return error.ENetInitFailed;
defer enet.enet_deinitialize();
const bob = try Encryptor.init();
const alice = try Encryptor.init();
@@ -106,9 +110,9 @@ pub fn main() !void {
std.debug.print(
"Packet: {s} {s} {s}\n",
.{
try digest(ally, pkt.cipher_text, .lower),
try digest(ally, &pkt.nonce, .lower),
try digest(ally, &pkt.tag, .lower),
try digest(ally, pkt.cipher_text, .lower),
try digest(ally, &pkt.nonce, .lower),
try digest(ally, &pkt.tag, .lower),
},
);
std.debug.assert(!std.mem.eql(u8, pkt.cipher_text, msg));

View File

@@ -1,10 +0,0 @@
const std = @import("std");
const testing = std.testing;
export fn add(a: i32, b: i32) i32 {
return a + b;
}
test "basic add functionality" {
try testing.expect(add(3, 7) == 10);
}