do not call digestCalculator.getDigest() twice
This commit is contained in:
parent
f8724d3f42
commit
7cf34b0539
|
@ -137,12 +137,7 @@ public class NfcSyncPGPContentSignerBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getSignature() {
|
public byte[] getSignature() {
|
||||||
byte[] digest;
|
byte[] digest = getDigest();
|
||||||
if (enablePreHash) {
|
|
||||||
digest = digestCalculator.getDigest();
|
|
||||||
} else {
|
|
||||||
digest = ((ByteArrayOutputStream) getOutputStream()).toByteArray();
|
|
||||||
}
|
|
||||||
ByteBuffer buf = ByteBuffer.wrap(digest);
|
ByteBuffer buf = ByteBuffer.wrap(digest);
|
||||||
if (signedHashes.containsKey(buf)) {
|
if (signedHashes.containsKey(buf)) {
|
||||||
return (byte[]) signedHashes.get(buf);
|
return (byte[]) signedHashes.get(buf);
|
||||||
|
@ -154,6 +149,9 @@ public class NfcSyncPGPContentSignerBuilder
|
||||||
|
|
||||||
public byte[] getDigest()
|
public byte[] getDigest()
|
||||||
{
|
{
|
||||||
|
if (digest != null) {
|
||||||
|
return digest;
|
||||||
|
}
|
||||||
if (enablePreHash) {
|
if (enablePreHash) {
|
||||||
digest = digestCalculator.getDigest();
|
digest = digestCalculator.getDigest();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue