Skip to content

Commit

Permalink
feature/aitor/16kb compatible (#19)
Browse files Browse the repository at this point in the history
Task: https://app.asana.com/0/488551667048375/1209000029029646/f

### Description
Make builds 16KB compliant

This is needed to target Android 15

### Test
- [x] check out duckduckgo/Android#5204 
- [x] Build app (internal debug is fine)
- [x] smoke test sync feature
  • Loading branch information
aitorvs authored Jan 14, 2025
1 parent 51e23a2 commit 087d8b0
Show file tree
Hide file tree
Showing 29 changed files with 296 additions and 301 deletions.
5 changes: 4 additions & 1 deletion android/sync-crypto/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ add_library( # Sets the name of the library.
../../../../../native_lib/DDGSyncCrypto.h
)
target_include_directories(ddgcrypto PRIVATE ${CMAKE_SOURCE_DIR}/../../../../../native_lib/third-party/android.${SODIUM_ARCH}/include)
target_link_libraries(ddgcrypto sodium)
target_link_libraries(ddgcrypto sodium)

# Make sure ddgcrypto is 16KB compatible
target_link_options(ddgcrypto PRIVATE "-Wl,-z,max-page-size=16384")
4 changes: 2 additions & 2 deletions native_lib/third-party/android.arm64-v8a/include/sodium.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "sodium/crypto_hash_sha256.h"
#include "sodium/crypto_hash_sha512.h"
#include "sodium/crypto_kdf.h"
#include "sodium/crypto_kdf_hkdf_sha256.h"
#include "sodium/crypto_kdf_hkdf_sha512.h"
#include "sodium/crypto_kdf_blake2b.h"
#include "sodium/crypto_kx.h"
#include "sodium/crypto_onetimeauth.h"
Expand Down Expand Up @@ -59,8 +61,6 @@
# include "sodium/crypto_box_curve25519xchacha20poly1305.h"
# include "sodium/crypto_core_ed25519.h"
# include "sodium/crypto_core_ristretto255.h"
# include "sodium/crypto_kdf_hkdf_sha256.h"
# include "sodium/crypto_kdf_hkdf_sha512.h"
# include "sodium/crypto_scalarmult_ed25519.h"
# include "sodium/crypto_scalarmult_ristretto255.h"
# include "sodium/crypto_secretbox_xchacha20poly1305.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#define crypto_aead_aegis128l_H

#include <stddef.h>

#include "export.h"

#ifdef __cplusplus
# ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long"
# endif
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wlong-long"
#endif
extern "C" {
#endif

Expand All @@ -23,68 +24,66 @@ size_t crypto_aead_aegis128l_nsecbytes(void);
SODIUM_EXPORT
size_t crypto_aead_aegis128l_npubbytes(void);

#define crypto_aead_aegis128l_ABYTES 16U
#define crypto_aead_aegis128l_ABYTES 32U
SODIUM_EXPORT
size_t crypto_aead_aegis128l_abytes(void);

#define crypto_aead_aegis128l_MESSAGEBYTES_MAX \
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aegis128l_ABYTES, \
(1ULL << 61) - 1)
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aegis128l_ABYTES, (1ULL << 61) - 1)
SODIUM_EXPORT
size_t crypto_aead_aegis128l_messagebytes_max(void);

