ThreadedSeedGenerator$SeedGenerator.smali

.class Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;
.super Ljava/lang/Object;
.source "ThreadedSeedGenerator.java"

# interfaces
.implements Ljava/lang/Runnable;


# instance fields
.field private volatile counter:I

.field private volatile stop:Z

.field final synthetic this$0:Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator;


# direct methods
.method private constructor <init>(Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator;)V
    .registers 3

    .prologue
    const/4 v0, 0x0

    .line 11
    iput-object p1, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->this$0:Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 14
    iput v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->counter:I

    .line 15
    iput-boolean v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->stop:Z

    return-void
.end method

.method synthetic constructor <init>(Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator;Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$1;)V
    .registers 3

    .prologue
    .line 11
    invoke-direct {p0, p1}, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;-><init>(Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator;)V

    return-void
.end method


# virtual methods
.method public generateSeed(IZ)[B
    .registers 9

    .prologue
    const/4 v0, 0x0

    .line 30
    new-instance v1, Ljava/lang/Thread;

    invoke-direct {v1, p0}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    .line 31
    new-array v2, p1, [B

    .line 32
    iput v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->counter:I

    .line 33
    iput-boolean v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->stop:Z

    .line 37
    invoke-virtual {v1}, Ljava/lang/Thread;->start()V

    .line 38
    if-nez p2, :cond_13

    .line 44
    shl-int/lit8 p1, p1, 0x3

    :cond_13
    move v1, v0

    .line 46
    :goto_14
    if-ge v1, p1, :cond_39

    .line 48
    :goto_16
    iget v3, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->counter:I

    if-ne v3, v0, :cond_22

    .line 52
    const-wide/16 v4, 0x1

    :try_start_1c
    invoke-static {v4, v5}, Ljava/lang/Thread;->sleep(J)V
    :try_end_1f
    .catch Ljava/lang/InterruptedException; {:try_start_1c .. :try_end_1f} :catch_20

    goto :goto_16

    .line 57
    :catch_20
    move-exception v3

    goto :goto_16

    .line 59
    :cond_22
    iget v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->counter:I

    .line 60
    if-eqz p2, :cond_2c

    .line 62
    int-to-byte v3, v0

    aput-byte v3, v2, v1

    .line 46
    :goto_29
    add-int/lit8 v1, v1, 0x1

    goto :goto_14

    .line 66
    :cond_2c
    div-int/lit8 v3, v1, 0x8

    .line 67
    aget-byte v4, v2, v3

    shl-int/lit8 v4, v4, 0x1

    and-int/lit8 v5, v0, 0x1

    or-int/2addr v4, v5

    int-to-byte v4, v4

    aput-byte v4, v2, v3

    goto :goto_29

    .line 71
    :cond_39
    const/4 v0, 0x1

    iput-boolean v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->stop:Z

    .line 72
    return-object v2
.end method

.method public run()V
    .registers 2

    .prologue
    .line 19
    :goto_0
    iget-boolean v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->stop:Z

    if-nez v0, :cond_b

    .line 21
    iget v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->counter:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lorg/spongycastle/crypto/prng/ThreadedSeedGenerator$SeedGenerator;->counter:I

    goto :goto_0

    .line 24
    :cond_b
    return-void
.end method