From eafe364f052f0959ba282175328d3590de5886ce Mon Sep 17 00:00:00 2001 From: Yannick Scherer Date: Tue, 17 Sep 2024 14:23:41 +0200 Subject: [PATCH] Print unimplemented algorithms after codegen --- src/pandect/codegen.clj | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/pandect/codegen.clj b/src/pandect/codegen.clj index 157a7ec..e1538c7 100644 --- a/src/pandect/codegen.clj +++ b/src/pandect/codegen.clj @@ -1,12 +1,14 @@ (ns ^:no-doc pandect.codegen (:require [clojure.pprint :refer [pprint]] [clojure.java.io :refer [file writer]] + [clojure.string :as str] [pandect.impl message-digest checksum bouncy-castle] [pandect.gen [core :refer [generate get-code-generators as-sym]] [hash-generator :refer [hash-generator]] [hmac-generator :refer [hmac-generator]] - [signature-generator :refer [signature-generator]]])) + [signature-generator :refer [signature-generator]]]) + (:import (java.security Security))) (def ^:private algorithms-names (-> '{gost "GOST3411" @@ -98,16 +100,13 @@ (for [length [384 512 1024]] [(as-sym 'skein1024- length) (str "SKEIN-1024-" length)])))) - -(defn missing-algorithms +(defn- missing-algorithms [] - (->> (java.security.Security/getAlgorithms "MessageDigest") - (remove #(re-matches #"^.*\d\.\d.+" %)) - (remove (comp (set (sort (map clojure.string/lower-case (vals algorithms-names)))) - clojure.string/lower-case)) - (sort))) - -(missing-algorithms) + (require 'pandect.utils.bouncy-castle-provider) + (let [implemented (set (map str/lower-case (vals algorithms-names))) + available (->> (Security/getAlgorithms "MessageDigest") + (remove #(re-matches #"^.*\d\.\d.+" %)))] + (remove (comp implemented str/lower-case) available))) (def ^:private generators [hash-generator @@ -163,4 +162,6 @@ (println "[codegen] writing algorithms to:" base) (generate-algo-namespaces! base) (println "[codegen] done.") + (when-let [algos (seq (missing-algorithms))] + (println "[codegen] Unimplemented:" (str/join ", " algos))) (shutdown-agents)))