Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ static jobject GetMessageDigestInstance(JNIEnv* env, intptr_t type)

int32_t CryptoNative_EvpDigestOneShot(intptr_t type, void* source, int32_t sourceSize, uint8_t* md, uint32_t* mdSize)
{
abort_if_invalid_pointer_argument (source);

if (!type || !md || !mdSize || sourceSize < 0)
if (!type || !md || !mdSize || sourceSize < 0 || (sourceSize > 0 && !source))
return FAIL;

JNIEnv* env = GetJNIEnv();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ int32_t CryptoNative_HmacReset(jobject ctx)

int32_t CryptoNative_HmacUpdate(jobject ctx, uint8_t* data, int32_t len)
{
if (!ctx)
// Callers are expected to skip update calls with no data.
if (!ctx || !data || len <= 0)
return FAIL;

abort_if_invalid_pointer_argument (data);
JNIEnv* env = GetJNIEnv();
jbyteArray dataBytes = make_java_byte_array(env, len);
(*env)->SetByteArrayRegion(env, dataBytes, 0, len, (jbyte*)data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ PALEXPORT void AndroidCryptoNative_RsaDestroy(RSA* rsa)

PALEXPORT int32_t AndroidCryptoNative_RsaPublicEncrypt(int32_t flen, uint8_t* from, uint8_t* to, RSA* rsa, RsaPadding padding)
{
abort_if_invalid_pointer_argument (from);
abort_if_invalid_pointer_argument (to);
abort_if_invalid_pointer_argument (rsa);

if ((flen > 0 && !from) || flen < 0)
return RSA_FAIL;

JNIEnv* env = GetJNIEnv();

int32_t ret = RSA_FAIL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public EvpHashProvider(IntPtr algorithmEvp)

public override void AppendHashData(ReadOnlySpan<byte> data)
{
if (data.IsEmpty)
{
return;
}

_running = true;
Check(Interop.Crypto.EvpDigestUpdate(_ctx, data, data.Length));
}
Expand Down Expand Up @@ -166,6 +171,11 @@ public HmacHashProvider(IntPtr algorithmEvp, ReadOnlySpan<byte> key)

public override void AppendHashData(ReadOnlySpan<byte> data)
{
if (data.IsEmpty)
{
return;
}

_running = true;
Check(Interop.Crypto.HmacUpdate(_hmacCtx, data, data.Length));
}
Expand Down