Closed lvh closed 5 years ago
Is this what you have in mind?
(deftest decryption-fns-invalid-ciphertext-test
(let [decryption-fns (filter #(clojure.string/includes? (key %) "decrypt")
(ns-publics 'caesium.crypto.aead))
k (rb/randombytes 32)
ctext (rb/randombytes 16)
ad (rb/randombytes 12)
nonce (rb/randombytes 12)]
(doseq [[fn-name decryption-fn] decryption-fns]
(is (thrown? RuntimeException
(decryption-fn ctext ad nonce k))
(str "Function `" fn-name "` should throw an exception when given an invalid ciphertext.")))))
Sure yep that looks about right :)
Not sure how to really do this. I guess we could find e.g. decryption functions and verify functions and just feed them random garbage?