Skip to content

Add OAEP notification encryption#4103

Open
mpivchev wants to merge 1 commit intomasterfrom
oaep-notifs
Open

Add OAEP notification encryption#4103
mpivchev wants to merge 1 commit intomasterfrom
oaep-notifs

Conversation

@mpivchev
Copy link
Copy Markdown
Collaborator

@mpivchev mpivchev commented May 7, 2026

Implements: nextcloud/files-clients#124

First tries to decrypt with RSA PKCS#1 v1.5, then OAEP.

Tested on local instance with both encryption methods.

Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates push-notification payload decryption to support RSA OAEP in addition to the existing RSA PKCS#1 v1.5 scheme, aligning the iOS client with the “OAEP notification encryption” feature request.

Changes:

  • Attempt RSA PKCS#1 v1.5 decryption first, then fall back to RSA OAEP decryption.
  • Treat non-UTF8 decrypted bytes as a decryption failure and retry with OAEP.
Comments suppressed due to low confidence (1)

iOSClient/PushNotification/NCPushNotificationEncryption.m:135

  • The cleanup at the end uses free(bio) and free(rsa), but these are OpenSSL-allocated types that should be released with the matching OpenSSL APIs (e.g., BIO_free and RSA_free / EVP_PKEY_free). Using free() here can leak internal allocations and can be unsafe across OpenSSL builds. Also consider freeing the EVP_PKEY *pkey you created earlier to avoid leaking it on success.
    if (decrypted)
        free(decrypted);
    free(bio);
    free(rsa);
    

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread iOSClient/PushNotification/NCPushNotificationEncryption.m
Comment thread iOSClient/PushNotification/NCPushNotificationEncryption.m
if(decrypted_length == -1) {
NSString *decryptString = decrypted_length == -1 ? nil : [[NSString alloc] initWithBytes:decrypted length:decrypted_length encoding:NSUTF8StringEncoding];

// Try decrypting with RSA OAEP padding
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since oaep will be the future, please switch it around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants