remove BLAKE2b, fix hash algo conditional compiles
parent
38c4857d6e
commit
b6d982a7fc
|
@ -176,6 +176,7 @@
|
||||||
description="Generate javah headers">
|
description="Generate javah headers">
|
||||||
<javah destdir="${jni.dir}" force="yes" classpathref="classpath">
|
<javah destdir="${jni.dir}" force="yes" classpathref="classpath">
|
||||||
<class name="com.wolfssl.wolfcrypt.WolfCrypt" />
|
<class name="com.wolfssl.wolfcrypt.WolfCrypt" />
|
||||||
|
<class name="com.wolfssl.wolfcrypt.FeatureDetect" />
|
||||||
<class name="com.wolfssl.wolfcrypt.Fips" />
|
<class name="com.wolfssl.wolfcrypt.Fips" />
|
||||||
<class name="com.wolfssl.wolfcrypt.NativeStruct" />
|
<class name="com.wolfssl.wolfcrypt.NativeStruct" />
|
||||||
<class name="com.wolfssl.wolfcrypt.Aes" />
|
<class name="com.wolfssl.wolfcrypt.Aes" />
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class com_wolfssl_wolfcrypt_FeatureDetect */
|
||||||
|
|
||||||
|
#ifndef _Included_com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
#define _Included_com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
* Method: Md5Enabled
|
||||||
|
* Signature: ()Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Md5Enabled
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
* Method: ShaEnabled
|
||||||
|
* Signature: ()Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_ShaEnabled
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
* Method: Sha256Enabled
|
||||||
|
* Signature: ()Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Sha256Enabled
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
* Method: Sha384Enabled
|
||||||
|
* Signature: ()Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Sha384Enabled
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_wolfssl_wolfcrypt_FeatureDetect
|
||||||
|
* Method: Sha512Enabled
|
||||||
|
* Signature: ()Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Sha512Enabled
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class com_wolfssl_wolfcrypt_Hmac_hashType */
|
||||||
|
|
||||||
|
#ifndef _Included_com_wolfssl_wolfcrypt_Hmac_hashType
|
||||||
|
#define _Included_com_wolfssl_wolfcrypt_Hmac_hashType
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -9,6 +9,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#undef com_wolfssl_wolfcrypt_WolfCrypt_SUCCESS
|
#undef com_wolfssl_wolfcrypt_WolfCrypt_SUCCESS
|
||||||
#define com_wolfssl_wolfcrypt_WolfCrypt_SUCCESS 0L
|
#define com_wolfssl_wolfcrypt_WolfCrypt_SUCCESS 0L
|
||||||
|
#undef com_wolfssl_wolfcrypt_WolfCrypt_FAILURE
|
||||||
|
#define com_wolfssl_wolfcrypt_WolfCrypt_FAILURE -1L
|
||||||
#undef com_wolfssl_wolfcrypt_WolfCrypt_SIZE_OF_128_BITS
|
#undef com_wolfssl_wolfcrypt_WolfCrypt_SIZE_OF_128_BITS
|
||||||
#define com_wolfssl_wolfcrypt_WolfCrypt_SIZE_OF_128_BITS 16L
|
#define com_wolfssl_wolfcrypt_WolfCrypt_SIZE_OF_128_BITS 16L
|
||||||
#undef com_wolfssl_wolfcrypt_WolfCrypt_SIZE_OF_160_BITS
|
#undef com_wolfssl_wolfcrypt_WolfCrypt_SIZE_OF_160_BITS
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/* jni_feature_detect.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
#include <wolfssl/options.h>
|
||||||
|
#endif
|
||||||
|
#include <jni.h>
|
||||||
|
#include <wolfcrypt_jni_debug.h>
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Md5Enabled
|
||||||
|
(JNIEnv* env, jclass jcl)
|
||||||
|
{
|
||||||
|
(void)env;
|
||||||
|
(void)jcl;
|
||||||
|
#ifndef NO_MD5
|
||||||
|
return JNI_TRUE;
|
||||||
|
#else
|
||||||
|
return JNI_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_ShaEnabled
|
||||||
|
(JNIEnv* env, jclass jcl)
|
||||||
|
{
|
||||||
|
(void)env;
|
||||||
|
(void)jcl;
|
||||||
|
#ifndef NO_SHA
|
||||||
|
return JNI_TRUE;
|
||||||
|
#else
|
||||||
|
return JNI_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Sha256Enabled
|
||||||
|
(JNIEnv* env, jclass jcl)
|
||||||
|
{
|
||||||
|
(void)env;
|
||||||
|
(void)jcl;
|
||||||
|
#ifndef NO_SHA256
|
||||||
|
return JNI_TRUE;
|
||||||
|
#else
|
||||||
|
return JNI_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Sha384Enabled
|
||||||
|
(JNIEnv* env, jclass jcl)
|
||||||
|
{
|
||||||
|
(void)env;
|
||||||
|
(void)jcl;
|
||||||
|
#ifdef WOLFSSL_SHA384
|
||||||
|
return JNI_TRUE;
|
||||||
|
#else
|
||||||
|
return JNI_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_com_wolfssl_wolfcrypt_FeatureDetect_Sha512Enabled
|
||||||
|
(JNIEnv* env, jclass jcl)
|
||||||
|
{
|
||||||
|
(void)env;
|
||||||
|
(void)jcl;
|
||||||
|
#ifdef WOLFSSL_SHA512
|
||||||
|
return JNI_TRUE;
|
||||||
|
#else
|
||||||
|
return JNI_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
static WC_INLINE int GetHashSizeByType(int type)
|
static WC_INLINE int GetHashSizeByType(int type)
|
||||||
{
|
{
|
||||||
if (!(type == WC_MD5 || type == WC_SHA || type == WC_SHA256
|
if (!(type == WC_MD5 || type == WC_SHA || type == WC_SHA256
|
||||||
|| type == WC_SHA384 || type == WC_SHA512 || type == BLAKE2B_ID))
|
|| type == WC_SHA384 || type == WC_SHA512))
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -73,12 +73,6 @@ static WC_INLINE int GetHashSizeByType(int type)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BLAKE2
|
|
||||||
case BLAKE2B_ID:
|
|
||||||
return BLAKE2B_OUTBYTES;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
break;
|
break;
|
||||||
|
@ -308,52 +302,69 @@ JNIEXPORT jint JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Hmac_getCodeMd5(
|
Java_com_wolfssl_wolfcrypt_Hmac_getCodeMd5(
|
||||||
JNIEnv* env, jobject this)
|
JNIEnv* env, jobject this)
|
||||||
{
|
{
|
||||||
|
#ifndef NO_MD5
|
||||||
jint result = WC_MD5;
|
jint result = WC_MD5;
|
||||||
LogStr("WC_MD5 = %d\n", result);
|
LogStr("WC_MD5 = %d\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
/* not compiled in */
|
||||||
|
return (jint) -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha(
|
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha(
|
||||||
JNIEnv* env, jobject this)
|
JNIEnv* env, jobject this)
|
||||||
{
|
{
|
||||||
|
#ifndef NO_SHA
|
||||||
jint result = WC_SHA;
|
jint result = WC_SHA;
|
||||||
LogStr("WC_SHA = %d\n", result);
|
LogStr("WC_SHA = %d\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
/* not compiled in */
|
||||||
|
return (jint) -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha256(
|
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha256(
|
||||||
JNIEnv* env, jobject this)
|
JNIEnv* env, jobject this)
|
||||||
{
|
{
|
||||||
|
#ifndef NO_SHA256
|
||||||
jint result = WC_SHA256;
|
jint result = WC_SHA256;
|
||||||
LogStr("WC_SHA256 = %d\n", result);
|
LogStr("WC_SHA256 = %d\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
/* not compiled in */
|
||||||
|
return (jint) -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha384(
|
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha384(
|
||||||
JNIEnv* env, jobject this)
|
JNIEnv* env, jobject this)
|
||||||
{
|
{
|
||||||
|
#ifdef WOLFSSL_SHA384
|
||||||
jint result = WC_SHA384;
|
jint result = WC_SHA384;
|
||||||
LogStr("WC_SHA384 = %d\n", result);
|
LogStr("WC_SHA384 = %d\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
/* not compiled in */
|
||||||
|
return (jint) -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha512(
|
Java_com_wolfssl_wolfcrypt_Hmac_getCodeSha512(
|
||||||
JNIEnv* env, jobject this)
|
JNIEnv* env, jobject this)
|
||||||
{
|
{
|
||||||
|
#ifdef WOLFSSL_SHA512
|
||||||
jint result = WC_SHA512;
|
jint result = WC_SHA512;
|
||||||
LogStr("WC_SHA512 = %d\n", result);
|
LogStr("WC_SHA512 = %d\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
/* not compiled in */
|
||||||
|
return (jint) -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
|
||||||
Java_com_wolfssl_wolfcrypt_Hmac_getCodeBlake2b(
|
|
||||||
JNIEnv* env, jobject this)
|
|
||||||
{
|
|
||||||
jint result = BLAKE2B_ID;
|
|
||||||
LogStr("BLAKE2B_ID = %d", result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ Java_com_wolfssl_wolfcrypt_Sha384_mallocNativeStruct(
|
||||||
{
|
{
|
||||||
jlong ret = 0;
|
jlong ret = 0;
|
||||||
|
|
||||||
#ifdef WOLFSSL_SHA512
|
#ifdef WOLFSSL_SHA384
|
||||||
ret = (jlong) XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
ret = (jlong) XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
@ -433,7 +433,7 @@ JNIEXPORT void JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Sha384_native_1init(
|
Java_com_wolfssl_wolfcrypt_Sha384_native_1init(
|
||||||
JNIEnv* env, jobject this)
|
JNIEnv* env, jobject this)
|
||||||
{
|
{
|
||||||
#ifdef WOLFSSL_SHA512
|
#ifdef WOLFSSL_SHA384
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Sha384* sha = (Sha384*) getNativeStruct(env, this);
|
Sha384* sha = (Sha384*) getNativeStruct(env, this);
|
||||||
if ((*env)->ExceptionOccurred(env)) {
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
|
@ -456,7 +456,7 @@ JNIEXPORT void JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Sha384_native_1update__Ljava_nio_ByteBuffer_2II(
|
Java_com_wolfssl_wolfcrypt_Sha384_native_1update__Ljava_nio_ByteBuffer_2II(
|
||||||
JNIEnv* env, jobject this, jobject data_buffer, jint position, jint len)
|
JNIEnv* env, jobject this, jobject data_buffer, jint position, jint len)
|
||||||
{
|
{
|
||||||
#ifdef WOLFSSL_SHA512
|
#ifdef WOLFSSL_SHA384
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Sha384* sha = NULL;
|
Sha384* sha = NULL;
|
||||||
byte* data = NULL;
|
byte* data = NULL;
|
||||||
|
@ -489,7 +489,7 @@ Java_com_wolfssl_wolfcrypt_Sha384_native_1update___3BII(
|
||||||
JNIEnv* env, jobject this, jbyteArray data_buffer, jint offset,
|
JNIEnv* env, jobject this, jbyteArray data_buffer, jint offset,
|
||||||
jint len)
|
jint len)
|
||||||
{
|
{
|
||||||
#ifdef WOLFSSL_SHA512
|
#ifdef WOLFSSL_SHA384
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Sha384* sha = NULL;
|
Sha384* sha = NULL;
|
||||||
byte* data = NULL;
|
byte* data = NULL;
|
||||||
|
@ -525,7 +525,7 @@ JNIEXPORT void JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Sha384_native_1final__Ljava_nio_ByteBuffer_2I(
|
Java_com_wolfssl_wolfcrypt_Sha384_native_1final__Ljava_nio_ByteBuffer_2I(
|
||||||
JNIEnv* env, jobject this, jobject hash_buffer, jint position)
|
JNIEnv* env, jobject this, jobject hash_buffer, jint position)
|
||||||
{
|
{
|
||||||
#ifdef WOLFSSL_SHA512
|
#ifdef WOLFSSL_SHA384
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Sha384* sha = NULL;
|
Sha384* sha = NULL;
|
||||||
byte* hash = NULL;
|
byte* hash = NULL;
|
||||||
|
@ -557,7 +557,7 @@ JNIEXPORT void JNICALL
|
||||||
Java_com_wolfssl_wolfcrypt_Sha384_native_1final___3B(
|
Java_com_wolfssl_wolfcrypt_Sha384_native_1final___3B(
|
||||||
JNIEnv* env, jobject this, jbyteArray hash_buffer)
|
JNIEnv* env, jobject this, jbyteArray hash_buffer)
|
||||||
{
|
{
|
||||||
#ifdef WOLFSSL_SHA512
|
#ifdef WOLFSSL_SHA384
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Sha384* sha = NULL;
|
Sha384* sha = NULL;
|
||||||
byte* hash = NULL;
|
byte* hash = NULL;
|
||||||
|
|
2
makefile
2
makefile
|
@ -5,7 +5,7 @@ INC_PATH = $(SRC_PATH)/include
|
||||||
OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \
|
OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \
|
||||||
jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \
|
jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \
|
||||||
jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \
|
jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \
|
||||||
jni_logging.o
|
jni_logging.o jni_feature_detect.o
|
||||||
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
|
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
|
||||||
TARGET = $(OUT_PATH)/libwolfcryptjni.jnilib
|
TARGET = $(OUT_PATH)/libwolfcryptjni.jnilib
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ INC_PATH = $(SRC_PATH)/include
|
||||||
OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \
|
OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \
|
||||||
jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \
|
jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \
|
||||||
jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \
|
jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \
|
||||||
jni_logging.o
|
jni_logging.o jni_feature_detect.o
|
||||||
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
|
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
|
||||||
TARGET = $(OUT_PATH)/libwolfcryptjni.so
|
TARGET = $(OUT_PATH)/libwolfcryptjni.so
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ INC_PATH = $(SRC_PATH)/include
|
||||||
OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \
|
OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \
|
||||||
jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \
|
jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \
|
||||||
jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \
|
jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \
|
||||||
jni_logging.o
|
jni_logging.o jni_feature_detect.o
|
||||||
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
|
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
|
||||||
TARGET = $(OUT_PATH)/libwolfcryptjni.jnilib
|
TARGET = $(OUT_PATH)/libwolfcryptjni.jnilib
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
package com.wolfssl.provider.jce;
|
package com.wolfssl.provider.jce;
|
||||||
|
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
|
import com.wolfssl.wolfcrypt.FeatureDetect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wolfCrypt JCE Provider implementation
|
* wolfCrypt JCE Provider implementation
|
||||||
|
@ -35,16 +36,26 @@ public final class WolfCryptProvider extends Provider {
|
||||||
super("wolfJCE", 1.0, "wolfCrypt JCE Provider");
|
super("wolfJCE", 1.0, "wolfCrypt JCE Provider");
|
||||||
|
|
||||||
/* MessageDigest */
|
/* MessageDigest */
|
||||||
put("MessageDigest.MD5",
|
if (FeatureDetect.Md5Enabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptMessageDigestMd5");
|
put("MessageDigest.MD5",
|
||||||
put("MessageDigest.SHA-1",
|
"com.wolfssl.provider.jce.WolfCryptMessageDigestMd5");
|
||||||
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha");
|
}
|
||||||
put("MessageDigest.SHA-256",
|
if (FeatureDetect.ShaEnabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha256");
|
put("MessageDigest.SHA-1",
|
||||||
put("MessageDigest.SHA-384",
|
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha");
|
||||||
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha384");
|
}
|
||||||
put("MessageDigest.SHA-512",
|
if (FeatureDetect.Sha256Enabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha512");
|
put("MessageDigest.SHA-256",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha256");
|
||||||
|
}
|
||||||
|
if (FeatureDetect.Sha384Enabled()) {
|
||||||
|
put("MessageDigest.SHA-384",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha384");
|
||||||
|
}
|
||||||
|
if (FeatureDetect.Sha512Enabled()) {
|
||||||
|
put("MessageDigest.SHA-512",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha512");
|
||||||
|
}
|
||||||
|
|
||||||
/* SecureRandom */
|
/* SecureRandom */
|
||||||
/* TODO: May need to add "SHA1PRNG" alias, other JCA consumemrs may
|
/* TODO: May need to add "SHA1PRNG" alias, other JCA consumemrs may
|
||||||
|
@ -53,37 +64,56 @@ public final class WolfCryptProvider extends Provider {
|
||||||
"com.wolfssl.provider.jce.WolfCryptRandom");
|
"com.wolfssl.provider.jce.WolfCryptRandom");
|
||||||
|
|
||||||
/* Signature */
|
/* Signature */
|
||||||
put("Signature.MD5withRSA",
|
if (FeatureDetect.Md5Enabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcMD5wRSA");
|
put("Signature.MD5withRSA",
|
||||||
put("Signature.SHA1withRSA",
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcMD5wRSA");
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA1wRSA");
|
}
|
||||||
put("Signature.SHA256withRSA",
|
if (FeatureDetect.ShaEnabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA256wRSA");
|
put("Signature.SHA1withRSA",
|
||||||
put("Signature.SHA384withRSA",
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA1wRSA");
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA384wRSA");
|
put("Signature.SHA1withECDSA",
|
||||||
put("Signature.SHA512withRSA",
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA1wECDSA");
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA512wRSA");
|
}
|
||||||
|
if (FeatureDetect.Sha256Enabled()) {
|
||||||
put("Signature.SHA1withECDSA",
|
put("Signature.SHA256withRSA",
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA1wECDSA");
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA256wRSA");
|
||||||
put("Signature.SHA256withECDSA",
|
put("Signature.SHA256withECDSA",
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA256wECDSA");
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA256wECDSA");
|
||||||
put("Signature.SHA384withECDSA",
|
}
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA384wECDSA");
|
if (FeatureDetect.Sha384Enabled()) {
|
||||||
put("Signature.SHA512withECDSA",
|
put("Signature.SHA384withRSA",
|
||||||
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA512wECDSA");
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA384wRSA");
|
||||||
|
put("Signature.SHA384withECDSA",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA384wECDSA");
|
||||||
|
}
|
||||||
|
if (FeatureDetect.Sha512Enabled()) {
|
||||||
|
put("Signature.SHA512withRSA",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA512wRSA");
|
||||||
|
put("Signature.SHA512withECDSA",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptSignature$wcSHA512wECDSA");
|
||||||
|
}
|
||||||
|
|
||||||
/* Mac */
|
/* Mac */
|
||||||
put("Mac.HmacMD5",
|
if (FeatureDetect.Md5Enabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacMD5");
|
put("Mac.HmacMD5",
|
||||||
put("Mac.HmacSHA1",
|
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacMD5");
|
||||||
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA1");
|
}
|
||||||
put("Mac.HmacSHA256",
|
if (FeatureDetect.ShaEnabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA256");
|
put("Mac.HmacSHA1",
|
||||||
put("Mac.HmacSHA384",
|
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA1");
|
||||||
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA384");
|
}
|
||||||
put("Mac.HmacSHA512",
|
if (FeatureDetect.Sha256Enabled()) {
|
||||||
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA512");
|
put("Mac.HmacSHA256",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA256");
|
||||||
|
}
|
||||||
|
if (FeatureDetect.Sha384Enabled()) {
|
||||||
|
put("Mac.HmacSHA384",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA384");
|
||||||
|
}
|
||||||
|
if (FeatureDetect.Sha512Enabled()) {
|
||||||
|
put("Mac.HmacSHA512",
|
||||||
|
"com.wolfssl.provider.jce.WolfCryptMac$wcHmacSHA512");
|
||||||
|
}
|
||||||
|
|
||||||
/* Cipher */
|
/* Cipher */
|
||||||
put("Cipher.AES/CBC/NoPadding",
|
put("Cipher.AES/CBC/NoPadding",
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/* FeatureDetect.java
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wolfssl.wolfcrypt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Native feature detection class
|
||||||
|
* Used to expose native preprocessor values to Java
|
||||||
|
*
|
||||||
|
* @author wolfSSL
|
||||||
|
* @version 1.0, January 2020
|
||||||
|
*/
|
||||||
|
public class FeatureDetect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if MD5 is compiled into the native wolfSSL library.
|
||||||
|
*
|
||||||
|
* @return true if enabled, otherwise false if not compiled in.
|
||||||
|
*/
|
||||||
|
public static native boolean Md5Enabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if SHA-1 is compiled into the native wolfSSL library.
|
||||||
|
*
|
||||||
|
* @return true if enabled, otherwise false if not compiled in.
|
||||||
|
*/
|
||||||
|
public static native boolean ShaEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if SHA-256 is compiled into the native wolfSSL library.
|
||||||
|
*
|
||||||
|
* @return true if enabled, otherwise false if not compiled in.
|
||||||
|
*/
|
||||||
|
public static native boolean Sha256Enabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if SHA-384 is compiled into the native wolfSSL library.
|
||||||
|
*
|
||||||
|
* @return true if enabled, otherwise false if not compiled in.
|
||||||
|
*/
|
||||||
|
public static native boolean Sha384Enabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if SHA-512 is compiled into the native wolfSSL library.
|
||||||
|
*
|
||||||
|
* @return true if enabled, otherwise false if not compiled in.
|
||||||
|
*/
|
||||||
|
public static native boolean Sha512Enabled();
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.loadLibrary("wolfcryptjni");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
package com.wolfssl.wolfcrypt;
|
package com.wolfssl.wolfcrypt;
|
||||||
|
|
||||||
import com.wolfssl.wolfcrypt.WolfCrypt;
|
import com.wolfssl.wolfcrypt.WolfCrypt;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,15 +34,15 @@ import java.nio.ByteBuffer;
|
||||||
public class Hmac extends NativeStruct {
|
public class Hmac extends NativeStruct {
|
||||||
|
|
||||||
private enum hashType {
|
private enum hashType {
|
||||||
typeMD5, typeSHA, typeSHA256, typeSHA384, typeSHA512, typeBLAKE2b;
|
typeMD5, typeSHA, typeSHA256, typeSHA384, typeSHA512;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* types may be -1 if not compiled in at native level */
|
||||||
public static final int MD5 = getHashCode(hashType.typeMD5);
|
public static final int MD5 = getHashCode(hashType.typeMD5);
|
||||||
public static final int SHA = getHashCode(hashType.typeSHA);
|
public static final int SHA = getHashCode(hashType.typeSHA);
|
||||||
public static final int SHA256 = getHashCode(hashType.typeSHA256);
|
public static final int SHA256 = getHashCode(hashType.typeSHA256);
|
||||||
public static final int SHA384 = getHashCode(hashType.typeSHA384);
|
public static final int SHA384 = getHashCode(hashType.typeSHA384);
|
||||||
public static final int SHA512 = getHashCode(hashType.typeSHA512);
|
public static final int SHA512 = getHashCode(hashType.typeSHA512);
|
||||||
public static final int BLAKE2b = getHashCode(hashType.typeBLAKE2b);
|
|
||||||
|
|
||||||
private WolfCryptState state = WolfCryptState.UNINITIALIZED;
|
private WolfCryptState state = WolfCryptState.UNINITIALIZED;
|
||||||
private int type = -1;
|
private int type = -1;
|
||||||
|
@ -80,7 +81,20 @@ public class Hmac extends NativeStruct {
|
||||||
|
|
||||||
protected native long mallocNativeStruct() throws OutOfMemoryError;
|
protected native long mallocNativeStruct() throws OutOfMemoryError;
|
||||||
|
|
||||||
|
/* check if type is -1, if so that type is not compiled in at native
|
||||||
|
* wolfSSL level. Throw exception if so. */
|
||||||
|
private void checkHashTypeCompiledIn(int type) throws WolfCryptException {
|
||||||
|
WolfCryptError notCompiledIn = WolfCryptError.NOT_COMPILED_IN;
|
||||||
|
if (type == -1) {
|
||||||
|
throw new WolfCryptException(notCompiledIn.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setKey(int type, byte[] key) {
|
public void setKey(int type, byte[] key) {
|
||||||
|
|
||||||
|
/* verify hash type is compiled in */
|
||||||
|
checkHashTypeCompiledIn(type);
|
||||||
|
|
||||||
wc_HmacSetKey(type, key);
|
wc_HmacSetKey(type, key);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -162,7 +176,7 @@ public class Hmac extends NativeStruct {
|
||||||
|
|
||||||
if (type == MD5) {
|
if (type == MD5) {
|
||||||
return "HmacMD5";
|
return "HmacMD5";
|
||||||
}
|
}
|
||||||
else if (type == SHA256) {
|
else if (type == SHA256) {
|
||||||
return "HmacSHA256";
|
return "HmacSHA256";
|
||||||
}
|
}
|
||||||
|
@ -172,9 +186,7 @@ public class Hmac extends NativeStruct {
|
||||||
else if (type == SHA512) {
|
else if (type == SHA512) {
|
||||||
return "HmacSHA512";
|
return "HmacSHA512";
|
||||||
}
|
}
|
||||||
else if (type == BLAKE2b) {
|
else {
|
||||||
return "HmacBLAKE2b";
|
|
||||||
} else {
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,8 +217,6 @@ public class Hmac extends NativeStruct {
|
||||||
return getCodeSha384();
|
return getCodeSha384();
|
||||||
case typeSHA512:
|
case typeSHA512:
|
||||||
return getCodeSha512();
|
return getCodeSha512();
|
||||||
case typeBLAKE2b:
|
|
||||||
return getCodeBlake2b();
|
|
||||||
default:
|
default:
|
||||||
return WolfCrypt.FAILURE;
|
return WolfCrypt.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,15 @@ package com.wolfssl.provider.jce.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import javax.crypto.Mac;
|
import javax.crypto.Mac;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.NoSuchProviderException;
|
import java.security.NoSuchProviderException;
|
||||||
|
@ -39,7 +43,7 @@ import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
|
||||||
public class WolfCryptMacTest {
|
public class WolfCryptMacTest {
|
||||||
|
|
||||||
private String wolfJCEAlgos[] = {
|
private static String wolfJCEAlgos[] = {
|
||||||
"HmacMD5",
|
"HmacMD5",
|
||||||
"HmacSHA1",
|
"HmacSHA1",
|
||||||
"HmacSHA256",
|
"HmacSHA256",
|
||||||
|
@ -47,8 +51,11 @@ public class WolfCryptMacTest {
|
||||||
"HmacSHA512"
|
"HmacSHA512"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static ArrayList<String> enabledAlgos =
|
||||||
|
new ArrayList<String>();
|
||||||
|
|
||||||
/* expected digest sizes, order must match wolfJCEAlgos */
|
/* expected digest sizes, order must match wolfJCEAlgos */
|
||||||
private int wolfJCEMacLengths[] = {
|
private static int wolfJCEMacLengths[] = {
|
||||||
16,
|
16,
|
||||||
20,
|
20,
|
||||||
32,
|
32,
|
||||||
|
@ -56,14 +63,32 @@ public class WolfCryptMacTest {
|
||||||
64
|
64
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static ArrayList<Integer> enabledAlgoLengths =
|
||||||
|
new ArrayList<Integer>();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
|
Mac mac;
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
|
|
||||||
|
/* populate enabledAlgos, some native features may be
|
||||||
|
* compiled out */
|
||||||
|
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
||||||
|
try {
|
||||||
|
mac = Mac.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
||||||
|
enabledAlgos.add(wolfJCEAlgos[i]);
|
||||||
|
enabledAlgoLengths.add(wolfJCEMacLengths[i]);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* algo not compiled in */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -73,8 +98,8 @@ public class WolfCryptMacTest {
|
||||||
Mac mac;
|
Mac mac;
|
||||||
|
|
||||||
/* try to get all available options we expect to have */
|
/* try to get all available options we expect to have */
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
mac = Mac.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
mac = Mac.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getting a garbage algorithm should throw an exception */
|
/* getting a garbage algorithm should throw an exception */
|
||||||
|
@ -93,12 +118,12 @@ public class WolfCryptMacTest {
|
||||||
|
|
||||||
Mac mac;
|
Mac mac;
|
||||||
|
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
mac = Mac.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
mac = Mac.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
|
|
||||||
if (mac.getMacLength() != wolfJCEMacLengths[i])
|
if (mac.getMacLength() != enabledAlgoLengths.get(i))
|
||||||
fail("Expected MAC length did not match, " +
|
fail("Expected MAC length did not match, " +
|
||||||
"algo = " + wolfJCEAlgos[i]);
|
"algo = " + enabledAlgos.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,13 +200,20 @@ public class WolfCryptMacTest {
|
||||||
SecretKeySpec keyspec =
|
SecretKeySpec keyspec =
|
||||||
new SecretKeySpec(vectors[i].getKey(), "MD5");
|
new SecretKeySpec(vectors[i].getKey(), "MD5");
|
||||||
|
|
||||||
Mac mac = Mac.getInstance("HmacMD5", "wolfJCE");
|
try {
|
||||||
mac.init(keyspec);
|
Mac mac = Mac.getInstance("HmacMD5", "wolfJCE");
|
||||||
mac.update(vectors[i].getInput());
|
|
||||||
|
|
||||||
byte out[] = mac.doFinal();
|
mac.init(keyspec);
|
||||||
|
mac.update(vectors[i].getInput());
|
||||||
|
|
||||||
assertArrayEquals(out, vectors[i].getOutput());
|
byte out[] = mac.doFinal();
|
||||||
|
|
||||||
|
assertArrayEquals(out, vectors[i].getOutput());
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* skip test if not available */
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,13 +295,20 @@ public class WolfCryptMacTest {
|
||||||
SecretKeySpec keyspec =
|
SecretKeySpec keyspec =
|
||||||
new SecretKeySpec(vectors[i].getKey(), "SHA1");
|
new SecretKeySpec(vectors[i].getKey(), "SHA1");
|
||||||
|
|
||||||
Mac mac = Mac.getInstance("HmacSHA1", "wolfJCE");
|
try {
|
||||||
mac.init(keyspec);
|
Mac mac = Mac.getInstance("HmacSHA1", "wolfJCE");
|
||||||
mac.update(vectors[i].getInput());
|
|
||||||
|
|
||||||
byte out[] = mac.doFinal();
|
mac.init(keyspec);
|
||||||
|
mac.update(vectors[i].getInput());
|
||||||
|
|
||||||
assertArrayEquals(out, vectors[i].getOutput());
|
byte out[] = mac.doFinal();
|
||||||
|
|
||||||
|
assertArrayEquals(out, vectors[i].getOutput());
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* skip test if not available */
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,13 +399,20 @@ public class WolfCryptMacTest {
|
||||||
SecretKeySpec keyspec =
|
SecretKeySpec keyspec =
|
||||||
new SecretKeySpec(vectors[i].getKey(), "SHA256");
|
new SecretKeySpec(vectors[i].getKey(), "SHA256");
|
||||||
|
|
||||||
Mac mac = Mac.getInstance("HmacSHA256", "wolfJCE");
|
try {
|
||||||
mac.init(keyspec);
|
Mac mac = Mac.getInstance("HmacSHA256", "wolfJCE");
|
||||||
mac.update(vectors[i].getInput());
|
|
||||||
|
|
||||||
byte out[] = mac.doFinal();
|
mac.init(keyspec);
|
||||||
|
mac.update(vectors[i].getInput());
|
||||||
|
|
||||||
assertArrayEquals(out, vectors[i].getOutput());
|
byte out[] = mac.doFinal();
|
||||||
|
|
||||||
|
assertArrayEquals(out, vectors[i].getOutput());
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* skip test if not available */
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,13 +515,20 @@ public class WolfCryptMacTest {
|
||||||
SecretKeySpec keyspec =
|
SecretKeySpec keyspec =
|
||||||
new SecretKeySpec(vectors[i].getKey(), "SHA384");
|
new SecretKeySpec(vectors[i].getKey(), "SHA384");
|
||||||
|
|
||||||
Mac mac = Mac.getInstance("HmacSHA384", "wolfJCE");
|
try {
|
||||||
mac.init(keyspec);
|
Mac mac = Mac.getInstance("HmacSHA384", "wolfJCE");
|
||||||
mac.update(vectors[i].getInput());
|
|
||||||
|
|
||||||
byte out[] = mac.doFinal();
|
mac.init(keyspec);
|
||||||
|
mac.update(vectors[i].getInput());
|
||||||
|
|
||||||
assertArrayEquals(out, vectors[i].getOutput());
|
byte out[] = mac.doFinal();
|
||||||
|
|
||||||
|
assertArrayEquals(out, vectors[i].getOutput());
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* skip test if not available */
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,13 +643,20 @@ public class WolfCryptMacTest {
|
||||||
SecretKeySpec keyspec =
|
SecretKeySpec keyspec =
|
||||||
new SecretKeySpec(vectors[i].getKey(), "SHA512");
|
new SecretKeySpec(vectors[i].getKey(), "SHA512");
|
||||||
|
|
||||||
Mac mac = Mac.getInstance("HmacSHA512", "wolfJCE");
|
try {
|
||||||
mac.init(keyspec);
|
Mac mac = Mac.getInstance("HmacSHA512", "wolfJCE");
|
||||||
mac.update(vectors[i].getInput());
|
|
||||||
|
|
||||||
byte out[] = mac.doFinal();
|
mac.init(keyspec);
|
||||||
|
mac.update(vectors[i].getInput());
|
||||||
|
|
||||||
assertArrayEquals(out, vectors[i].getOutput());
|
byte out[] = mac.doFinal();
|
||||||
|
|
||||||
|
assertArrayEquals(out, vectors[i].getOutput());
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* skip test if not available */
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ package com.wolfssl.provider.jce.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
@ -32,24 +33,30 @@ import java.security.NoSuchProviderException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import com.wolfssl.provider.jce.WolfCryptProvider;
|
import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
import com.wolfssl.wolfcrypt.FeatureDetect;
|
||||||
|
|
||||||
public class WolfCryptMessageDigestMd5Test {
|
public class WolfCryptMessageDigestMd5Test {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
try {
|
||||||
public void testGetMessageDigestFromProvider()
|
MessageDigest md5 = MessageDigest.getInstance("MD5",
|
||||||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
"wolfJCE");
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5", "wolfJCE");
|
/* if we also detect algo is compiled out, skip tests */
|
||||||
|
if (FeatureDetect.Md5Enabled() == false) {
|
||||||
|
System.out.println("JSSE MD5 Test skipped");
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,7 @@ package com.wolfssl.provider.jce.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
@ -32,24 +33,30 @@ import java.security.NoSuchProviderException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import com.wolfssl.provider.jce.WolfCryptProvider;
|
import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
import com.wolfssl.wolfcrypt.FeatureDetect;
|
||||||
|
|
||||||
public class WolfCryptMessageDigestSha256Test {
|
public class WolfCryptMessageDigestSha256Test {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
try {
|
||||||
public void testGetMessageDigestFromProvider()
|
MessageDigest sha256 = MessageDigest.getInstance("SHA-256",
|
||||||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
"wolfJCE");
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256", "wolfJCE");
|
/* if we also detect algo is compiled out, skip tests */
|
||||||
|
if (FeatureDetect.Sha256Enabled() == false) {
|
||||||
|
System.out.println("JSSE SHA-256 Test skipped");
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,7 @@ package com.wolfssl.provider.jce.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
@ -32,24 +33,30 @@ import java.security.NoSuchProviderException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import com.wolfssl.provider.jce.WolfCryptProvider;
|
import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
import com.wolfssl.wolfcrypt.FeatureDetect;
|
||||||
|
|
||||||
public class WolfCryptMessageDigestSha384Test {
|
public class WolfCryptMessageDigestSha384Test {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
try {
|
||||||
public void testGetMessageDigestFromProvider()
|
MessageDigest sha384 = MessageDigest.getInstance("SHA-384",
|
||||||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
"wolfJCE");
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
MessageDigest sha384 = MessageDigest.getInstance("SHA-384", "wolfJCE");
|
/* if we also detect algo is compiled out, skip tests */
|
||||||
|
if (FeatureDetect.Sha384Enabled() == false) {
|
||||||
|
System.out.println("JSSE SHA-384 Test skipped");
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,7 @@ package com.wolfssl.provider.jce.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
@ -32,24 +33,30 @@ import java.security.NoSuchProviderException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import com.wolfssl.provider.jce.WolfCryptProvider;
|
import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
import com.wolfssl.wolfcrypt.FeatureDetect;
|
||||||
|
|
||||||
public class WolfCryptMessageDigestSha512Test {
|
public class WolfCryptMessageDigestSha512Test {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
try {
|
||||||
public void testGetMessageDigestFromProvider()
|
MessageDigest sha512 = MessageDigest.getInstance("SHA-512",
|
||||||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
"wolfJCE");
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512", "wolfJCE");
|
/* if we also detect algo is compiled out, skip tests */
|
||||||
|
if (FeatureDetect.Sha512Enabled() == false) {
|
||||||
|
System.out.println("JSSE SHA-512 Test skipped");
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,7 @@ package com.wolfssl.provider.jce.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
@ -32,24 +33,30 @@ import java.security.NoSuchProviderException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import com.wolfssl.provider.jce.WolfCryptProvider;
|
import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
import com.wolfssl.wolfcrypt.FeatureDetect;
|
||||||
|
|
||||||
public class WolfCryptMessageDigestShaTest {
|
public class WolfCryptMessageDigestShaTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
try {
|
||||||
public void testGetMessageDigestFromProvider()
|
MessageDigest sha = MessageDigest.getInstance("SHA-1",
|
||||||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
"wolfJCE");
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
MessageDigest sha = MessageDigest.getInstance("SHA-1", "wolfJCE");
|
/* if we also detect algo is compiled out, skip tests */
|
||||||
|
if (FeatureDetect.ShaEnabled() == false) {
|
||||||
|
System.out.println("JSSE SHA-1 Test skipped");
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -25,6 +25,9 @@ import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
@ -45,7 +48,7 @@ import com.wolfssl.provider.jce.WolfCryptProvider;
|
||||||
|
|
||||||
public class WolfCryptSignatureTest {
|
public class WolfCryptSignatureTest {
|
||||||
|
|
||||||
private String wolfJCEAlgos[] = {
|
private static String wolfJCEAlgos[] = {
|
||||||
"SHA1withRSA",
|
"SHA1withRSA",
|
||||||
"SHA256withRSA",
|
"SHA256withRSA",
|
||||||
"SHA384withRSA",
|
"SHA384withRSA",
|
||||||
|
@ -56,14 +59,31 @@ public class WolfCryptSignatureTest {
|
||||||
"SHA512withECDSA"
|
"SHA512withECDSA"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static ArrayList<String> enabledAlgos =
|
||||||
|
new ArrayList<String>();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testProviderInstallationAtRuntime() {
|
public static void testProviderInstallationAtRuntime()
|
||||||
|
throws NoSuchProviderException {
|
||||||
|
|
||||||
|
Signature sig;
|
||||||
|
|
||||||
/* install wolfJCE provider at runtime */
|
/* install wolfJCE provider at runtime */
|
||||||
Security.addProvider(new WolfCryptProvider());
|
Security.addProvider(new WolfCryptProvider());
|
||||||
|
|
||||||
Provider p = Security.getProvider("wolfJCE");
|
Provider p = Security.getProvider("wolfJCE");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
|
|
||||||
|
/* populate enabledAlgos, some native features may be
|
||||||
|
* compiled out */
|
||||||
|
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
||||||
|
try {
|
||||||
|
sig = Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
||||||
|
enabledAlgos.add(wolfJCEAlgos[i]);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
/* algo not compiled in */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -73,8 +93,8 @@ public class WolfCryptSignatureTest {
|
||||||
Signature sig;
|
Signature sig;
|
||||||
|
|
||||||
/* try to get all available options we expect to have */
|
/* try to get all available options we expect to have */
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
sig = Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
sig = Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* asking for a bad algo should throw an exception */
|
/* asking for a bad algo should throw an exception */
|
||||||
|
@ -95,12 +115,12 @@ public class WolfCryptSignatureTest {
|
||||||
byte[] toSignBuf = toSign.getBytes();
|
byte[] toSignBuf = toSign.getBytes();
|
||||||
byte[] signature = null;
|
byte[] signature = null;
|
||||||
|
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
|
|
||||||
Signature signer =
|
Signature signer =
|
||||||
Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
Signature verifier =
|
Signature verifier =
|
||||||
Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
|
|
||||||
assertNotNull(signer);
|
assertNotNull(signer);
|
||||||
assertNotNull(verifier);
|
assertNotNull(verifier);
|
||||||
|
@ -110,7 +130,7 @@ public class WolfCryptSignatureTest {
|
||||||
assertNotNull(rand);
|
assertNotNull(rand);
|
||||||
|
|
||||||
/* generate key pair */
|
/* generate key pair */
|
||||||
KeyPair pair = generateKeyPair(wolfJCEAlgos[i], rand);
|
KeyPair pair = generateKeyPair(enabledAlgos.get(i), rand);
|
||||||
assertNotNull(pair);
|
assertNotNull(pair);
|
||||||
|
|
||||||
PrivateKey priv = pair.getPrivate();
|
PrivateKey priv = pair.getPrivate();
|
||||||
|
@ -144,12 +164,12 @@ public class WolfCryptSignatureTest {
|
||||||
byte[] toSignBuf = toSign.getBytes();
|
byte[] toSignBuf = toSign.getBytes();
|
||||||
byte[] signature = null;
|
byte[] signature = null;
|
||||||
|
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
|
|
||||||
Signature signer =
|
Signature signer =
|
||||||
Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
Signature verifier =
|
Signature verifier =
|
||||||
Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
|
|
||||||
assertNotNull(signer);
|
assertNotNull(signer);
|
||||||
assertNotNull(verifier);
|
assertNotNull(verifier);
|
||||||
|
@ -159,7 +179,7 @@ public class WolfCryptSignatureTest {
|
||||||
assertNotNull(rand);
|
assertNotNull(rand);
|
||||||
|
|
||||||
/* generate key pair */
|
/* generate key pair */
|
||||||
KeyPair pair = generateKeyPair(wolfJCEAlgos[i], rand);
|
KeyPair pair = generateKeyPair(enabledAlgos.get(i), rand);
|
||||||
assertNotNull(pair);
|
assertNotNull(pair);
|
||||||
|
|
||||||
PrivateKey priv = pair.getPrivate();
|
PrivateKey priv = pair.getPrivate();
|
||||||
|
@ -198,12 +218,12 @@ public class WolfCryptSignatureTest {
|
||||||
byte[] toSignBuf = toSign.getBytes();
|
byte[] toSignBuf = toSign.getBytes();
|
||||||
byte[] signature;
|
byte[] signature;
|
||||||
|
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
|
|
||||||
Signature signer =
|
Signature signer =
|
||||||
Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
Signature verifier =
|
Signature verifier =
|
||||||
Signature.getInstance(wolfJCEAlgos[i]);
|
Signature.getInstance(enabledAlgos.get(i));
|
||||||
|
|
||||||
assertNotNull(signer);
|
assertNotNull(signer);
|
||||||
assertNotNull(verifier);
|
assertNotNull(verifier);
|
||||||
|
@ -220,7 +240,7 @@ public class WolfCryptSignatureTest {
|
||||||
assertNotNull(rand);
|
assertNotNull(rand);
|
||||||
|
|
||||||
/* generate key pair */
|
/* generate key pair */
|
||||||
KeyPair pair = generateKeyPair(wolfJCEAlgos[i], rand);
|
KeyPair pair = generateKeyPair(enabledAlgos.get(i), rand);
|
||||||
assertNotNull(pair);
|
assertNotNull(pair);
|
||||||
|
|
||||||
PrivateKey priv = pair.getPrivate();
|
PrivateKey priv = pair.getPrivate();
|
||||||
|
@ -254,12 +274,12 @@ public class WolfCryptSignatureTest {
|
||||||
byte[] toSignBuf = toSign.getBytes();
|
byte[] toSignBuf = toSign.getBytes();
|
||||||
byte[] signature;
|
byte[] signature;
|
||||||
|
|
||||||
for (int i = 0; i < wolfJCEAlgos.length; i++) {
|
for (int i = 0; i < enabledAlgos.size(); i++) {
|
||||||
|
|
||||||
Signature signer =
|
Signature signer =
|
||||||
Signature.getInstance(wolfJCEAlgos[i]);
|
Signature.getInstance(enabledAlgos.get(i));
|
||||||
Signature verifier =
|
Signature verifier =
|
||||||
Signature.getInstance(wolfJCEAlgos[i], "wolfJCE");
|
Signature.getInstance(enabledAlgos.get(i), "wolfJCE");
|
||||||
|
|
||||||
assertNotNull(signer);
|
assertNotNull(signer);
|
||||||
assertNotNull(verifier);
|
assertNotNull(verifier);
|
||||||
|
@ -276,7 +296,7 @@ public class WolfCryptSignatureTest {
|
||||||
assertNotNull(rand);
|
assertNotNull(rand);
|
||||||
|
|
||||||
/* generate key pair */
|
/* generate key pair */
|
||||||
KeyPair pair = generateKeyPair(wolfJCEAlgos[i], rand);
|
KeyPair pair = generateKeyPair(enabledAlgos.get(i), rand);
|
||||||
assertNotNull(pair);
|
assertNotNull(pair);
|
||||||
|
|
||||||
PrivateKey priv = pair.getPrivate();
|
PrivateKey priv = pair.getPrivate();
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class HmacTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shaHmacShouldMatch() {
|
public void shaHmacShouldMatch() {
|
||||||
String[] keyVector = new String[] {
|
String[] keyVector = new String[] {
|
||||||
"fd42f5044e3f70825102017f8521",
|
"fd42f5044e3f70825102017f8521",
|
||||||
"7da600a31369689ae60b73e30bd9",
|
"7da600a31369689ae60b73e30bd9",
|
||||||
"c545cc0ef4adf1c98bd9e0e4ba04",
|
"c545cc0ef4adf1c98bd9e0e4ba04",
|
||||||
|
@ -74,23 +74,32 @@ public class HmacTest {
|
||||||
"fb6788ccd29e16544e5b52c963279b6a9eb21537" };
|
"fb6788ccd29e16544e5b52c963279b6a9eb21537" };
|
||||||
|
|
||||||
for (int i = 0; i < dataVector.length; i++) {
|
for (int i = 0; i < dataVector.length; i++) {
|
||||||
Hmac hmac = new Hmac();
|
try {
|
||||||
byte[] key = Util.h2b(keyVector[i]);
|
Hmac hmac = new Hmac();
|
||||||
byte[] data = Util.h2b(dataVector[i]);
|
byte[] key = Util.h2b(keyVector[i]);
|
||||||
byte[] expected = Util.h2b(hashVector[i]);
|
byte[] data = Util.h2b(dataVector[i]);
|
||||||
|
byte[] expected = Util.h2b(hashVector[i]);
|
||||||
|
|
||||||
hmac.setKey(Hmac.SHA, key);
|
hmac.setKey(Hmac.SHA, key);
|
||||||
|
|
||||||
for (byte b : data)
|
for (byte b : data)
|
||||||
hmac.update(b);
|
hmac.update(b);
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal());
|
assertArrayEquals(expected, hmac.doFinal());
|
||||||
|
|
||||||
hmac.reset();
|
hmac.reset();
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal(data));
|
assertArrayEquals(expected, hmac.doFinal(data));
|
||||||
}
|
} catch (WolfCryptException e) {
|
||||||
}
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Hmac SHA1 test skipped: " +
|
||||||
|
e.getError());
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha256HmacShouldMatch() {
|
public void sha256HmacShouldMatch() {
|
||||||
|
@ -115,23 +124,32 @@ public class HmacTest {
|
||||||
"e35457edf1dc47f70be1e7dfd4f2332b704a0febd0dbca26a6bb63d1c7bef647" };
|
"e35457edf1dc47f70be1e7dfd4f2332b704a0febd0dbca26a6bb63d1c7bef647" };
|
||||||
|
|
||||||
for (int i = 0; i < dataVector.length; i++) {
|
for (int i = 0; i < dataVector.length; i++) {
|
||||||
Hmac hmac = new Hmac(Hmac.SHA256, Util.h2b(keyVector[i]));
|
try {
|
||||||
byte[] data = Util.h2b(dataVector[i]);
|
Hmac hmac = new Hmac(Hmac.SHA256, Util.h2b(keyVector[i]));
|
||||||
byte[] expected = Util.h2b(hashVector[i]);
|
byte[] data = Util.h2b(dataVector[i]);
|
||||||
|
byte[] expected = Util.h2b(hashVector[i]);
|
||||||
|
|
||||||
hmac.update(data);
|
hmac.update(data);
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal());
|
assertArrayEquals(expected, hmac.doFinal());
|
||||||
|
|
||||||
assertEquals(expected.length, hmac.getMacLength());
|
assertEquals(expected.length, hmac.getMacLength());
|
||||||
|
|
||||||
hmac.reset();
|
hmac.reset();
|
||||||
|
|
||||||
buffer.put(data).rewind();
|
buffer.put(data).rewind();
|
||||||
hmac.update(buffer);
|
hmac.update(buffer);
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal());
|
assertArrayEquals(expected, hmac.doFinal());
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Hmac SHA256 test skipped: " +
|
||||||
|
e.getError());
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,22 +175,32 @@ public class HmacTest {
|
||||||
"914551534846b871c2c70d5e30856021c2b1ff7490354e987423069db694de2f1e960ae84b341c2a0bf5301f7bc77ade" };
|
"914551534846b871c2c70d5e30856021c2b1ff7490354e987423069db694de2f1e960ae84b341c2a0bf5301f7bc77ade" };
|
||||||
|
|
||||||
for (int i = 0; i < dataVector.length; i++) {
|
for (int i = 0; i < dataVector.length; i++) {
|
||||||
Hmac hmac = new Hmac();
|
try {
|
||||||
byte[] key = Util.h2b(keyVector[i]);
|
Hmac hmac = new Hmac();
|
||||||
byte[] data = Util.h2b(dataVector[i]);
|
byte[] key = Util.h2b(keyVector[i]);
|
||||||
byte[] expected = Util.h2b(hashVector[i]);
|
byte[] data = Util.h2b(dataVector[i]);
|
||||||
|
byte[] expected = Util.h2b(hashVector[i]);
|
||||||
|
|
||||||
hmac.setKey(Hmac.SHA384, key);
|
hmac.setKey(Hmac.SHA384, key);
|
||||||
|
|
||||||
/* first half */
|
/* first half */
|
||||||
hmac.update(data, 0, data.length / 2);
|
hmac.update(data, 0, data.length / 2);
|
||||||
|
|
||||||
/* second half */
|
/* second half */
|
||||||
hmac.update(data, data.length / 2, data.length / 2);
|
hmac.update(data, data.length / 2, data.length / 2);
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal());
|
assertArrayEquals(expected, hmac.doFinal());
|
||||||
|
|
||||||
assertEquals("HmacSHA384", hmac.getAlgorithm());
|
assertEquals("HmacSHA384", hmac.getAlgorithm());
|
||||||
|
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Hmac SHA384 test skipped: " +
|
||||||
|
e.getError());
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,22 +226,31 @@ public class HmacTest {
|
||||||
"74ec06a96c017463d3cbff306f45386b9b1c082592ee923206c3847dde7f11ff417cd9172a18c2040c877bbc58b5e057667f8136bdd39038addc1f0e8eabe3f0" };
|
"74ec06a96c017463d3cbff306f45386b9b1c082592ee923206c3847dde7f11ff417cd9172a18c2040c877bbc58b5e057667f8136bdd39038addc1f0e8eabe3f0" };
|
||||||
|
|
||||||
for (int i = 0; i < dataVector.length; i++) {
|
for (int i = 0; i < dataVector.length; i++) {
|
||||||
Hmac hmac = new Hmac();
|
try {
|
||||||
byte[] key = Util.h2b(keyVector[i]);
|
Hmac hmac = new Hmac();
|
||||||
byte[] data = Util.h2b(dataVector[i]);
|
byte[] key = Util.h2b(keyVector[i]);
|
||||||
byte[] expected = Util.h2b(hashVector[i]);
|
byte[] data = Util.h2b(dataVector[i]);
|
||||||
|
byte[] expected = Util.h2b(hashVector[i]);
|
||||||
|
|
||||||
hmac.setKey(Hmac.SHA512, key);
|
hmac.setKey(Hmac.SHA512, key);
|
||||||
hmac.update(data);
|
hmac.update(data);
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal());
|
assertArrayEquals(expected, hmac.doFinal());
|
||||||
|
|
||||||
hmac.reset();
|
hmac.reset();
|
||||||
|
|
||||||
hmac.update(data);
|
hmac.update(data);
|
||||||
|
|
||||||
assertArrayEquals(expected, hmac.doFinal());
|
assertArrayEquals(expected, hmac.doFinal());
|
||||||
|
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Hmac SHA512 test skipped: " +
|
||||||
|
e.getError());
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,28 @@ package com.wolfssl.wolfcrypt.test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import com.wolfssl.wolfcrypt.Md5;
|
import com.wolfssl.wolfcrypt.Md5;
|
||||||
import com.wolfssl.wolfcrypt.NativeStruct;
|
import com.wolfssl.wolfcrypt.NativeStruct;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptError;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptException;
|
||||||
|
|
||||||
public class Md5Test {
|
public class Md5Test {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void checkMd5IsAvailable() {
|
||||||
|
try {
|
||||||
|
Md5 md5 = new Md5();
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("MD5 skipped: " + e.getError());
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructorShouldInitializeNativeStruct() {
|
public void constructorShouldInitializeNativeStruct() {
|
||||||
assertNotEquals(NativeStruct.NULL, new Md5().getNativeStruct());
|
assertNotEquals(NativeStruct.NULL, new Md5().getNativeStruct());
|
||||||
|
|
|
@ -28,15 +28,31 @@ import java.nio.ByteBuffer;
|
||||||
import javax.crypto.ShortBufferException;
|
import javax.crypto.ShortBufferException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import com.wolfssl.wolfcrypt.Sha256;
|
import com.wolfssl.wolfcrypt.Sha256;
|
||||||
import com.wolfssl.wolfcrypt.NativeStruct;
|
import com.wolfssl.wolfcrypt.NativeStruct;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptException;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptError;
|
||||||
|
|
||||||
public class Sha256Test {
|
public class Sha256Test {
|
||||||
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
||||||
private ByteBuffer result = ByteBuffer.allocateDirect(Sha256.DIGEST_SIZE);
|
private ByteBuffer result = ByteBuffer.allocateDirect(Sha256.DIGEST_SIZE);
|
||||||
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha256.DIGEST_SIZE);
|
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha256.DIGEST_SIZE);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void checkSha256IsAvailable() {
|
||||||
|
try {
|
||||||
|
Sha256 sha = new Sha256();
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Sha256Test skipped: " + e.getError());
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructorShouldInitializeNativeStruct() {
|
public void constructorShouldInitializeNativeStruct() {
|
||||||
assertNotEquals(NativeStruct.NULL, new Sha256().getNativeStruct());
|
assertNotEquals(NativeStruct.NULL, new Sha256().getNativeStruct());
|
||||||
|
|
|
@ -28,15 +28,31 @@ import java.nio.ByteBuffer;
|
||||||
import javax.crypto.ShortBufferException;
|
import javax.crypto.ShortBufferException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import com.wolfssl.wolfcrypt.Sha384;
|
import com.wolfssl.wolfcrypt.Sha384;
|
||||||
import com.wolfssl.wolfcrypt.NativeStruct;
|
import com.wolfssl.wolfcrypt.NativeStruct;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptException;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptError;
|
||||||
|
|
||||||
public class Sha384Test {
|
public class Sha384Test {
|
||||||
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
||||||
private ByteBuffer result = ByteBuffer.allocateDirect(Sha384.DIGEST_SIZE);
|
private ByteBuffer result = ByteBuffer.allocateDirect(Sha384.DIGEST_SIZE);
|
||||||
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha384.DIGEST_SIZE);
|
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha384.DIGEST_SIZE);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void checkSha384IsAvailable() {
|
||||||
|
try {
|
||||||
|
Sha384 sha = new Sha384();
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Sha384Test skipped: " + e.getError());
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructorShouldInitializeNativeStruct() {
|
public void constructorShouldInitializeNativeStruct() {
|
||||||
assertNotEquals(NativeStruct.NULL, new Sha384().getNativeStruct());
|
assertNotEquals(NativeStruct.NULL, new Sha384().getNativeStruct());
|
||||||
|
|
|
@ -28,15 +28,31 @@ import java.nio.ByteBuffer;
|
||||||
import javax.crypto.ShortBufferException;
|
import javax.crypto.ShortBufferException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import com.wolfssl.wolfcrypt.Sha512;
|
import com.wolfssl.wolfcrypt.Sha512;
|
||||||
import com.wolfssl.wolfcrypt.NativeStruct;
|
import com.wolfssl.wolfcrypt.NativeStruct;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptException;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptError;
|
||||||
|
|
||||||
public class Sha512Test {
|
public class Sha512Test {
|
||||||
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
||||||
private ByteBuffer result = ByteBuffer.allocateDirect(Sha512.DIGEST_SIZE);
|
private ByteBuffer result = ByteBuffer.allocateDirect(Sha512.DIGEST_SIZE);
|
||||||
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha512.DIGEST_SIZE);
|
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha512.DIGEST_SIZE);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void checkSha512IsAvailable() {
|
||||||
|
try {
|
||||||
|
Sha512 sha = new Sha512();
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("Sha512Test skipped: " + e.getError());
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructorShouldInitializeNativeStruct() {
|
public void constructorShouldInitializeNativeStruct() {
|
||||||
assertNotEquals(NativeStruct.NULL, new Sha512().getNativeStruct());
|
assertNotEquals(NativeStruct.NULL, new Sha512().getNativeStruct());
|
||||||
|
|
|
@ -28,15 +28,31 @@ import java.nio.ByteBuffer;
|
||||||
import javax.crypto.ShortBufferException;
|
import javax.crypto.ShortBufferException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Assume;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import com.wolfssl.wolfcrypt.Sha;
|
import com.wolfssl.wolfcrypt.Sha;
|
||||||
import com.wolfssl.wolfcrypt.NativeStruct;
|
import com.wolfssl.wolfcrypt.NativeStruct;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptException;
|
||||||
|
import com.wolfssl.wolfcrypt.WolfCryptError;
|
||||||
|
|
||||||
public class ShaTest {
|
public class ShaTest {
|
||||||
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
private ByteBuffer data = ByteBuffer.allocateDirect(32);
|
||||||
private ByteBuffer result = ByteBuffer.allocateDirect(Sha.DIGEST_SIZE);
|
private ByteBuffer result = ByteBuffer.allocateDirect(Sha.DIGEST_SIZE);
|
||||||
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha.DIGEST_SIZE);
|
private ByteBuffer expected = ByteBuffer.allocateDirect(Sha.DIGEST_SIZE);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void checkShaIsAvailable() {
|
||||||
|
try {
|
||||||
|
Sha sha = new Sha();
|
||||||
|
} catch (WolfCryptException e) {
|
||||||
|
if (e.getError() == WolfCryptError.NOT_COMPILED_IN) {
|
||||||
|
System.out.println("ShaTest skipped: " + e.getError());
|
||||||
|
Assume.assumeTrue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructorShouldInitializeNativeStruct() {
|
public void constructorShouldInitializeNativeStruct() {
|
||||||
assertNotEquals(NativeStruct.NULL, new Sha().getNativeStruct());
|
assertNotEquals(NativeStruct.NULL, new Sha().getNativeStruct());
|
||||||
|
|
Loading…
Reference in New Issue