Liking cljdoc? Tell your friends :D
All platforms.

dk.simongray.webcrypto.pem

Keys in PEM (RFC 7468): the base64 of their DER between a BEGIN line and an END line with a label, e.g. PUBLIC KEY, as OpenSSL writes them.

WebCrypto only imports SPKI and PKCS#8, so key-data turns the older PKCS#1 and SEC1 keys into those, without any cryptography.

Keys in PEM (RFC 7468): the base64 of their DER between a BEGIN line and
an END line with a label, e.g. PUBLIC KEY, as OpenSSL writes them.

WebCrypto only imports SPKI and PKCS#8, so key-data turns the older
PKCS#1 and SEC1 keys into those, without any cryptography.
raw docstring

decodeclj/s

(decode s)

The blocks of PEM in the text s, in order, as maps of their :label and their :der as bytes. Text around the blocks, e.g. a comment, doesn't count, and neither does a block whose base64 isn't valid.

The blocks of PEM in the text `s`, in order, as maps of their :label and
their :der as bytes. Text around the blocks, e.g. a comment, doesn't count,
and neither does a block whose base64 isn't valid.
sourceraw docstring

encodeclj/s

(encode label der)

The PEM of the DER bytes der under the label, e.g. PUBLIC KEY, in lines of 64 characters.

(encode "PUBLIC KEY" (webcrypto/export-key :spki public-key))
The PEM of the DER bytes `der` under the `label`, e.g. PUBLIC KEY, in
lines of 64 characters.

    (encode "PUBLIC KEY" (webcrypto/export-key :spki public-key))
sourceraw docstring

key-dataclj/s

(key-data s)

The first key in the PEM text s as the :format and :data that import-key takes, or nil when it holds no key. The labels are these:

  • PUBLIC KEY and PRIVATE KEY, SPKI and PKCS#8 as they are, but for keys of RSASSA-PSS, whose algorithm becomes rsaEncryption as WebCrypto needs
  • RSA PUBLIC KEY and RSA PRIVATE KEY of PKCS#1, which become SPKI and PKCS#8
  • EC PRIVATE KEY of SEC1, which becomes PKCS#8

A key that isn't valid DER throws data-error.

(let [{:keys [format data]} (key-data (slurp "key.pem"))]
  (webcrypto/import-key format data {:name :ecdsa :named-curve :p-256}
                        false [:sign]))
The first key in the PEM text `s` as the :format and :data that
import-key takes, or nil when it holds no key. The labels are these:

- PUBLIC KEY and PRIVATE KEY, SPKI and PKCS#8 as they are, but for keys
  of RSASSA-PSS, whose algorithm becomes rsaEncryption as WebCrypto needs
- RSA PUBLIC KEY and RSA PRIVATE KEY of PKCS#1, which become SPKI and
  PKCS#8
- EC PRIVATE KEY of SEC1, which becomes PKCS#8

A key that isn't valid DER throws data-error.

    (let [{:keys [format data]} (key-data (slurp "key.pem"))]
      (webcrypto/import-key format data {:name :ecdsa :named-curve :p-256}
                            false [:sign]))
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close