fixes rsa memory error: The FP_MAX_BITS constant was different in the wolfssl lib (8192) and in the wolfcrypt-jni (4096). The order of the includes affected the constant.

pull/2/merge
Moisés Guimarães 2016-03-04 16:43:15 -03:00
parent 73311405fd
commit 6f2ac81712
15 changed files with 80 additions and 48 deletions

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Aes.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Aes.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/aes.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Asn.h>
#include <wolfcrypt_jni_NativeStruct.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Asn.h>
#include <wolfcrypt_jni_NativeStruct.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/asn_public.h>
#include <wolfssl/wolfcrypt/error-crypt.h>

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Des3.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Des3.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/des3.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Dh.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Dh.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/dh.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Ecc.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Ecc.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/ecc.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,13 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_WolfCryptError.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_WolfCryptError.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
JNIEXPORT jstring JNICALL Java_com_wolfssl_wolfcrypt_WolfCryptError_wc_1GetErrorString
(JNIEnv* env, jclass obj, jint error)
{

View File

@ -19,16 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_WolfCrypt.h>
#include <com_wolfssl_wolfcrypt_Fips.h>
#include <wolfcrypt_jni_NativeStruct.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <stdio.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/fips_test.h>
#include <wolfssl/wolfcrypt/aes.h>

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Hmac.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Hmac.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/hmac.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,13 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Logging.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Logging.h>
#include <wolfssl/wolfcrypt/logging.h>
int wolfSSL_Debugging_ON(void);
void wolfSSL_Debugging_OFF(void);

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Md5.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Md5.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/md5.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_NativeStruct.h>
#include <wolfcrypt_jni_NativeStruct.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_NativeStruct.h>
#include <wolfcrypt_jni_NativeStruct.h>
#include <wolfssl/wolfcrypt/types.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Rng.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Rng.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/random.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */

View File

@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Rsa.h>
#include <wolfcrypt_jni_NativeStruct.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Rsa.h>
#include <wolfcrypt_jni_NativeStruct.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/rsa.h>
#include <wolfssl/wolfcrypt/error-crypt.h>

View File

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <com_wolfssl_wolfcrypt_Sha.h>
#include <wolfcrypt_jni_error.h>
#ifndef __ANDROID__
#include <wolfssl/options.h>
#endif
#include <com_wolfssl_wolfcrypt_Sha.h>
#include <wolfcrypt_jni_error.h>
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/sha512.h>

View File

@ -31,6 +31,11 @@ import com.wolfssl.wolfcrypt.Rsa;
public class RsaTest {
private ByteBuffer n = ByteBuffer
.allocateDirect(WolfCrypt.SIZE_OF_2048_BITS);
private ByteBuffer e = ByteBuffer
.allocateDirect(WolfCrypt.SIZE_OF_2048_BITS);
@Test
public void constructorShouldInitializeNativeStruct() {
assertNotEquals(NativeStruct.NULL, new Rsa().getNativeStruct());
@ -38,9 +43,35 @@ public class RsaTest {
@Test
public void decodeRawPublicKeyShouldNotRaiseExceptions() {
/*
* TODO Rsa init needed for this test.
*/
Rsa key = new Rsa();
n.put(Util
.h2b("aff5f9e2e2622320d44dbf54f2274a0f96fa7d70a63ddaa563f48811"
+ "43112bb3c36fe65ba0c9ad99d6fb6e53cb08e3938ee415b3a8cb"
+ "7f9602f2154fab83dd160fa6f509ba2c41295af9eea8787d333e"
+ "961461447fc60b3c61616ef5b94e822114e6fad44d1f2c476bc2"
+ "3bc03609e2e70a483d826409fdb7c50a91269a773976ef137e7f"
+ "a477c3951e8fbcb48f2378aa5e430e8c60b481beeb63df9abe10"
+ "c7ccf266e394fbd925e8725e4675fb6ad895caed4b31d751c871"
+ "2533e1c42ebefe9166e1aa20631521858c7548c61626ede105f2"
+ "812632bac96eb769c9be560beef4200b86409727a5a61d1cc583"
+ "1785ba4d42f02dd298a56bbbd6c479ce724d5bb5")).rewind();
e.put(Util
.h2b("00000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000d0ee61")).rewind();
assertEquals(WolfCrypt.SUCCESS, Fips.InitRsaKey_fips(key, null));
key.decodeRawPublicKey(n, n.limit(), e, e.limit());
assertEquals(WolfCrypt.SUCCESS, Fips.FreeRsaKey_fips(key));
}
@Test