JCE: code review fixes, cleanup
parent
aed7a9d787
commit
9615fe0d7c
|
@ -237,6 +237,10 @@ public class WolfCryptKeyAgreement extends KeyAgreementSpi {
|
|||
}
|
||||
|
||||
tmp = this.dh.makeSharedSecret(this.dh);
|
||||
if (tmp == null) {
|
||||
throw new RuntimeException("Error when creating DH " +
|
||||
"shared secret");
|
||||
}
|
||||
|
||||
if ((sharedSecret.length - offset) < tmp.length) {
|
||||
zeroArray(tmp);
|
||||
|
@ -256,6 +260,10 @@ public class WolfCryptKeyAgreement extends KeyAgreementSpi {
|
|||
case WC_ECDH:
|
||||
|
||||
tmp = this.ecPrivate.makeSharedSecret(this.ecPublic);
|
||||
if (tmp == null) {
|
||||
throw new RuntimeException("Error when creating ECDH " +
|
||||
"shared secret");
|
||||
}
|
||||
|
||||
if ((sharedSecret.length - offset) < tmp.length) {
|
||||
zeroArray(tmp);
|
||||
|
|
|
@ -161,7 +161,7 @@ public class WolfCryptKeyPairGenerator extends KeyPairGeneratorSpi {
|
|||
"Invalid parameters, either p or g is null");
|
||||
}
|
||||
|
||||
if (debug.DEBUG)
|
||||
if ((this.dhP != null) && debug.DEBUG)
|
||||
log("init with spec, prime len: " + this.dhP.length);
|
||||
|
||||
break;
|
||||
|
|
|
@ -111,7 +111,11 @@ public class WolfCryptMac extends MacSpi {
|
|||
byte[] out = this.hmac.doFinal();
|
||||
|
||||
if (debug.DEBUG)
|
||||
log("final digest generated, len: " + out.length);
|
||||
if (out != null) {
|
||||
log("final digest generated, len: " + out.length);
|
||||
} else {
|
||||
log("final digest was null");
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -433,8 +433,13 @@ public class WolfCryptSignature extends SignatureSpi {
|
|||
rng.free();
|
||||
rng.releaseNativeStruct();
|
||||
|
||||
if (debug.DEBUG)
|
||||
log("generated signature, len: " + signature.length);
|
||||
if (debug.DEBUG) {
|
||||
if (signature != null) {
|
||||
log("generated signature, len: " + signature.length);
|
||||
} else {
|
||||
log("generated signature was null");
|
||||
}
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
@ -560,9 +565,12 @@ public class WolfCryptSignature extends SignatureSpi {
|
|||
break;
|
||||
}
|
||||
|
||||
if (debug.DEBUG)
|
||||
log("finished verify of sig len: " + sigBytes.length +
|
||||
", verified: " + verified);
|
||||
if (debug.DEBUG) {
|
||||
if (sigBytes != null) {
|
||||
log("finished verify of sig len: " + sigBytes.length +
|
||||
", verified: " + verified);
|
||||
}
|
||||
}
|
||||
|
||||
return verified;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue