what-the-bank/sources/org/bouncycastle/crypto/prng/ThreadedSeedGenerator.java

59 lines
1.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.prng;
/* loaded from: classes6.dex */
public class ThreadedSeedGenerator {
/* loaded from: classes6.dex */
class SeedGenerator implements Runnable {
private volatile int counter;
private volatile boolean stop;
final ThreadedSeedGenerator this$0;
@Override // java.lang.Runnable
public void run() {
while (!this.stop) {
this.counter++;
}
}
public byte[] generateSeed(int i, boolean z) {
Thread thread = new Thread(this);
byte[] bArr = new byte[i];
this.counter = 0;
this.stop = false;
thread.start();
if (!z) {
i <<= 3;
}
int i2 = 0;
for (int i3 = 0; i3 < i; i3++) {
while (this.counter == i2) {
try {
Thread.sleep(1L);
} catch (InterruptedException unused) {
}
}
i2 = this.counter;
if (z) {
bArr[i3] = (byte) i2;
} else {
int i4 = i3 / 8;
bArr[i4] = (byte) ((bArr[i4] << 1) | (i2 & 1));
}
}
this.stop = true;
return bArr;
}
private SeedGenerator(ThreadedSeedGenerator threadedSeedGenerator) {
this.this$0 = threadedSeedGenerator;
this.counter = 0;
this.stop = false;
}
}
public byte[] generateSeed(int i, boolean z) {
return new SeedGenerator().generateSeed(i, z);
}
}