< prev index next >

src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCryptoMD.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 36,46 **** extern jbyte* getBytes(JNIEnv *env, jbyteArray bytes, int offset, int len); /////////////////////////////////////////////////////// // SPECIAL ENTRIES FOR JVM JNI-BYPASSING OPTIMIZATION //////////////////////////////////////////////////////// ! jlong JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeInit(jint mech) { void *pContext = NULL; switch (mech) { case com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1: pContext = malloc(sizeof(SHA1_CTX)); --- 36,47 ---- extern jbyte* getBytes(JNIEnv *env, jbyteArray bytes, int offset, int len); /////////////////////////////////////////////////////// // SPECIAL ENTRIES FOR JVM JNI-BYPASSING OPTIMIZATION //////////////////////////////////////////////////////// ! JNIEXPORT jlong JNICALL ! JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeInit(jint mech) { void *pContext = NULL; switch (mech) { case com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1: pContext = malloc(sizeof(SHA1_CTX));
*** 76,86 **** if (J2UC_DEBUG) printf("ERROR: Unsupported mech %i\n", mech); } return (jlong) pContext; } ! jint JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeUpdate (jint mech, jlong pContext, int notUsed, unsigned char* in, jint ofs, jint len) { if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { (*ftab->sha1Update)((SHA1_CTX*)pContext, (unsigned char*)(in+ofs), len); } else if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_MD5) { (*ftab->md5Update)((MD5_CTX*)pContext, (unsigned char*)(in+ofs), len); --- 77,88 ---- if (J2UC_DEBUG) printf("ERROR: Unsupported mech %i\n", mech); } return (jlong) pContext; } ! JNIEXPORT jint JNICALL ! JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeUpdate (jint mech, jlong pContext, int notUsed, unsigned char* in, jint ofs, jint len) { if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { (*ftab->sha1Update)((SHA1_CTX*)pContext, (unsigned char*)(in+ofs), len); } else if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_MD5) { (*ftab->md5Update)((MD5_CTX*)pContext, (unsigned char*)(in+ofs), len);
*** 89,99 **** } return 0; } // Do digest and free the context immediately ! jint JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeDigest (jint mech, jlong pContext, int notUsed, unsigned char* out, jint ofs, jint digestLen) { if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { (*ftab->sha1Final)((unsigned char*)(out + ofs), (SHA1_CTX *)pContext); free((SHA1_CTX *)pContext); --- 91,102 ---- } return 0; } // Do digest and free the context immediately ! JNIEXPORT jint JNICALL ! JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeDigest (jint mech, jlong pContext, int notUsed, unsigned char* out, jint ofs, jint digestLen) { if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { (*ftab->sha1Final)((unsigned char*)(out + ofs), (SHA1_CTX *)pContext); free((SHA1_CTX *)pContext);
*** 105,115 **** free((SHA2_CTX *)pContext); } return 0; } ! jlong JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeClone (jint mech, jlong pContext) { void *copy = NULL; size_t len = 0; if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { --- 108,119 ---- free((SHA2_CTX *)pContext); } return 0; } ! JNIEXPORT jlong JNICALL ! JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeClone (jint mech, jlong pContext) { void *copy = NULL; size_t len = 0; if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) {
*** 124,134 **** bcopy((void *)pContext, copy, len); } return (jlong) copy; } ! void JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeFree (jint mech, jlong pContext) { if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { free((SHA1_CTX*) pContext); } else if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_MD5) { free((MD5_CTX*) pContext); --- 128,139 ---- bcopy((void *)pContext, copy, len); } return (jlong) copy; } ! JNIEXPORT void JNICALL ! JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeFree (jint mech, jlong pContext) { if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA1) { free((SHA1_CTX*) pContext); } else if (mech == com_oracle_security_ucrypto_NativeDigestMD_MECH_MD5) { free((MD5_CTX*) pContext);
< prev index next >