mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 04:01:46 +02:00
🎉 Add "sodi" vendor library for crypto primitives.
Will replace buddy-core, buddy-hashers and buddy-sign.
This commit is contained in:
parent
193c2026ba
commit
fe2c3aa8ad
8 changed files with 652 additions and 0 deletions
22
backend/vendor/sodi/tests/sodi/tests/test_pwhash.clj
vendored
Normal file
22
backend/vendor/sodi/tests/sodi/tests/test_pwhash.clj
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
(ns sodi.tests.test-pwhash
|
||||
(:require
|
||||
[clojure.test :as t]
|
||||
[clojure.test.check.clojure-test :refer [defspec]]
|
||||
[clojure.test.check.generators :as gen]
|
||||
[clojure.test.check.properties :as props]
|
||||
[sodi.pwhash :as pwh]))
|
||||
|
||||
(defspec derive-verify-roundtrip 1000
|
||||
(props/for-all
|
||||
[password gen/string]
|
||||
(let [pwhash (pwh/derive password {:cpucost 10})
|
||||
result (pwh/verify password pwhash)]
|
||||
(t/is (true? (:valid result))))))
|
||||
|
||||
(defspec derive-verify-roundtrip-invalid 1000
|
||||
(props/for-all
|
||||
[pw1 gen/string
|
||||
pw2 (gen/such-that #(not= % pw1) gen/string)]
|
||||
(let [pwhash (pwh/derive pw1 {:cpucost 10})
|
||||
result (pwh/verify pw2 pwhash)]
|
||||
(t/is (false? (:valid result))))))
|
31
backend/vendor/sodi/tests/user.clj
vendored
Normal file
31
backend/vendor/sodi/tests/user.clj
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns user
|
||||
(:require
|
||||
[clojure.tools.namespace.repl :as repl]
|
||||
[clojure.walk :refer [macroexpand-all]]
|
||||
[clojure.pprint :refer [pprint]]
|
||||
[clojure.test :as test]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.repl :refer :all]))
|
||||
|
||||
(defn run-tests
|
||||
([] (run-tests #"^sodi.tests.*"))
|
||||
([o]
|
||||
;; (repl/refresh)
|
||||
(cond
|
||||
(instance? java.util.regex.Pattern o)
|
||||
(test/run-all-tests o)
|
||||
|
||||
(symbol? o)
|
||||
(if-let [sns (namespace o)]
|
||||
(do (require (symbol sns))
|
||||
(test/test-vars [(resolve o)]))
|
||||
(test/test-ns o)))))
|
Loading…
Add table
Add a link
Reference in a new issue