package org.bouncycastle.crypto.prng;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class SP800SecureRandom extends java.security.SecureRandom {
    private final org.bouncycastle.crypto.prng.DRBGProvider a;
    private final boolean b;
    private final java.security.SecureRandom c;
    private final org.bouncycastle.crypto.prng.EntropySource d;
    private org.bouncycastle.crypto.prng.drbg.SP80090DRBG e;

    SP800SecureRandom(java.security.SecureRandom secureRandom, org.bouncycastle.crypto.prng.EntropySource entropySource, org.bouncycastle.crypto.prng.DRBGProvider dRBGProvider, boolean z) {
        this.c = secureRandom;
        this.d = entropySource;
        this.a = dRBGProvider;
        this.b = z;
    }

    public void a(byte[] bArr) {
        synchronized (this) {
            try {
                if (this.e == null) {
                    this.e = this.a.a(this.d);
                }
                this.e.b(bArr);
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.security.SecureRandom
    public byte[] generateSeed(int i) {
        return org.bouncycastle.crypto.prng.EntropyUtil.a(this.d, i);
    }

    @Override // java.security.SecureRandom
    public java.lang.String getAlgorithm() {
        return this.a.getAlgorithm();
    }

    @Override // java.security.SecureRandom, java.util.Random
    public void nextBytes(byte[] bArr) {
        synchronized (this) {
            try {
                if (this.e == null) {
                    this.e = this.a.a(this.d);
                }
                if (this.e.a(bArr, null, this.b) < 0) {
                    this.e.b(null);
                    this.e.a(bArr, null, this.b);
                }
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.security.SecureRandom, java.util.Random
    public void setSeed(long j) {
        synchronized (this) {
            try {
                java.security.SecureRandom secureRandom = this.c;
                if (secureRandom != null) {
                    secureRandom.setSeed(j);
                }
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.security.SecureRandom
    public void setSeed(byte[] bArr) {
        synchronized (this) {
            try {
                java.security.SecureRandom secureRandom = this.c;
                if (secureRandom != null) {
                    secureRandom.setSeed(bArr);
                }
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
    }
}
