GithubHelp home page GithubHelp logo

nim-bearssl's Introduction

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.

nim-bearssl's People

Contributors

arnetheduck avatar cheatfate avatar jangko avatar mratsim avatar narimiran avatar nikitinator avatar stefantalpalaru avatar yglukhov avatar zah 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.