Skip to main content

Module webpush

Module webpush 

Source
Expand description

RFC 8291 Web Push message encryption, aes128gcm (RFC 8188), one record.

The sender encrypts straight to the device’s subscription keys, so the pusher forwards bytes it cannot open. Every body is padded to BODY_LEN, so its size says nothing about the message inside.

Constants§

BODY_LEN
Small enough for every push service, Firefox for Android’s (about 3015) included.
HEADER_LEN
Salt (16), record size (4), key id length (1), the sender’s public key (65).
MAX_PLAINTEXT
What fits once the header, the tag and the padding delimiter are paid for.

Functions§

decrypt
Open a body with the subscription’s private key: what a browser or the UnifiedPush connector does on receipt. Here for tests and for native receivers.
encrypt
Encrypt plaintext to a subscription’s p256dh key and auth secret.