Skip to content
Docs

Encryption

Hide push content from Apple, Google, and the Opush server with shared-key or end-to-end encryption.

A normal push passes through Opush and through Apple's or Google's push service in plain text. Encryption hides the content on the way. Only your devices can read it.

Opush has three options:

OptionWho encryptsWho can read it
Shared-key encryptionYour script, with an AES keyAnyone with the key
Server encryptionThe Opush server, with a key your device setYour devices (the server sees plain text when it arrives)
End-to-end encryptionYour script, with your device's public keyOnly the device that holds the private key

Shared-key encryption

This is the common way to encrypt pushes. If you already have a script that sends ciphertext, change the server and key and it works.

  1. Open the encryption settings in the Opush app. Pick an algorithm and a key. New users get AES-256-GCM with a key the app creates for you.
  2. In your script, write the push parameters as JSON, for example {"title":"Login code","body":"381920","copy":"381920"}.
  3. Encrypt the JSON with the same algorithm and key, then base64 the result.
  4. Send it as ciphertext, with iv for GCM and CBC.

Algorithms

AlgorithmKeyIV
AES-128-GCM / AES-192-GCM / AES-256-GCM16 / 24 / 32 characters12 characters
AES-128-CBC / AES-192-CBC / AES-256-CBC16 / 24 / 32 characters16 characters, PKCS#7 padding
AES-128-ECB / AES-192-ECB / AES-256-ECB16 / 24 / 32 charactersNot used
  • The key and IV are plain ASCII strings, used as bytes directly. They are not hex.
  • For GCM, ciphertext is base64 of the encrypted bytes followed by the 16-byte authentication tag.
  • If a push has no iv, the app uses the IV saved in its encryption settings.

Use a new IV for every push

Reusing an IV with GCM can leak your content. Generate a random IV for each push and send it as iv. ECB is not secure. It exists only for old scripts.

Examples

KEY='your16charkey123'          # AES-128-CBC: 16 characters
IV=$(openssl rand -hex 8)        # 16 characters
JSON='{"title":"Login code","body":"381920","copy":"381920"}'

CIPHERTEXT=$(printf '%s' "$JSON" | openssl enc -aes-128-cbc \
  -K "$(printf '%s' "$KEY" | xxd -p -c 256)" \
  -iv "$(printf '%s' "$IV" | xxd -p -c 256)" | openssl base64 -A)

curl https://opu.sh/YOUR_KEY \
  --data-urlencode "ciphertext=$CIPHERTEXT" \
  --data-urlencode "iv=$IV"

openssl enc can't do GCM, so this example uses CBC. Set the app to the same algorithm.

What goes inside, what stays outside

You can put any parameter inside the encrypted JSON: content, sound, badge, call, action, isArchive, ttl, buttons, and so on. The app applies them after it decrypts. Values inside the JSON override the same values outside.

Some parameters must stay outside in plain text, because the server needs them to deliver the push:

ParameterWhy
device_key, device_keysThe server needs to know where to send it
id, deleteThey decide which notification to replace or recall
level, volumeThey set the interruption level and critical sound
at, delay, repeat, tzThe server holds scheduled pushes until it's time
call, voice, sms, phone, escalate, escalate_afterThe server places calls and texts

Apple and Google only see a placeholder text ("You received an encrypted message"). The app replaces it with the real content after it decrypts. If decryption fails, the notification says so. Check that the algorithm, key, and IV match.

Server encryption

If your tool can't encrypt (for example, it only takes a URL), let the server do it. Turn on Server encryption in the app's encryption settings. From then on, Opush encrypts every plain-text push to that device before it hands it to Apple or Google.

  • Supported: AES-128-GCM, AES-256-GCM, AES-128-CBC, AES-256-CBC, and your end-to-end public key. ECB and 192-bit keys are not available here.
  • Encrypted fields: title, subtitle, body, markdown, url, copy, icon, image, action, and buttons (button URLs often carry tokens). Fields like group, sound, badge, level, and id stay outside.
  • The server makes a new random IV for every push.
  • Pushes that already have ciphertext or sealed are not encrypted again. Recalls are not encrypted.

The server still sees the plain text at the moment it receives it. If you don't want the server to see your content at all, encrypt in your script.

End-to-end encryption (HPKE)

With a shared key, anyone who gets the key can read every push: your script, a relay, or a leaked config file. End-to-end encryption uses a key pair instead. Scripts and the server only get the public key. Only the device with the private key can open the push.

  1. In the app's encryption settings, open End-to-end encryption and tap Create a key pair. The private key stays in the device's keychain.
  2. Share the public key with your script. It's base64 of a 65-byte uncompressed P-256 point (starts with 0x04). You can also export it as PEM.
  3. Seal the parameter JSON with the public key and send it as sealed.
SchemeHPKE (RFC 9180), base mode
KEM / KDF / AEADDHKEM(P-256, HKDF-SHA256) / HKDF-SHA256 / AES-256-GCM
infoopush v1 (UTF-8)
AADNone
sealedbase64(enc ‖ ciphertext), where enc is the 65-byte encapsulated key

The plain text is the same parameter JSON as ciphertext, and the same rules apply for what stays outside. If a push has both sealed and ciphertext, Opush uses sealed.

import { Aes256Gcm, CipherSuite, DhkemP256HkdfSha256, HkdfSha256 } from "@hpke/core";

const PUBLIC_KEY = "BASE64_PUBLIC_KEY_FROM_THE_APP";

const suite = new CipherSuite({ kem: new DhkemP256HkdfSha256(), kdf: new HkdfSha256(), aead: new Aes256Gcm() });
const recipient = await suite.kem.deserializePublicKey(Buffer.from(PUBLIC_KEY, "base64"));
const sender = await suite.createSenderContext({ recipientPublicKey: recipient, info: new TextEncoder().encode("opush v1") });
const ct = await sender.seal(new TextEncoder().encode(JSON.stringify({ title: "Login code", body: "381920" })));
const sealed = Buffer.concat([Buffer.from(sender.enc), Buffer.from(ct)]).toString("base64");

await fetch("https://opu.sh/push", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ device_key: "YOUR_KEY", sealed }),
});

Python and Go have HPKE libraries too. Use the same suite and info.

More than one device

Each device makes its own key pair. To read the same pushes on several devices, export the private key from one device and import it on the others (PEM, base64 DER, or the raw 32-byte key in base64).

In the app

  • Server encryption with your public key: pick the public key as the server encryption method. The server stores only the public key, so even a database leak can't open past pushes.
  • Send tab: when you add a recipient with a public key, the app seals each push on your phone before sending it. The server only sees sealed.
  • Receive tab: the "let others push to you" QR code and link include your public key when you have a key pair. Apple Watch seals pushes the same way.

Limits

  • Live progress can't be encrypted. The Lock Screen card has no way to decrypt it.
  • An encrypted push still has to fit the 4096-byte push size limit after base64.
  • SMS for a push you encrypted yourself (ciphertext or sealed) only says that you have a new encrypted push. With server encryption, the server writes the text before it encrypts the push, so the text includes the title and body. Leave out sms=1 if that content shouldn't go out by text.