Mercurial > prosody-modules
comparison mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua @ 4333:97f369745ec7
mod_cloud_notify_encrypted: Use new direct access to notification element
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 13 Jan 2021 15:01:59 +0000 |
| parents | 2e355540f8c8 |
| children | 41ac0941b217 |
comparison
equal
deleted
inserted
replaced
| 4332:7a5ca4b285cb | 4333:97f369745ec7 |
|---|---|
| 92 -- FIXME: luaossl does not expose the EVP_CTRL_GCM_GET_TAG API, so we append 16 NUL bytes | 92 -- FIXME: luaossl does not expose the EVP_CTRL_GCM_GET_TAG API, so we append 16 NUL bytes |
| 93 -- Siskin does not validate the tag anyway. | 93 -- Siskin does not validate the tag anyway. |
| 94 local encrypted_payload = base64.encode(ciphers.new("AES-128-GCM"):encrypt(key_binary, iv):final(push_json)..string.rep("\0", 16)); | 94 local encrypted_payload = base64.encode(ciphers.new("AES-128-GCM"):encrypt(key_binary, iv):final(push_json)..string.rep("\0", 16)); |
| 95 local encrypted_element = st.stanza("encrypted", { xmlns = xmlns_push_encrypt, iv = base64.encode(iv) }) | 95 local encrypted_element = st.stanza("encrypted", { xmlns = xmlns_push_encrypt, iv = base64.encode(iv) }) |
| 96 :text(encrypted_payload); | 96 :text(encrypted_payload); |
| 97 -- Replace the unencrypted notification with the encrypted one | 97 -- Replace the unencrypted notification data with the encrypted one |
| 98 event.notification_stanza | 98 event.notification_payload |
| 99 :get_child("pubsub", "http://jabber.org/protocol/pubsub") | 99 :remove_children("x", "jabber:x:data") |
| 100 :get_child("publish") | 100 :add_child(encrypted_element); |
| 101 :get_child("item") | |
| 102 :remove_children("notification", xmlns_push) | |
| 103 :tag("notification", { xmlns = xmlns_push }) | |
| 104 :add_child(encrypted_element) | |
| 105 :up(); | |
| 106 end | 101 end |
| 107 | 102 |
| 108 module:hook("cloud_notify/registration", handle_register); | 103 module:hook("cloud_notify/registration", handle_register); |
| 109 module:hook("cloud_notify/push", handle_push); | 104 module:hook("cloud_notify/push", handle_push); |
