From 66369003e6bb4801c2d10e4b2fc81036f3f7b80f Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Sun, 27 Sep 2020 19:48:14 +0200 Subject: [PATCH] Fix return type for randombytes_random and _uniform --- .../java/com/goterl/lazycode/lazysodium/LazySodium.java | 4 ++-- src/main/java/com/goterl/lazycode/lazysodium/Sodium.java | 4 ++-- .../com/goterl/lazycode/lazysodium/interfaces/Random.java | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/goterl/lazycode/lazysodium/LazySodium.java b/src/main/java/com/goterl/lazycode/lazysodium/LazySodium.java index 7d63694..1749ac8 100644 --- a/src/main/java/com/goterl/lazycode/lazysodium/LazySodium.java +++ b/src/main/java/com/goterl/lazycode/lazysodium/LazySodium.java @@ -147,7 +147,7 @@ private static byte[] hexToBytes(String s) { //// -------------------------------------------| @Override - public byte randomBytesRandom() { + public long randomBytesRandom() { return getSodium().randombytes_random(); } @@ -164,7 +164,7 @@ public byte[] nonce(int size) { } @Override - public byte randomBytesUniform(int upperBound) { + public long randomBytesUniform(int upperBound) { return getSodium().randombytes_uniform(upperBound); } diff --git a/src/main/java/com/goterl/lazycode/lazysodium/Sodium.java b/src/main/java/com/goterl/lazycode/lazysodium/Sodium.java index 2c89971..0450d3e 100644 --- a/src/main/java/com/goterl/lazycode/lazysodium/Sodium.java +++ b/src/main/java/com/goterl/lazycode/lazysodium/Sodium.java @@ -100,9 +100,9 @@ public native int sodium_base642bin(byte[] bin, //// RANDOM //// -------------------------------------------| - public native byte randombytes_random(); + public native long randombytes_random(); - public native byte randombytes_uniform(int upperBound); + public native long randombytes_uniform(int upperBound); public native void randombytes_buf(byte[] buffer, int size); diff --git a/src/main/java/com/goterl/lazycode/lazysodium/interfaces/Random.java b/src/main/java/com/goterl/lazycode/lazysodium/interfaces/Random.java index cfd0f01..becc6fc 100644 --- a/src/main/java/com/goterl/lazycode/lazysodium/interfaces/Random.java +++ b/src/main/java/com/goterl/lazycode/lazysodium/interfaces/Random.java @@ -13,10 +13,10 @@ public interface Random { /** - * Return a random byte 0 and 0xffffffff included. + * Return a unsigned int byte 0 and 0xffffffff included. * @return A random byte. */ - byte randomBytesRandom(); + long randomBytesRandom(); /** * Returns an unpredictable value between 0 and upperBound (excluded). @@ -24,9 +24,9 @@ public interface Random { * of the possible output values even when upper_bound is not a power of 2. Note * that an upper_bound less than 2 leaves only a single element to be chosen, namely 0. * @param upperBound - * @return A uniformally random bytes. + * @return A uniformly random unsigned int. */ - byte randomBytesUniform(int upperBound); + long randomBytesUniform(int upperBound); /** * Get a random number of bytes.