Giter Site home page Giter Site logo

baitcenter / libreauth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from breard-r/libreauth

0.0 1.0 0.0 366 KB

LibreAuth is a collection of tools for user authentication.

Home Page: https://docs.rs/libreauth/

License: Other

Makefile 1.40% C 14.94% Rust 83.67%

libreauth's Introduction

LibreAuth

Build Status LibreAuth on crates.io LibreAuth on docs.rs License: CeCILL-C License: CeCILL-2.1

LibreAuth is a collection of tools for user authentication.

Features

  • Password / passphrase authentication
    • no character-set limitation
    • reasonable lenth limit (security vs. DOS)
    • strong, evolutive and retro-compatible password hashing functions
    • NFKC normalization for Unicode passwords
    • optional NIST Special Publication 800-63B compatibility
  • HOTP - HMAC-based One-time Password Algorithm (OATH - RFC 4226)
    • the key can be passed as bytes, an ASCII string, an hexadicimal string, a base32 string or a base64 string
    • customizable counter
    • customizable hash function (sha1, full sha2 family, sha3/Keccak fixed-size families)
    • customizable output length
    • customizable output alphabet
  • TOTP - Time-based One-time Password Algorithm (OATH - RFC 6238)
    • the key can be passed as bytes, an ASCII string, an hexadicimal string, a base32 string or a base64 string
    • customizable timestamp
    • customizable period
    • customizable initial time (T0)
    • customizable hash function (sha1, full sha2 family, sha3/Keccak fixed-size families)
    • customizable output length
    • customizable output alphabet
    • customizable positive and negative period tolerance
  • Random key generation
    • uses the platform's secure entropy source
    • customizable size
    • customizable output format (Vec, hexadicimal string, base32 string, base64 string)
  • U2F - Universal 2nd Factor (FIDO Alliance) ⚠️ Not started
    • virtual device API
    • client API
    • server API

Status

The project itself is still in development and therefore should not be used in production before version 1.0.0. Below is the list of features that will be present in the first stable version and their individual status.

  • OATH HOTP/TOTP: almost ready!
    • ✅ lot of features
    • ⚠️ almost stable API
    • ⚠️ lack of peer review
  • Password / passphrase authentication: not ready yet.
    • ‼️ incomplete
    • ‼️ unstable API
    • ⚠️ lack of peer review
  • Random key generation: almost ready!
    • ⚠️ almost stable API
    • ⚠️ lack of peer review

Using within a Rust project

You can find LibreAuth on crates.io and include it in your Cargo.toml:

libreauth = "*"

Using outside Rust

In order to build LibreAuth, you will need the Rust compiler and its package manager, Cargo. The minimal required Rust version is 1.31, although it is recommended to use the latest stable one.

$ make
$ make install

Quick examples

Rust

More examples are available in the documentation.

extern crate libreauth;
use libreauth::oath::TOTPBuilder;

let key = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ".to_string();
let code = TOTPBuilder::new()
    .base32_key(&key)
    .finalize()
    .unwrap()
    .generate();
assert_eq!(code.len(), 6);

C

#include <stdio.h>
#include <libreauth.h>

int main(void) {
  struct libreauth_totp_cfg cfg;
  char   code[7], key[] = "12345678901234567890";

  if (libreauth_totp_init(&cfg) != LIBREAUTH_OTP_SUCCESS) {
    return 1;
  }
  cfg.key = key;
  cfg.key_len = sizeof(key);
  if (libreauth_totp_generate(&cfg, code) != LIBREAUTH_OTP_SUCCESS) {
    return 2;
  }

  printf("%s\n", code);

  return 0;
}
$ cc -o totp totp.c -llibreauth
$ ./totp
848085

Python

Python bindings are available. See the Python LibreAuth project.

License

LibreAuth is a free software available either under the CeCILL-C or the CeCILL 2.1 license. For a quick summary of those licenses, you can read the frequently asked questions on the licenses' website. A full copy of those licenses are available in this repository both in english and french.

While the CeCILL 2.1 is the original LibreAuth license, future versions may be published only under the CeCILL-C license. This change occurs because CeCILL 2.1 isn't really suited for a library since it is a "viral" license.

libreauth's People

Contributors

breard-r avatar deedasmi avatar lamafab 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.