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