wolfcrypt-jni/jni/jni_hmac.c

53 lines
1.5 KiB
C

/* jni_hmac.c
*
* Copyright (C) 2006-2016 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 <wolfssl/wolfcrypt/hmac.h>
#include <com_wolfssl_wolfcrypt_Hmac.h>
#include <wolfcrypt_jni_error.h>
/* #define WOLFCRYPT_JNI_DEBUG_ON */
#include <wolfcrypt_jni_debug.h>
JNIEXPORT jlong JNICALL Java_com_wolfssl_wolfcrypt_Hmac_mallocNativeStruct(
JNIEnv* env, jobject this)
{
jlong ret = 0;
#ifdef NO_HMAC
throwNotCompiledInException(env);
#else
ret = (jlong) XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (!ret)
throwOutOfMemoryException(env, "Failed to allocate Hmac object");
LogStr("new Hmac() = %p\n", ret);
#endif
return ret;
}