Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Remove namespaces. Replace Travis-CI with GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
aw committed Dec 3, 2019
1 parent 214eaa8 commit 2e01689
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 54 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

timeout-minutes: 5

strategy:
matrix:
arch: ['src64']
version: ['17.12', '18.6', '18.12', '19.6', 'latest']

steps:
- uses: actions/checkout@v1
- uses: aw/picolisp-action@v1
with:
version: ${{matrix.version}}
architecture: ${{matrix.arch}}

- name: Run the tests on PicoLisp ${{matrix.arch}} v${{matrix.version}}
run: make check
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.0.0 (2019-12-03)

* **[Breaking changes]** Remove the use of PicoLisp namespaces
* Update picolisp-unit dependency to v3.0.0

## 1.0.0 (2015-06-11)

* Production release
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>
Copyright (c) 2015-2019 Alexander Williams, Unscramble <license@unscramble.jp>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ $(BUILD_DIR):

$(TEST_DIR):
mkdir -p $(TEST_DIR) && \
git clone $(TEST_REPO) $(TEST_DIR)
git clone $(TEST_REPO) $(TEST_DIR) && \
cd $(TEST_DIR) && \
git checkout v3.0.0

$(BUILD_DIR)/$(TARGET):
cd $(BUILD_DIR) && \
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bcrypt hashing for PicoLisp

[![GitHub release](https://img.shields.io/github/release/aw/picolisp-bcrypt.svg)](https://img.shields.io/github/release/aw/picolisp-bcrypt) [![Build Status](https://travis-ci.org/aw/picolisp-bcrypt.svg?branch=master)](https://travis-ci.org/aw/picolisp-bcrypt) [![Dependency](https://img.shields.io/badge/[deps]%20bcrypt-b1e3dea0a1-ff69b4.svg)](https://github.com/rg3/bcrypt.git) [![Dependency](https://img.shields.io/badge/[deps]%20picolisp%2D-unit-v1.0.0-ff69b4.svg)](https://github.com/aw/picolisp-unit.git)
[![GitHub release](https://img.shields.io/github/release/aw/picolisp-bcrypt.svg)](https://img.shields.io/github/release/aw/picolisp-bcrypt) [![Build Status](https://travis-ci.org/aw/picolisp-bcrypt.svg?branch=master)](https://travis-ci.org/aw/picolisp-bcrypt) [![Dependency](https://img.shields.io/badge/[deps]%20bcrypt-b1e3dea0a1-ff69b4.svg)](https://github.com/rg3/bcrypt.git) [![Dependency](https://img.shields.io/badge/[deps]%20picolisp%2D-unit-v3.0.0-ff69b4.svg)](https://github.com/aw/picolisp-unit.git) ![Build status](https://github.com/aw/picolisp-bcrypt/workflows/CI/badge.svg?branch=master)

This library can be used to hash strings (ex: passwords) using bcrypt in [PicoLisp](http://picolisp.com/).

Expand All @@ -16,7 +16,8 @@ This library can be used to hash strings (ex: passwords) using bcrypt in [PicoLi

# Requirements

* PicoLisp 64-bit v3.1.9+
* PicoLisp 64-bit `v3.1.9+`
* Tested up to PicoLisp `v19.11.25`, [see test runs](https://github.com/aw/picolisp-bcrypt/commit/1b9d4e2921e5f108dac0facbff1dc5bfff97835a/checks)
* Git
* UNIX/Linux development/build tools (gcc, make/gmake, etc..)

Expand Down Expand Up @@ -44,7 +45,7 @@ To keep everything updated, type:

# Usage

Only the following functions are exported publicly, and namespaced with `(symbols 'bcrypt)` (or the prefix: `bcrypt~`):
Only the following functions are exported publicly:

* **(gensalt Factor)** generates a salt to be used for hashing a string
- `Factor` _Number_: a Number between 4 and 31, defaults to `12` otherwise
Expand All @@ -56,7 +57,7 @@ Only the following functions are exported publicly, and namespaced with `(symbol
- `Hash` _String_: the hashed String of the password
* **(timing Factor)** calculates the timing of a password hashing, in seconds. Returns the factor in `car` and seconds in `cdr`

> **Note:** These functions are not namespace [local symbols](http://software-lab.de/doc/refL.html#local), which means they would redefine symbols with the same name in the `'pico` namespace.
> **Note:** These functions are not namespace [local symbols](https://software-lab.de/doc/refL.html#local), which means they would redefine symbols with the same name in the `'pico` namespace.
### Notes

Expand All @@ -73,7 +74,6 @@ pil +
(load "bcrypt.l")
(symbols 'bcrypt)
(gensalt)
-> "$2a$12$mQn1fUDeEZFW74KD5kU6g."
Expand All @@ -88,7 +88,6 @@ pil +
(load "bcrypt.l")
(symbols 'bcrypt)
(hashpw "changeme")
-> "$2a$12$mmxN/qk8yvfjCx./KXtgfuqnUFsXjYv1ZTZmkMtdQ94rTDngiXpsq"
Expand All @@ -106,7 +105,6 @@ pil +
(load "bcrypt.l")
(symbols 'bcrypt)
(compare "changeme" "$2a$14$kjOSmjZeLsBdru7NRPEmQuL5eU5YN4Yb48bD1A0Pxzwu/3G/7kwBy")
-> T
Expand All @@ -124,7 +122,6 @@ pil +
(load "bcrypt.l")
(symbols 'bcrypt)
(timing)
-> (12 . 0)
Expand All @@ -148,4 +145,4 @@ If you want to improve this library, please make a pull-request.

[MIT License](LICENSE)

Copyright (c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>
Copyright (c) 2015-2019 Alexander Williams, Unscramble <license@unscramble.jp>
7 changes: 1 addition & 6 deletions bcrypt.l
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>

(symbols 'bcrypt 'pico)

(local MODULE_INFO *Bcrypt *BCRYPT_HASHSIZE *Work_factor *Salt_struct)
(local bcrypt-gensalt bcrypt-hashpw throw-error epoch to-string)
# Copyright (c) 2015-2019 Alexander Williams, Unscramble <license@unscramble.jp>

(load (pack (car (file)) "module.l"))

Expand Down
6 changes: 3 additions & 3 deletions module.l
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[de MODULE_INFO
("name" "bcrypt")
("version" "1.0.0")
("version" "2.0.0")
("summary" "bcrypt hashing for PicoLisp")
("source" "https://github.com/aw/picolisp-bcrypt.git")
("author" "Alexander Williams")
("license" "MIT")
("copyright" "(c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>")
("copyright" "(c) 2015-2019 Alexander Williams, Unscramble <license@unscramble.jp>")
("install" "make")
("requires"
("bcrypt" "b1e3dea0a1" "https://github.com/rg3/bcrypt.git")
("picolisp-unit" "v1.0.0" "https://github.com/aw/picolisp-unit.git") ]
("picolisp-unit" "v3.0.0" "https://github.com/aw/picolisp-unit.git") ]
2 changes: 1 addition & 1 deletion test.l
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
(chdir "test/"
(mapcar load (filter '((N) (sub? "test_" N)) (dir "."))) )

(unit~report)
(report)
32 changes: 12 additions & 20 deletions test/test_bcrypt.l
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,48 @@

(prinl "^J Testing bcrypt library functions^J")

(symbols 'bcrypt)

(setq *Salt (gensalt)
*Hash (hashpw "changeme" *Salt)
*Passwd (hashpw "changeme") )

(de test-hash-factor-12 ()
(unit~assert-includes "$2a$12"
(assert-includes "$2a$12"
*Salt
"Generate a bcrypt hash with factor of 12" ) )

(de test-leaky-symbols ()
(unit~assert-nil (= "bcrypt" (cadr (assoc "name" pico~MODULE_INFO)))
"Ensure local symbols are not leaked globally" ) )

[unit~execute
[execute
'(test-hash-factor-12)

'(unit~assert-includes "$2a$14"
'(assert-includes "$2a$14"
(gensalt 14)
"Generate a bcrypt hash with factor of 14" )

'(unit~assert-includes "$2a$12"
'(assert-includes "$2a$12"
(gensalt 90)
"Does NOT generate a bcrypt hash with factor of 90" )

'(unit~assert-includes *Salt
'(assert-includes *Salt
*Hash
"Generate matching bcrypt hashes" )

'(unit~assert-kind-of 'String
'(assert-kind-of 'String
*Passwd
"Generate bcrypt password without providing a hash" )

'(unit~assert-t (compare "changeme" *Passwd)
'(assert-t (compare "changeme" *Passwd)
"Successfully compare a password and hash" )

'(unit~assert-nil (compare "changeme" "$2a$12$2Lgk0P5s5VsxDUM2aa/HFu/6DwHce1lbUwJ1kTm092DwEeDRHHYBy")
'(assert-nil (compare "changeme" "$2a$12$2Lgk0P5s5VsxDUM2aa/HFu/6DwHce1lbUwJ1kTm092DwEeDRHHYBy")
"Fail to compare a password and hash" )

'(unit~assert-throws 'InternalError
'(assert-throws 'InternalError
'(BcryptError . "Unable to hash password")
'(compare "changeme" "I have no idea what i'm doing")
"Throw an InternalError when trying to compare an invalid hash" )

'(unit~assert-equal 12
'(assert-equal 12
(car (timing))
"Timing a hash with the default factor of 12" )

'(unit~assert-t (> (cdr (timing 15)) 1)
"Timing a hash in more than 1 second with a factor of 15")

'(test-leaky-symbols) ]
'(assert-t (> (cdr (timing 15)) 1)
"Timing a hash in more than 1 second with a factor of 15") ]

0 comments on commit 2e01689

Please sign in to comment.