I am getting this message when running zig test src/crypto/encryption.zig --library crypto on this file:
const std = @import("std");
const crypto = @cImport({
@cInclude("openssl/evp.h");
@cInclude("openssl/aes.h");
});
const CipherError = error{
CIPHER_INIT_ERROR,
ENCRYPTION_INIT_ERROR,
DECRYPTION_INIT_ERROR,
};
pub const Cipher = struct {
key: [16]u8,
block_size: usize,
enc_ctx: *const crypto.EVP_CIPHER_CTX,
dec_ctx: *const crypto.EVP_CIPHER_CTX,
pub fn init(key: [16]u8) !Cipher {
const c_key: [*c]const u8 = key[0..];
const enc_ctx: crypto.EVP_CIPHER_CTX = undefined;
const dec_ctx: crypto.EVP_CIPHER_CTX = undefined;
if (crypto.EVP_CIPHER_CTX_init(@constCast(&enc_ctx)) == 0) return CipherError.CIPHER_INIT_ERROR;
if (crypto.EVP_EncryptInit_ex2(@constCast(&enc_ctx), crypto.EVP_aes_128_cfb8(), c_key, c_key, null) == 0) return CipherError.ENCRYPTION_INIT_ERROR;
if (crypto.EVP_CIPHER_CTX_init(@constCast(&dec_ctx)) == 0) return CipherError.CIPHER_INIT_ERROR;
if (crypto.EVP_DecryptInit_ex2(@constCast(&dec_ctx), crypto.EVP_aes_128_cfb8(), c_key, c_key, null) == 0) return CipherError.DECRYPTION_INIT_ERROR;
const block_size = crypto.EVP_CIPHER_block_size(crypto.EVP_aes_128_cfb8());
return .{
.key = key,
.block_size = @intCast(block_size),
.enc_ctx = &enc_ctx,
.dec_ctx = &dec_ctx,
};
}
};
test Cipher {
std.testing.refAllDecls(Cipher);
}
I'm not sure what is even going on to cause this issue. I'm not really testing anything, just using the test command to see if it compiles. Anything, even just pointing in the right direction would help. Thanks!