diff --git a/README.md b/README.md index 04f0fe8..a30883c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ import { crypto_box_open_easy, crypto_box_PUBLICKEYBYTES, crypto_box_SECRETKEYBYTES, + crypto_kdf_CONTEXTBYTES, crypto_kdf_derive_from_key, crypto_kdf_KEYBYTES, crypto_kdf_keygen, diff --git a/cpp/react-native-libsodium.cpp b/cpp/react-native-libsodium.cpp index ff4645e..b12f2f3 100644 --- a/cpp/react-native-libsodium.cpp +++ b/cpp/react-native-libsodium.cpp @@ -25,6 +25,7 @@ void installLibsodium(jsi::Runtime &jsiRuntime) jsiRuntime.global().setProperty(jsiRuntime, "jsi_crypto_kdf_KEYBYTES", (int)crypto_kdf_KEYBYTES); jsiRuntime.global().setProperty(jsiRuntime, "jsi_crypto_pwhash_BYTES_MAX", (int)crypto_pwhash_BYTES_MAX); jsiRuntime.global().setProperty(jsiRuntime, "jsi_crypto_pwhash_BYTES_MIN", (int)crypto_pwhash_BYTES_MIN); + jsiRuntime.global().setProperty(jsiRuntime, "jsi_crypto_kdf_CONTEXTBYTES", (int)crypto_kdf_CONTEXTBYTES); auto jsi_from_base64_to_arraybuffer = jsi::Function::createFromHostFunction( jsiRuntime, diff --git a/example/src/App.tsx b/example/src/App.tsx index 08cab7c..d2a5091 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -13,6 +13,7 @@ import sodium, { crypto_box_open_easy, crypto_box_PUBLICKEYBYTES, crypto_box_SECRETKEYBYTES, + crypto_kdf_CONTEXTBYTES, crypto_kdf_derive_from_key, crypto_kdf_KEYBYTES, crypto_kdf_keygen, @@ -69,8 +70,13 @@ function LibsodiumTests() { crypto_kdf_KEYBYTES, crypto_pwhash_BYTES_MIN, crypto_pwhash_BYTES_MAX, + crypto_kdf_CONTEXTBYTES, }); + if (crypto_kdf_CONTEXTBYTES !== 8) { + throw new Error('crypto_kdf_CONTEXTBYTES not properly exported'); + } + const randombytes_buf_1 = randombytes_buf(1); const randombytes_buf_3 = randombytes_buf(3); const randombytes_buf_9 = randombytes_buf(9); diff --git a/src/index.tsx b/src/index.tsx index 261e19b..72c006e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -31,6 +31,7 @@ declare global { var jsi_crypto_kdf_KEYBYTES: number; var jsi_crypto_pwhash_BYTES_MIN: number; var jsi_crypto_pwhash_BYTES_MAX: number; + var jsi_crypto_kdf_CONTEXTBYTES: number; function jsi_from_base64_to_arraybuffer( input: string, @@ -176,6 +177,7 @@ export const crypto_aead_xchacha20poly1305_ietf_NPUBBYTES = export const crypto_kdf_KEYBYTES = global.jsi_crypto_kdf_KEYBYTES; export const crypto_pwhash_BYTES_MIN = global.jsi_crypto_pwhash_BYTES_MIN; export const crypto_pwhash_BYTES_MAX = global.jsi_crypto_pwhash_BYTES_MAX; +export const crypto_kdf_CONTEXTBYTES = global.jsi_crypto_kdf_CONTEXTBYTES; export const from_base64 = ( input: string, @@ -668,6 +670,7 @@ export default { crypto_box_PUBLICKEYBYTES, crypto_box_SECRETKEYBYTES, crypto_kdf_derive_from_key, + crypto_kdf_CONTEXTBYTES, crypto_kdf_KEYBYTES, crypto_kdf_keygen, crypto_pwhash,