Coder Social home page Coder Social logo

boringssl-wasm's Introduction

BoringSSL (boringcrypto) for WebAssembly

A zig build file to compile BoringSSL's libcrypto to WebAssembly/WASI.

Precompiled library

For convenience, a precompiled library for WebAssembly can be directly downloaded from this repository.

Dependencies

The only required dependencies to rebuild the library are:

  • Go - Required by BoringSSL to generate the error codes map
  • Zig - To compile C/C++ code to WebAssembly

BoringSSL submodule

This repository includes an unmodified version of BoringSSL as a submodule. If you didn't clone it with the --recursive flag, the following command can be used to pull the submodule:

git submodule update --init --recursive --depth=1

Building the BoringSSL crypto library for WebAssembly

Generic build for WebAssembly/WASI:

zig build -Doptimize=ReleaseFast

The resulting static library is put into zig-out/libcrypto.a.

Build modes:

  • -Doptimize=ReleaseFast
  • -Doptimize=ReleaseSafe
  • -Doptimize-ReleaseSmall (also turns OPENSSL_SMALL on to disable precomputed tables)
  • -Doptimize=Debug (default, not recommended in production builds)

The library is compatible with the vast majority of WebAssembly runtimes, and can be used linked with C, Zig, Rust, whatever.

Optimizations only compatible with some runtimes can be also enabled:

zig build -Dtarget=wasm32-wasi -Drelease-fast \
          -Dcpu=generic+simd128+multivalue+bulk_memory

Possibly relevant extensions:

  • bulk_memory
  • exception_handling
  • multivalue
  • sign_ext
  • simd128
  • tail_call

Cross-compiling to other targets

The build file can be used to cross-compile to other targets as well. However, assembly implementations will not be included.

Examples

Compile to the native architecture:

zig build -Dtarget=native -Drelease-fast

Cross-compile to x86_64-linux:

zig build -Dtarget=x86_64-linux -Drelease-small

Cross-compile to Apple Silicon:

zig build -Dtarget=aarch64-macos -Drelease-safe

boringssl-wasm's People

Contributors

jedisct1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.