Renamed a bunch of lock variables.

"synchLock" will become confusing when we have lots of objects with "sync" in the name.
This commit is contained in:
akwizgran
2015-12-03 16:39:53 +00:00
parent 4f59491c9f
commit 8529c976c2
18 changed files with 180 additions and 179 deletions

View File

@@ -19,9 +19,9 @@ class FortunaGenerator {
private static final int KEY_BYTES = 32;
private static final int BLOCK_BYTES = 16;
private final Lock synchLock = new ReentrantLock();
private final Lock lock = new ReentrantLock();
// The following are locking: synchLock
// The following are locking: lock
private final MessageDigest digest = new DoubleDigest(new SHA256Digest());
private final BlockCipher cipher = new AESLightEngine();
private final byte[] key = new byte[KEY_BYTES];
@@ -34,21 +34,21 @@ class FortunaGenerator {
}
void reseed(byte[] seed) {
synchLock.lock();
lock.lock();
try {
digest.update(key);
digest.update(seed);
digest.digest(key, 0, KEY_BYTES);
incrementCounter();
} finally {
synchLock.unlock();
lock.unlock();
}
}
// Package access for testing
void incrementCounter() {
synchLock.lock();
lock.lock();
try {
counter[0]++;
for (int i = 0; counter[i] == 0; i++) {
@@ -57,23 +57,23 @@ class FortunaGenerator {
counter[i + 1]++;
}
} finally {
synchLock.unlock();
lock.unlock();
}
}
// Package access for testing
byte[] getCounter() {
synchLock.lock();
lock.lock();
try {
return counter;
} finally {
synchLock.unlock();
lock.unlock();
}
}
int nextBytes(byte[] dest, int off, int len) {
synchLock.lock();
lock.lock();
try {
// Don't write more than the maximum number of bytes in one request
if (len > MAX_BYTES_PER_REQUEST) len = MAX_BYTES_PER_REQUEST;
@@ -104,7 +104,7 @@ class FortunaGenerator {
// Return the number of bytes written
return len;
} finally {
synchLock.unlock();
lock.unlock();
}
}
}