SecureRandomInitializer.smali

.class public Laegon/chrome/base/SecureRandomInitializer;
.super Ljava/lang/Object;


# annotations
.annotation build Landroid/annotation/SuppressLint;
    value = {
        "SecureRandom"
    }
.end annotation


# static fields
.field private static final NUM_RANDOM_BYTES:I = 0x10


# direct methods
.method public constructor <init>()V
    .registers 1

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

    return-void
.end method

.method public static initialize(Ljava/security/SecureRandom;)V
    .registers 7

    new-instance v2, Ljava/io/FileInputStream;

    const-string v0, "/dev/urandom"

    invoke-direct {v2, v0}, Ljava/io/FileInputStream;-><init>(Ljava/lang/String;)V

    const/4 v1, 0x0

    const/16 v0, 0x10

    :try_start_a
    new-array v0, v0, [B

    invoke-virtual {v2, v0}, Ljava/io/FileInputStream;->read([B)I

    move-result v3

    array-length v4, v0

    if-eq v3, v4, :cond_27

    new-instance v0, Ljava/io/IOException;

    const-string v3, "Failed to get enough random data."

    invoke-direct {v0, v3}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v0
    :try_end_1b
    .catch Ljava/lang/Throwable; {:try_start_a .. :try_end_1b} :catch_1b
    .catchall {:try_start_a .. :try_end_1b} :catchall_42

    :catch_1b
    move-exception v0

    :try_start_1c
    throw v0
    :try_end_1d
    .catchall {:try_start_1c .. :try_end_1d} :catchall_1d

    :catchall_1d
    move-exception v1

    move-object v5, v1

    move-object v1, v0

    move-object v0, v5

    :goto_21
    if-eqz v1, :cond_3e

    :try_start_23
    invoke-virtual {v2}, Ljava/io/FileInputStream;->close()V
    :try_end_26
    .catch Ljava/lang/Throwable; {:try_start_23 .. :try_end_26} :catch_39

    :goto_26
    throw v0

    :cond_27
    :try_start_27
    invoke-virtual {p0, v0}, Ljava/security/SecureRandom;->setSeed([B)V
    :try_end_2a
    .catch Ljava/lang/Throwable; {:try_start_27 .. :try_end_2a} :catch_1b
    .catchall {:try_start_27 .. :try_end_2a} :catchall_42

    if-eqz v1, :cond_35

    :try_start_2c
    invoke-virtual {v2}, Ljava/io/FileInputStream;->close()V
    :try_end_2f
    .catch Ljava/lang/Throwable; {:try_start_2c .. :try_end_2f} :catch_30

    :goto_2f
    return-void

    :catch_30
    move-exception v0

    invoke-virtual {v1, v0}, Ljava/lang/Throwable;->addSuppressed(Ljava/lang/Throwable;)V

    goto :goto_2f

    :cond_35
    invoke-virtual {v2}, Ljava/io/FileInputStream;->close()V

    goto :goto_2f

    :catch_39
    move-exception v2

    invoke-virtual {v1, v2}, Ljava/lang/Throwable;->addSuppressed(Ljava/lang/Throwable;)V

    goto :goto_26

    :cond_3e
    invoke-virtual {v2}, Ljava/io/FileInputStream;->close()V

    goto :goto_26

    :catchall_42
    move-exception v0

    goto :goto_21
.end method