SODIUM_EXPORT
int crypto_aead_aegis128l_encrypt(unsigned char *c,
unsigned long long *clen_p,
int crypto_aead_aegis128l_encrypt(unsigned char *c,
unsigned long long *clen_p,
const unsigned char *m,
unsigned long long mlen,
unsigned long long mlen,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *nsec,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((nonnull(1, 8, 9)));
const unsigned char *k) __attribute__((nonnull(1, 8, 9)));

SODIUM_EXPORT
int crypto_aead_aegis128l_decrypt(unsigned char *m,
unsigned long long *mlen_p,
unsigned char *nsec,
int crypto_aead_aegis128l_decrypt(unsigned char *m,
unsigned long long *mlen_p,
unsigned char *nsec,
const unsigned char *c,
unsigned long long clen,
unsigned long long clen,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
const unsigned char *k) __attribute__((warn_unused_result))
__attribute__((nonnull(4, 8, 9)));

SODIUM_EXPORT
int crypto_aead_aegis128l_encrypt_detached(unsigned char *c,
unsigned char *mac,
unsigned long long *maclen_p,
int crypto_aead_aegis128l_encrypt_detached(unsigned char *c,
unsigned char *mac,
unsigned long long *maclen_p,
const unsigned char *m,
unsigned long long mlen,
unsigned long long mlen,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *nsec,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((nonnull(1, 2, 9, 10)));
__attribute__((nonnull(1, 2, 9, 10)));

SODIUM_EXPORT
int crypto_aead_aegis128l_decrypt_detached(unsigned char *m,
unsigned char *nsec,
int crypto_aead_aegis128l_decrypt_detached(unsigned char *m,
unsigned char *nsec,
const unsigned char *c,
unsigned long long clen,
unsigned long long clen,
const unsigned char *mac,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
__attribute__((warn_unused_result)) __attribute__((nonnull(3, 5, 8, 9)));

SODIUM_EXPORT
void crypto_aead_aegis128l_keygen(unsigned char k[crypto_aead_aegis128l_KEYBYTES])
__attribute__ ((nonnull));
__attribute__((nonnull));

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
#define crypto_aead_aegis256_H

#include <stddef.h>

#include "export.h"

#ifdef __cplusplus
# ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long"
# endif
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wlong-long"
#endif
extern "C" {
#endif

#define crypto_aead_aegis256_KEYBYTES 32U
#define crypto_aead_aegis256_KEYBYTES 32U
SODIUM_EXPORT
size_t crypto_aead_aegis256_keybytes(void);

Expand All @@ -23,68 +24,66 @@ size_t crypto_aead_aegis256_nsecbytes(void);
SODIUM_EXPORT
size_t crypto_aead_aegis256_npubbytes(void);

#define crypto_aead_aegis256_ABYTES 16U
#define crypto_aead_aegis256_ABYTES 32U
SODIUM_EXPORT
size_t crypto_aead_aegis256_abytes(void);

#define crypto_aead_aegis256_MESSAGEBYTES_MAX \
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aegis256_ABYTES, \
(1ULL << 61) - 1)
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aegis256_ABYTES, (1ULL << 61) - 1)
SODIUM_EXPORT
size_t crypto_aead_aegis256_messagebytes_max(void);

SODIUM_EXPORT
int crypto_aead_aegis256_encrypt(unsigned char *c,
unsigned long long *clen_p,
int crypto_aead_aegis256_encrypt(unsigned char *c,
unsigned long long *clen_p,
const unsigned char *m,
unsigned long long mlen,
unsigned long long mlen,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *nsec,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((nonnull(1, 8, 9)));
const unsigned char *k) __attribute__((nonnull(1, 8, 9)));

SODIUM_EXPORT
int crypto_aead_aegis256_decrypt(unsigned char *m,
unsigned long long *mlen_p,
unsigned char *nsec,
int crypto_aead_aegis256_decrypt(unsigned char *m,
unsigned long long *mlen_p,
unsigned char *nsec,
const unsigned char *c,
unsigned long long clen,
unsigned long long clen,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
const unsigned char *k) __attribute__((warn_unused_result))
__attribute__((nonnull(4, 8, 9)));

SODIUM_EXPORT
int crypto_aead_aegis256_encrypt_detached(unsigned char *c,
unsigned char *mac,
unsigned long long *maclen_p,
int crypto_aead_aegis256_encrypt_detached(unsigned char *c,
unsigned char *mac,
unsigned long long *maclen_p,
const unsigned char *m,
unsigned long long mlen,
unsigned long long mlen,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *nsec,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((nonnull(1, 2, 9, 10)));
__attribute__((nonnull(1, 2, 9, 10)));

SODIUM_EXPORT
int crypto_aead_aegis256_decrypt_detached(unsigned char *m,
unsigned char *nsec,
int crypto_aead_aegis256_decrypt_detached(unsigned char *m,
unsigned char *nsec,
const unsigned char *c,
unsigned long long clen,
unsigned long long clen,
const unsigned char *mac,
const unsigned char *ad,
unsigned long long adlen,
unsigned long long adlen,
const unsigned char *npub,
const unsigned char *k)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
__attribute__((warn_unused_result)) __attribute__((nonnull(3, 5, 8, 9)));

SODIUM_EXPORT
void crypto_aead_aegis256_keygen(unsigned char k[crypto_aead_aegis256_KEYBYTES])
__attribute__ ((nonnull));
__attribute__((nonnull));

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#ifndef crypto_onetimeauth_poly1305_H
#define crypto_onetimeauth_poly1305_H

#ifdef __cplusplus
# ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long"
# endif
extern "C" {
#endif

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -16,6 +9,13 @@ extern "C" {

#include "export.h"

#ifdef __cplusplus
# ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlong-long"
# endif
extern "C" {
#endif

typedef struct CRYPTO_ALIGN(16) crypto_onetimeauth_poly1305_state {
unsigned char opaque[256];
} crypto_onetimeauth_poly1305_state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int crypto_pwhash_str_needs_rehash(const char *str,
unsigned long long opslimit, size_t memlimit)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));

#define crypto_pwhash_PRIMITIVE "argon2i"
#define crypto_pwhash_PRIMITIVE "argon2id,argon2i"
SODIUM_EXPORT
const char *crypto_pwhash_primitive(void)
__attribute__ ((warn_unused_result));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "export.h"

#define SODIUM_VERSION_STRING "1.0.18"
#define SODIUM_VERSION_STRING "1.0.21"

#define SODIUM_LIBRARY_VERSION_MAJOR 11
#define SODIUM_LIBRARY_VERSION_MAJOR 28
#define SODIUM_LIBRARY_VERSION_MINOR 0


Expand Down
Binary file modified native_lib/third-party/android.arm64-v8a/libsodium.so
Binary file not shown.
4 changes: 2 additions & 2 deletions native_lib/third-party/android.armeabi-v7a/include/sodium.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "sodium/crypto_hash_sha256.h"
#include "sodium/crypto_hash_sha512.h"
#include "sodium/crypto_kdf.h"
#include "sodium/crypto_kdf_hkdf_sha256.h"
#include "sodium/crypto_kdf_hkdf_sha512.h"
#include "sodium/crypto_kdf_blake2b.h"
#include "sodium/crypto_kx.h"
#include "sodium/crypto_onetimeauth.h"
Expand Down Expand Up @@ -59,8 +61,6 @@
# include "sodium/crypto_box_curve25519xchacha20poly1305.h"
# include "sodium/crypto_core_ed25519.h"
# include "sodium/crypto_core_ristretto255.h"
# include "sodium/crypto_kdf_hkdf_sha256.h"
# include "sodium/crypto_kdf_hkdf_sha512.h"
# include "sodium/crypto_scalarmult_ed25519.h"
# include "sodium/crypto_scalarmult_ristretto255.h"
# include "sodium/crypto_secretbox_xchacha20poly1305.h"
Expand Down
Loading

0 comments on commit 087d8b0

Please sign in to comment.