lib.openpgp

crc-24

added in 3.0

(crc-24 input)

returns the crc24 checksum

(crc-24 (byte-array 100 100 100 100 100 100)) => [“=6Fko” -24 89 40 15227176]

decrypt

added in 3.0

(decrypt encrypted {:keys [private]})

decrypts the encrypted information

(-> (.getBytes “Hello World”) (encrypt {:public +public-key+}) ^bytes (decrypt {:private +private-key+}) (String.)) => “Hello World”

encrypt

added in 3.0

(encrypt clear {:keys [public]})

encrypts bytes given a public key

(->> (encrypt (.getBytes “Hello World”) {:public +public-key+})

(encode/to-base64))

fingerprint

added in 3.0

(fingerprint pub)

returns the fingerprint of a public key

(fingerprint +public-key+) => “E710D59C5346D3C0A1C578AE6753F8E16D35FC24”

generate-signature

added in 3.0

(generate-signature bytes {:keys [public private]})

generates a signature given bytes and a keyring

(generate-signature (.getBytes “Hello World”) {:public +public-key+ :private +private-key+}) ;; #gpg.signature "iQEcBAABCAAGBQJbw1U8AAoJEGdT+OFtNf… " => org.bouncycastle.openpgp.PGPSignature

key-pair

added in 3.0

(key-pair secret-key)

parse-public-key

added in 3.0

(parse-public-key input)(parse-public-key input id)

parses a public key from string

(-> (str/joinl +public-key-string+ “\n”) (parse-public-key)) ;; #public “E710D59C5346D3C0A1C578AE6753F8E16D35FC24” => org.bouncycastle.openpgp.PGPPublicKey

parse-public-key-ring

added in 3.0

(parse-public-key-ring input)

parses a public key ring from string

(-> (str/joinl +public-key-string+ “\n”) (parse-public-key-ring)) => org.bouncycastle.openpgp.PGPPublicKeyRing

parse-secret-key

added in 3.0

(parse-secret-key input)(parse-secret-key input id)

parses a secret key from string

(-> (str/joinl +secret-key-string+ “\n”) (parse-secret-key)) ;; #secret “E710D59C5346D3C0A1C578AE6753F8E16D35FC24” => org.bouncycastle.openpgp.PGPSecretKey

parse-secret-key-ring

added in 3.0

(parse-secret-key-ring input)

parses a secret key ring from string

(-> (str/joinl +secret-key-string+ “\n”) (parse-secret-key-ring)) => org.bouncycastle.openpgp.PGPSecretKeyRing

pgp-signature

added in 3.0

(pgp-signature bytes)

returns a gpg signature from encoded bytes

(-> (generate-signature (.getBytes “Hello World”) {:public +public-key+ :private +private-key+}) (.getEncoded) (pgp-signature)) => org.bouncycastle.openpgp.PGPSignature

read-sig-file

added in 3.0

(read-sig-file sig-file)

reads bytes from a GPG compatible file

(read-sig-file “test-scratch/project.clj.asc”) => bytes?

sign

added in 3.0

(sign input sig-file {:keys [public private], :as opts})

generates a output gpg signature for an input file

(sign “project.clj” “test-scratch/project.clj.asc” {:public +public-key+ :private +private-key+}) => bytes?

verify

added in 3.0

(verify input sig-file {:keys [public]})

verifies that the signature works

(verify “project.clj” “test-scratch/project.clj.asc” {:public +public-key+}) => true

write-sig-file

added in 3.0

(write-sig-file sig-file bytes)

writes bytes to a GPG compatible file

(let signature (-> (generate-signature (.getBytes “Hello World”) {:public +public-key+ :private +private-key+}) (.getEncoded)) (write-sig-file “test-scratch/project.clj.asc” signature))