gnutls: fix spelling of GNUTLS_E_PREMATURE_TERMINATION

fixes spelling mistake from commit #0eda57f2d3a6387c6b20ba66068cce22894f5690

Signed-off-by: Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
gnutls: Fix minor memory leak when trying blank passwords

Commit 99f22b9d3 (Handle empty (but not NULL) passwords on PKCS#12 certs)
introduced a possible memory leak if gnutls_pkcs12_verify_mac(p12, "")
returned an error other than GNUTLS_E_MAC_VERIFY_FAILED.  Simplify the
check so that it only sets an empty password if MAC verification passes.

Spotted by Coverity.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
jni: Change cancelLock so it can be used from native code

Rename cancelLock to asyncLock and store a global reference so it can
be acquired by various JNI functions.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
jni: Allow other threads to call setLogLevel()

It is useful to allow the user to toggle PRG_TRACE logging on an active
connection for debugging purposes.  But currently this would involve
releasing the class lock held by the mainloop.  So we will use asyncLock
to protect the shared variable.

Timings conducted on a Nexus 7 (2012) show that the new
MonitorEnter/MonitorExit pair adds about 700ns to each progress_cb (which
is called on each packet).  This isn't great, but it's probably small
enough to make it worth doing things the right way (using a lock) instead
of just declaring loglevel as volatile.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>