BearSSL wrapper in Nim
Go to file
Jacek Sieka 5159f7e385
update nimble build (#38)
* update nimble build

* remove arc tests

orc is default on devel
2022-11-21 11:07:33 +01:00
.github/workflows update nimble build (#38) 2022-11-21 11:07:33 +01:00
bearssl update nimble build (#38) 2022-11-21 11:07:33 +01:00
tests move `-d:nimRawSetjmp` to config.nims (#30) 2022-06-24 20:09:29 +02:00
.appveyor.yml Fix appveyor. 2019-10-23 11:23:33 +03:00
.gitignore update nimble build (#38) 2022-11-21 11:07:33 +01:00
.gitmodules Fix a submodule URL (otherwise, cloning was failing on a fresh Windows installation) 2022-03-04 13:29:44 +02:00
.travis.yml Fix appveyor. 2019-10-23 11:23:33 +03:00
LICENSE-APACHEv2 Initial commit (copied from nim-libp2p) 2019-09-30 21:23:06 +03:00
LICENSE-MIT Initial commit (copied from nim-libp2p) 2019-09-30 21:23:06 +03:00
README.md rand: convenience API (#28) 2022-06-15 22:53:40 +02:00
bearssl.nim split decls into separate modules in `bearssl/abi` (#27) 2022-06-14 19:33:00 +02:00
bearssl.nimble update nimble build (#38) 2022-11-21 11:07:33 +01:00
config.nims Add setup files 2022-07-25 22:05:58 +03:00
nim.cfg move `-d:nimRawSetjmp` to config.nims (#30) 2022-06-24 20:09:29 +02:00
nimble.lock Add a Nimble lock file 2022-04-14 18:08:54 +03:00
regenerate.sh update nimble build (#38) 2022-11-21 11:07:33 +01:00

README.md

bearssl

Build Status (Travis) Windows build status (Appveyor) Stability: experimental License: MIT License: Apache Github action

Simple BearSSL wrapper for Nim, fully integrated with the Nim build system.

Applications using nim-bearssl are fully stand-alone, needing no additional DLL or shared library.

Usage

The library is organised into two parts:

  • bearssl/ (except for abi) exposes thin wrappers around the raw ABI making the functions more convenient to use in Nim
  • bearssl/abi exposes the raw C functions of bearssl

For each bearssl header file, a corresponding Nim file exists - bearssl_rand.h ~ bearssl/rand.nim.

# You can import the whole library
import bearssl

# ... or simply parts thereof, which can save compilation time
import bearssl/rand

In general, the mappings follow the conventions of the original BearSSL library closely. The following conventions exist:

  • the br_ prefix has been dropped throughout
  • functions taking a XxxContext* use var and not ptr
  • byte replaces unsigned char* - this type is predominantly used for byte buffers
  • uint used instead of csize_t - these are the same type in Nim, but spelled more conveniently
    • Canonical nim code will have to be careful when converting existing int lengths, looking out for out-of-range values

In addition to the raw C-like api, convenience functions are added where applicable - these follow a similar set of conventions:

  • named after the function they simplify, but take advantage of types and overload support in Nim
  • help turn pointers and bytes into Nim types

Installation

You can install the developement version of the library through nimble with the following command:

nimble install bearssl

BearSSL itself is compiled as part of your project - there is no need to install any third-party libraries.

Developer notes

When updating the library, c2nim is used via regenerate.sh to update the RAW ABI files. Manual editing is then needed to make a few adjustments to the mapping, after which the files can be generated.

When adding new convenience functions, these should be added to bearssl/ instead of the generated files.

License

Licensed and distributed under either of

or

at your option. This file may not be copied, modified, or distributed except according to those terms.