diff options
Diffstat (limited to 'src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java')
-rw-r--r-- | src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java b/src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java index e34bd925..a19a0481 100644 --- a/src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java +++ b/src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java @@ -6,6 +6,7 @@ import org.bouncycastle.crypto.Digest; import org.bouncycastle.crypto.InvalidCipherTextException; import org.bouncycastle.crypto.digests.SHA1Digest; import org.bouncycastle.crypto.params.ParametersWithRandom; +import org.bouncycastle.util.encoders.Hex; import java.security.SecureRandom; @@ -16,7 +17,6 @@ public class OAEPEncoding implements AsymmetricBlockCipher { private byte[] defHash; - private Digest hash; private Digest mgf1Hash; private AsymmetricBlockCipher engine; @@ -51,10 +51,11 @@ public class OAEPEncoding byte[] encodingParams) { this.engine = cipher; - this.hash = hash; this.mgf1Hash = mgf1Hash; this.defHash = new byte[hash.getDigestSize()]; + hash.reset(); + if (encodingParams != null) { hash.update(encodingParams, 0, encodingParams.length); @@ -326,9 +327,9 @@ public class OAEPEncoding byte[] C = new byte[4]; int counter = 0; - hash.reset(); + mgf1Hash.reset(); - do + while (counter < (length / hashBuf.length)) { ItoOSP(counter, C); @@ -337,8 +338,9 @@ public class OAEPEncoding mgf1Hash.doFinal(hashBuf, 0); System.arraycopy(hashBuf, 0, mask, counter * hashBuf.length, hashBuf.length); + + counter++; } - while (++counter < (length / hashBuf.length)); if ((counter * hashBuf.length) < length) { |