Skip to content

Commit

Permalink
Merge pull request #19 from xsc/chore/bring-into-2021
Browse files Browse the repository at this point in the history
Adapt Codebase
  • Loading branch information
xsc authored Jan 17, 2021
2 parents 2d4dc0b + 7524a0a commit 2ca70a1
Show file tree
Hide file tree
Showing 30 changed files with 228 additions and 287 deletions.
2 changes: 2 additions & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:lint-as {pandect.core-test/deftest-api clojure.test/deftest}
:output {:exclude-files ["^src/pandect/algo"]}}
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: ["**"]
pull_request:
branches: [master]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: DeLaGuardo/clojure-lint-action@master
with:
clj-kondo-args: --lint src test
check-name: clj-kondo
github_token: ${{ secrets.GITHUB_TOKEN }}

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: lein deps
- name: Run tests
run: lein ci
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ pom.xml.asc
*.swp
*~
.nrepl-port
src/pandect/algo
.clj-kondo/.cache
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2014-2016 Yannick Scherer
Copyright (c) 2014-2021 Yannick Scherer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
# pandect

[![Clojars Project](https://img.shields.io/clojars/v/pandect.svg)](https://clojars.org/pandect)
[![CI](https://github.com/xsc/pandect/workflows/CI/badge.svg)](https://github.com/xsc/pandect/actions?query=workflow%3ACI)

__pandect__ is a fast and easy-to-use
[Message Digest](http://en.wikipedia.org/wiki/Message_digest),
[Checksum](http://en.wikipedia.org/wiki/Checksum),
[HMAC](https://en.wikipedia.org/wiki/Hash-based_message_authentication_code)
and [Signature](https://en.wikipedia.org/wiki/Digital_signature)
library for Clojure.

[![Build Status](https://travis-ci.org/xsc/pandect.svg?branch=master)](https://travis-ci.org/xsc/pandect)

## Usage

__Leiningen__ ([via Clojars](https://clojars.org/pandect))


[![Clojars Project](https://img.shields.io/clojars/v/pandect.svg)](https://clojars.org/pandect)

Note that - for versions 0.6.0 and up - to use functions based on the
BouncyCastle crypto provider, you have to manually include a version of
the `org.bouncycastle/bcprov-jdk15on` artifact. Additionally, you need to take
special care when trying to create an uberjar
([see here](#uberjars-and-bouncycastle)).
([see here](#uberjars-and-bouncycastle)).

__REPL__

Expand Down Expand Up @@ -193,7 +189,7 @@ __clj-message-digest__ | 112ms | 3.07ms | 4.59ms | 6.73ms | 5.17ms
```
MIT License

Copyright (c) 2014-2016 Yannick Scherer
Copyright (c) 2014-2021 Yannick Scherer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
48 changes: 25 additions & 23 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
(defproject pandect "0.6.2-SNAPSHOT"
(defproject pandect "1.0.0-SNAPSHOT"
:description "Message Digest and Checksum Library for Clojure"
:url "https://github.com/xsc/pandect"
:license {:name "MIT License"
:url "https://opensource.org/licenses/MIT"
:license {:name "MIT"
:comment "MIT License"
:url "https://choosealicense.com/licenses/mit"
:year 2014
:key "mit"}
:dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
[org.bouncycastle/bcprov-jdk15on "1.54" :scope "provided"]]
:exclusions [org.clojure/clojure]
:source-paths ["src/clojure" "target/generated"]
:java-source-paths ["src/java"]
:profiles {:dev {:plugins [[lein-codox "0.9.4"]]
:codox {:project {:name "pandect"}
:metadata {:doc/format :markdown}
:output-path "doc"
:namespaces [pandect.core
pandect.buffer
#"^pandect\.algo\.[a-z\-]+"]}}
:dependencies [[org.clojure/clojure "1.10.1" :scope "provided"]
[org.bouncycastle/bcprov-jdk15on "1.54" :scope "provided"]
^:inline-dep [potemkin "0.4.5"]
^:inline-dep [riddley "0.2.0"]]
:profiles {:dev
{:global-vars {*warn-on-reflection* true}}
:benchmark {:dependencies [[criterium "0.4.3"]
[clj-message-digest "1.0.0"]
[digest "1.4.4"]]
:source-paths ["shootout"]
:jvm-opts ^:replace ["-Xmx1g" "-server"]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0-alpha13"]]}}
:kaocha
{:dependencies [[lambdaisland/kaocha "1.0.732"
:exclusions [org.clojure/spec.alpha]]]}
:ci
[:kaocha
{:global-vars {*warn-on-reflection* false}}]}

:prep-tasks ["codegen"]
:aliases {"benchmark" ["with-profile" "dev,benchmark" "run" "-m"]
"codegen" ["run" "-m" "pandect.codegen"]
"all" ["with-profile" "+dev:+1.5:+1.6:+1.7:+1.9"]}
:prep-tasks [["codegen"]]
:plugins [[lein-isolate "0.2.2-SNAPSHOT"]]
:middleware [leiningen.isolate/middleware]

:aliases {"kaocha" ["with-profile" "+kaocha" "run" "-m" "kaocha.runner"]
"ci" ["with-profile" "+ci" "run" "-m" "kaocha.runner"
"--reporter" "documentation"]
"benchmark" ["with-profile" "dev,benchmark" "run" "-m"]
"codegen" ["run" "-m" "pandect.codegen"]}
:pedantic? :abort)
32 changes: 0 additions & 32 deletions src/clojure/pandect/core.clj

This file was deleted.

128 changes: 0 additions & 128 deletions src/clojure/pandect/utils/potemkin.clj

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

(defn -main
[& [base]]
(let [base (or base "target/generated")]
(let [base (or base "src")]
(println "[codegen] writing algorithms to:" base)
(generate-algo-namespaces! base)
(println "[codegen] done.")
Expand Down
49 changes: 49 additions & 0 deletions src/pandect/core.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
(ns ^{:doc "Digest Creation for Pandect"
:author "Yannick Scherer"}
pandect.core
(:require [pandect.buffer]
[potemkin :refer [import-vars]]
[pandect.codegen :refer [algorithms algorithm-namespace]]))

;; ## Re-export all algorithms

;; ### Helper

(defn- collect-algorithm-functions
[ns algorithm-symbol]
(require ns)
(let [s (name algorithm-symbol)]
(->> (ns-publics ns)
(map (comp first))
(filter #(.startsWith (name %) s)))))

;; ### Declare (necessary for clj-kondo to work)

(defn- create-declare
[]
`(~'declare ~'with-buffer-size
~@(->> (for [algo (algorithms)
:let [ns (algorithm-namespace algo)]]
(collect-algorithm-functions ns algo))
(apply concat))))

(comment
;; Create the 'declare' form by evaluting the following:
(create-declare))

(declare with-buffer-size ripemd256 ripemd256-hmac-file-bytes ripemd256-file ripemd256-hmac ripemd256-hmac-file ripemd256-hmac* ripemd256* ripemd256-hmac-bytes ripemd256-file-bytes ripemd256-hmac-file* ripemd256-bytes ripemd256-file* tiger tiger-file* tiger-hmac-bytes tiger-file tiger-hmac tiger-hmac-file-bytes tiger-file-bytes tiger-hmac* tiger-bytes tiger-hmac-file tiger* tiger-hmac-file* sha3-512 sha3-512-bytes sha3-512-file-bytes sha3-512* sha3-512-file* sha3-512-file keccak-384-file keccak-384-hmac* keccak-384 keccak-384-hmac-file keccak-384* keccak-384-bytes keccak-384-hmac-file-bytes keccak-384-file* keccak-384-file-bytes keccak-384-hmac-file* keccak-384-hmac keccak-384-hmac-bytes md5-file-bytes md5-hmac-bytes md5-hmac md5-rsa-verify-file md5-rsa* md5 md5-hmac-file* md5* md5-rsa-bytes md5-bytes md5-rsa-verify md5-rsa-file md5-file md5-hmac-file-bytes md5-rsa-file-bytes md5-rsa-file* md5-rsa md5-file* md5-hmac* md5-hmac-file ripemd128-hmac-file-bytes ripemd128 ripemd128-hmac ripemd128-file-bytes ripemd128-hmac-bytes ripemd128-hmac* ripemd128-hmac-file* ripemd128-file ripemd128-bytes ripemd128* ripemd128-file* ripemd128-hmac-file ripemd320-hmac-bytes ripemd320-hmac-file* ripemd320-hmac ripemd320 ripemd320-hmac* ripemd320-file ripemd320-hmac-file-bytes ripemd320-file* ripemd320-bytes ripemd320-hmac-file ripemd320* ripemd320-file-bytes siphash48-file siphash48-file-bytes siphash48-file* siphash48 siphash48-bytes siphash48* blake2b-384-file* blake2b-384-bytes blake2b-384* blake2b-384 blake2b-384-file blake2b-384-file-bytes sha3-224* sha3-224-bytes sha3-224-file* sha3-224-file-bytes sha3-224 sha3-224-file blake2b-512* blake2b-512-file* blake2b-512-file-bytes blake2b-512-bytes blake2b-512 blake2b-512-file sha3-384-file sha3-384 sha3-384* sha3-384-file* sha3-384-file-bytes sha3-384-bytes md2-rsa-file md2-bytes md2-rsa-verify md2-rsa* md2-rsa-file-bytes md2-rsa-bytes md2-file-bytes md2 md2-rsa-file* md2-rsa-verify-file md2* md2-file* md2-rsa md2-file whirlpool-hmac whirlpool-hmac* whirlpool-bytes whirlpool-hmac-bytes whirlpool-hmac-file* whirlpool whirlpool-file whirlpool* whirlpool-file* whirlpool-hmac-file whirlpool-hmac-file-bytes whirlpool-file-bytes blake2b-256* blake2b-256-bytes blake2b-256-file* blake2b-256-file blake2b-256-file-bytes blake2b-256 sha3-256-file-bytes sha3-256-file sha3-256-file* sha3-256 sha3-256-bytes sha3-256* siphash-file* siphash* siphash-file siphash siphash-bytes siphash-file-bytes keccak-224-file* keccak-224-hmac-file keccak-224-hmac* keccak-224-bytes keccak-224* keccak-224-hmac-file* keccak-224-file keccak-224-hmac keccak-224-file-bytes keccak-224 keccak-224-hmac-file-bytes keccak-224-hmac-bytes sha1-rsa sha1-rsa-file sha1-file sha1-rsa* sha1-dsa sha1-bytes sha1-hmac-file* sha1-dsa* sha1-hmac-bytes sha1-file* sha1-hmac-file-bytes sha1-hmac sha1-dsa-file* sha1-hmac* sha1-rsa-verify sha1* sha1 sha1-rsa-bytes sha1-dsa-bytes sha1-rsa-verify-file sha1-rsa-file-bytes sha1-rsa-file* sha1-dsa-file-bytes sha1-hmac-file sha1-dsa-verify sha1-dsa-verify-file sha1-file-bytes sha1-dsa-file sha224-hmac-file sha224-hmac sha224-bytes sha224-hmac* sha224-hmac-file* sha224-file sha224* sha224-file-bytes sha224-file* sha224-hmac-file-bytes sha224 sha224-hmac-bytes sha384-rsa sha384-rsa-verify-file sha384-rsa-verify sha384* sha384-hmac sha384-hmac-file sha384-hmac-file* sha384-rsa-file-bytes sha384-rsa* sha384-rsa-file* sha384-file-bytes sha384-file* sha384-rsa-bytes sha384-hmac-file-bytes sha384-file sha384 sha384-bytes sha384-hmac* sha384-rsa-file sha384-hmac-bytes keccak-256-bytes keccak-256-hmac* keccak-256-file* keccak-256* keccak-256-hmac keccak-256-hmac-file-bytes keccak-256-hmac-file keccak-256-file-bytes keccak-256-hmac-bytes keccak-256-hmac-file* keccak-256 keccak-256-file gost-file-bytes gost-hmac-file* gost-hmac* gost-hmac-bytes gost-bytes gost-hmac gost-hmac-file-bytes gost-file* gost* gost-hmac-file gost-file gost sha512-hmac-file-bytes sha512-rsa* sha512-bytes sha512-hmac sha512-rsa-file sha512-rsa-verify sha512-rsa-file* sha512-hmac* sha512-hmac-file sha512-hmac-file* sha512-file-bytes sha512-file* sha512-file sha512-rsa-file-bytes sha512 sha512-rsa-bytes sha512* sha512-hmac-bytes sha512-rsa sha512-rsa-verify-file crc32-file* crc32-bytes crc32-file-bytes crc32* crc32 crc32-file blake2b-160-bytes blake2b-160-file blake2b-160-file-bytes blake2b-160 blake2b-160* blake2b-160-file* ripemd160-hmac* ripemd160-file ripemd160-hmac-file* ripemd160-file-bytes ripemd160-file* ripemd160-hmac-file-bytes ripemd160-bytes ripemd160* ripemd160-hmac-file ripemd160-hmac-bytes ripemd160 ripemd160-hmac keccak-512-hmac-file-bytes keccak-512-hmac-file keccak-512-file-bytes keccak-512-file* keccak-512-hmac-bytes keccak-512-hmac* keccak-512-hmac-file* keccak-512-bytes keccak-512-hmac keccak-512* keccak-512-file keccak-512 sha256-hmac-bytes sha256-hmac-file sha256-file-bytes sha256-rsa* sha256-rsa sha256-hmac* sha256-hmac sha256* sha256-rsa-verify sha256-hmac-file-bytes sha256-rsa-file-bytes sha256-file* sha256-rsa-bytes sha256-bytes sha256-rsa-file* sha256-hmac-file* sha256-file sha256-rsa-file sha256 sha256-rsa-verify-file md4* md4-file md4-bytes md4-hmac* md4-hmac-file* md4-hmac md4-file-bytes md4-hmac-file-bytes md4-file* md4-hmac-file md4 md4-hmac-bytes adler32* adler32-bytes adler32-file* adler32-file adler32-file-bytes adler32)

;; ### Import Vars

(defmacro ^:private reexport-algos
[]
`(do
(import-vars pandect.buffer/with-buffer-size)
~@(for [algo (algorithms)
:let [ns (algorithm-namespace algo)]]
`(do
(require '~ns)
(import-vars
[~ns ~@(collect-algorithm-functions ns algo)])))))

(reexport-algos)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns ^:no-doc pandect.gen.core
(:import [java.io File FileInputStream InputStream]))
(:import [java.io File FileInputStream]))

;; ## Concept
;;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(:require [pandect.gen.core :as gen]
[pandect.impl.message-digest
[hmac :as hmac]
[hash :as hash]]
[pandect.utils.convert :as c]))
[hash :as hash]]))

;; ## Message Digest/HMAC Algorithms

Expand Down
Loading

0 comments on commit 2ca70a1

Please sign in to comment.