boringssl packaged with Zig
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-09 21:30:10 +01:00
.github/workflows reduce size of CI target matrix 2026-07-14 07:34:42 +02:00
patches fix: Translate-c (#14) 2026-08-13 15:39:27 +02:00
.gitignore add zig-pkg directory to .gitignore 2026-07-14 07:34:42 +02:00
build.zig feat: Upgrade to zig 0.17.0 (#17) 2026-10-03 17:14:45 +02:00
build.zig.zon upgrade nasm to fix mempcpy issue 2026-10-06 13:04:16 +02:00
LICENSE build.zig 2025-06-02 12:58:33 +02:00
README.md fix repository link in readme 2026-11-09 21:30:10 +01:00

BoringSSL

This is BoringSSL, packaged for Zig.

Installation

First, update your build.zig.zon:

# Initialize a `zig build` project if you haven't already
zig init
zig fetch --save git+https://github.com/allyourcodebase/boringssl.git

You can then link boringssl in your build.zig with:

const boringssl_dependency = b.dependency("boringssl", .{
    .target = target,
    .optimize = optimize,
});
your_module.linkLibrary(boringssl_dependency.artifact("ssl"));
your_module.linkLibrary(boringssl_dependency.artifact("crypto"));

To use the library first declare translate-c as a dependency. See here for more information.

Declare a source file that imports the C includes.

For example:

src/my_ssl.c:

#include "openssl/ssl.h"
...
...

Convert that source file into zig using the declared translate-c dependency.

// Translate my_ssl.c into zig
const Translator = @import("translate_c").Translator;
const t: Translator = .init(translate_c, .{
    .c_source_file = b.path("src/my_ssl.c"),
    .target = target,
    .optimize = optimize,
});
t.addIncludePath(boringssl_dependency.namedLazyPath("ssl_include"));

your_module.addImport("boringssl", t.mod);

And use the library like this:

const ssl = @import("boringssl");

const ctx = ssl.EVP_CIPHER_CTX_new();
...
...

Notes

Windows support:

At the moment only x86_64-windows-gnu is functional. MSVC doesn't work!

GNU doesn't seem an official target by boringssl for windows which is why we need the patch.

Zig Version

The target zig version is 0.17.0