remove argv0 from calls to jose

This commit is contained in:
Daniel Barlow 2024-08-28 11:16:43 +01:00
parent 74093b7ee3
commit 85071c88e7
1 changed files with 9 additions and 7 deletions

View File

@ -20,7 +20,8 @@
(fn jose [params inputstr] (fn jose [params inputstr]
(let [env (ll.environ) (let [env (ll.environ)
(pid in out) (popen2 (os.getenv "JOSE_BIN") params env)] argv (doto params (table.insert 1 "jose"))
(pid in out) (popen2 (os.getenv "JOSE_BIN") argv env)]
;; be careful if using this code for commands othert than jose: it ;; be careful if using this code for commands othert than jose: it
;; may deadlock if we write more than 8k and the command doesn't ;; may deadlock if we write more than 8k and the command doesn't
;; read it. ;; read it.
@ -47,7 +48,8 @@
(table.concat params " ") exitcode out))))) (table.concat params " ") exitcode out)))))
(fn has-key? [keys kid alg] (fn has-key? [keys kid alg]
(jose! ["jose" "jwk" "thp" "-i-" "-f" kid "-a" alg] (json.encode keys))) (jose! ["jwk" "thp" "-i-" "-f" kid "-a" alg] (json.encode keys)))
(fn search-key [keys kid] (fn search-key [keys kid]
(accumulate [ret nil (accumulate [ret nil
_ alg (ipairs thumbprint-algs) _ alg (ipairs thumbprint-algs)
@ -55,21 +57,21 @@
(or ret (has-key? keys kid alg)))) (or ret (has-key? keys kid alg))))
(fn jwk-generate [crv] (fn jwk-generate [crv]
(jose! ["jose" "jwk" "gen" "-i" (%% "{\"alg\":\"ECMR\",\"crv\":%q}" crv)] "")) (jose! ["jwk" "gen" "-i" (%% "{\"alg\":\"ECMR\",\"crv\":%q}" crv)] ""))
(fn jwk-pub [response] (fn jwk-pub [response]
(jose! ["jose" "jwk" "pub" "-i-"] (json.encode response))) (jose! ["jwk" "pub" "-i-"] (json.encode response)))
(fn jwk-exc-noi [clt eph] (fn jwk-exc-noi [clt eph]
(jose! ["jose" "jwk" "exc" "-l-" "-r-"] (jose! ["jwk" "exc" "-l-" "-r-"]
(.. (json.encode clt) " " (json.encode eph)))) (.. (json.encode clt) " " (json.encode eph))))
(fn jwk-exc [clt eph] (fn jwk-exc [clt eph]
(jose! ["jose" "jwk" "exc" "-i" "{\"alg\":\"ECMR\"}" "-l-" "-r-"] (jose! ["jwk" "exc" "-i" "{\"alg\":\"ECMR\"}" "-l-" "-r-"]
(.. (json.encode clt) " " (json.encode eph)))) (.. (json.encode clt) " " (json.encode eph))))
(fn jwe-dec [jwk ph undigested] (fn jwe-dec [jwk ph undigested]
(josep! [ "jwe" "dec" "-k-" "-i-"] (josep! ["jwe" "dec" "-k-" "-i-"]
(.. (json.encode jwk) ph "." undigested))) (.. (json.encode jwk) ph "." undigested)))
(fn parse-jwe [jwe] (fn parse-jwe [jwe]