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.
The named curve of each object identifier of an EC key's curve.
The named curve of each object identifier of an EC key's curve.
(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.
(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))(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:
The map also has the :kind of key, :rsa, :ec or :ed25519, and the :named-curve of an EC key, e.g. :p-256, when the library knows them. They tell which algorithm to import a key for, since import-key needs one. 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
The map also has the :kind of key, :rsa, :ec or :ed25519, and the
:named-curve of an EC key, e.g. :p-256, when the library knows them. They
tell which algorithm to import a key for, since import-key needs one. 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 kind of key of each object identifier of an algorithm of SPKI and PKCS#8 that key-data names.
The kind of key of each object identifier of an algorithm of SPKI and PKCS#8 that key-data names.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |