jlong JNICALL Java_beecrypt_provider_SHA512_allocParam(JNIEnv* env, jclass dummy)
{
	jlong param = (jlong) malloc(sizeof(sha512Param));
	if (param == 0)
	{
		jclass ex = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
		if (ex)
			(*env)->ThrowNew(env, ex, (const char*) 0);
	}

	sha512Reset((sha512Param*) param);

	return param;
}
Beispiel #2
0
int main()
{
	int i, failures = 0;
	sha512Param param;
	byte digest[64];

	for (i = 0; i < 1; i++)
	{
		if (sha512Reset(&param))
			return -1;
		if (sha512Update(&param, table[i].input, table[i].input_size))
			return -1;
		if (sha512Digest(&param, digest))
			return -1;

		if (memcmp(digest, table[i].expect, 64))
		{
			printf("failed test vector %d\n", i+1);
			failures++;
		}
	}
	return failures;
}
void JNICALL Java_beecrypt_provider_SHA512_reset(JNIEnv* env, jclass dummy, jlong param)
{
	sha512Reset((sha512Param*) param);
}