PRNGFixes$LinuxPRNGSecureRandom.smali
.class public Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;
.super Ljava/security/SecureRandomSpi;
.source "PRNGFixes.java"
# static fields
.field private static final bFT:Ljava/io/File;
.field private static bFU:Ljava/io/DataInputStream; = null
.field private static bFV:Ljava/io/OutputStream; = null
.field private static final sLock:Ljava/lang/Object;
.field private static final serialVersionUID:J = 0x1L
# instance fields
.field private mSeeded:Z
# direct methods
.method static constructor <clinit>()V
.registers 2
.prologue
.line 186
new-instance v0, Ljava/io/File;
const-string v1, "/dev/urandom"
invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
sput-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFT:Ljava/io/File;
.line 188
new-instance v0, Ljava/lang/Object;
invoke-direct {v0}, Ljava/lang/Object;-><init>()V
sput-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object;
return-void
.end method
.method public constructor <init>()V
.registers 1
.prologue
.line 169
invoke-direct {p0}, Ljava/security/SecureRandomSpi;-><init>()V
return-void
.end method
.method private static LZ()Ljava/io/DataInputStream;
.registers 5
.prologue
.line 260
sget-object v1, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object;
monitor-enter v1
.line 261
:try_start_3
sget-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFU:Ljava/io/DataInputStream;
:try_end_5
.catchall {:try_start_3 .. :try_end_5} :catchall_37
if-nez v0, :cond_15
.line 267
:try_start_7
new-instance v0, Ljava/io/DataInputStream;
new-instance v2, Ljava/io/FileInputStream;
sget-object v3, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFT:Ljava/io/File;
invoke-direct {v2, v3}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
invoke-direct {v0, v2}, Ljava/io/DataInputStream;-><init>(Ljava/io/InputStream;)V
sput-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFU:Ljava/io/DataInputStream;
:try_end_15
.catch Ljava/io/IOException; {:try_start_7 .. :try_end_15} :catch_19
.catchall {:try_start_7 .. :try_end_15} :catchall_37
.line 274
:cond_15
:try_start_15
sget-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFU:Ljava/io/DataInputStream;
monitor-exit v1
return-object v0
.line 269
:catch_19
move-exception v0
.line 270
new-instance v2, Ljava/lang/SecurityException;
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "Failed to open "
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
sget-object v4, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFT:Ljava/io/File;
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v3
const-string v4, " for reading"
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
invoke-direct {v2, v3, v0}, Ljava/lang/SecurityException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v2
.line 275
:catchall_37
move-exception v0
monitor-exit v1
:try_end_39
.catchall {:try_start_15 .. :try_end_39} :catchall_37
throw v0
.end method
.method private static Ma()Ljava/io/OutputStream;
.registers 3
.prologue
.line 279
sget-object v1, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object;
monitor-enter v1
.line 280
:try_start_3
sget-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFV:Ljava/io/OutputStream;
if-nez v0, :cond_10
.line 281
new-instance v0, Ljava/io/FileOutputStream;
sget-object v2, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFT:Ljava/io/File;
invoke-direct {v0, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
sput-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFV:Ljava/io/OutputStream;
.line 283
:cond_10
sget-object v0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFV:Ljava/io/OutputStream;
monitor-exit v1
return-object v0
.line 284
:catchall_14
move-exception v0
monitor-exit v1
:try_end_16
.catchall {:try_start_3 .. :try_end_16} :catchall_14
throw v0
.end method
# virtual methods
.method protected engineGenerateSeed(I)[B
.registers 3
.prologue
.line 254
new-array v0, p1, [B
.line 255
invoke-virtual {p0, v0}, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->engineNextBytes([B)V
.line 256
return-object v0
.end method
.method protected engineNextBytes([B)V
.registers 6
.prologue
.line 233
iget-boolean v0, p0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z
if-nez v0, :cond_b
.line 235
invoke-static {}, Lcom/subgraph/orchid/crypto/PRNGFixes;->LY()[B
move-result-object v0
invoke-virtual {p0, v0}, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->engineSetSeed([B)V
.line 240
:cond_b
:try_start_b
sget-object v1, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object;
monitor-enter v1
:try_end_e
.catch Ljava/io/IOException; {:try_start_b .. :try_end_e} :catch_1c
.line 241
:try_start_e
invoke-static {}, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->LZ()Ljava/io/DataInputStream;
move-result-object v2
.line 242
monitor-exit v1
:try_end_13
.catchall {:try_start_e .. :try_end_13} :catchall_19
.line 243
:try_start_13
monitor-enter v2
:try_end_14
.catch Ljava/io/IOException; {:try_start_13 .. :try_end_14} :catch_1c
.line 244
:try_start_14
invoke-virtual {v2, p1}, Ljava/io/DataInputStream;->readFully([B)V
.line 245
monitor-exit v2
:try_end_18
.catchall {:try_start_14 .. :try_end_18} :catchall_34
return-void
.line 242
:catchall_19
move-exception v0
:try_start_1a
monitor-exit v1
:try_end_1b
.catchall {:try_start_1a .. :try_end_1b} :catchall_19
:try_start_1b
throw v0
:try_end_1c
.catch Ljava/io/IOException; {:try_start_1b .. :try_end_1c} :catch_1c
.line 246
:catch_1c
move-exception v0
.line 247
new-instance v1, Ljava/lang/SecurityException;
new-instance v2, Ljava/lang/StringBuilder;
const-string v3, "Failed to read from "
invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
sget-object v3, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFT:Ljava/io/File;
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2, v0}, Ljava/lang/SecurityException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
.line 245
:catchall_34
move-exception v0
:try_start_35
monitor-exit v2
:try_end_36
.catchall {:try_start_35 .. :try_end_36} :catchall_34
:try_start_36
throw v0
:try_end_37
.catch Ljava/io/IOException; {:try_start_36 .. :try_end_37} :catch_1c
.end method
.method protected engineSetSeed([B)V
.registers 6
.prologue
const/4 v3, 0x1
.line 217
:try_start_1
sget-object v1, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object;
monitor-enter v1
:try_end_4
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_4} :catch_15
.catchall {:try_start_1 .. :try_end_4} :catchall_31
.line 218
:try_start_4
invoke-static {}, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->Ma()Ljava/io/OutputStream;
move-result-object v0
.line 219
monitor-exit v1
:try_end_9
.catchall {:try_start_4 .. :try_end_9} :catchall_12
.line 220
:try_start_9
invoke-virtual {v0, p1}, Ljava/io/OutputStream;->write([B)V
.line 221
invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V
:try_end_f
.catch Ljava/io/IOException; {:try_start_9 .. :try_end_f} :catch_15
.catchall {:try_start_9 .. :try_end_f} :catchall_31
.line 227
iput-boolean v3, p0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z
.line 228
:goto_11
return-void
.line 219
:catchall_12
move-exception v0
:try_start_13
monitor-exit v1
:try_end_14
.catchall {:try_start_13 .. :try_end_14} :catchall_12
:try_start_14
throw v0
:try_end_15
.catch Ljava/io/IOException; {:try_start_14 .. :try_end_15} :catch_15
.catchall {:try_start_14 .. :try_end_15} :catchall_31
.line 225
:catch_15
move-exception v0
:try_start_16
# getter for: Lcom/subgraph/orchid/crypto/PRNGFixes;->logger:Ljava/util/logging/Logger;
invoke-static {}, Lcom/subgraph/orchid/crypto/PRNGFixes;->access$000()Ljava/util/logging/Logger;
move-result-object v0
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Failed to mix seed into "
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
sget-object v2, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->bFT:Ljava/io/File;
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/util/logging/Logger;->warning(Ljava/lang/String;)V
:try_end_2e
.catchall {:try_start_16 .. :try_end_2e} :catchall_31
.line 227
iput-boolean v3, p0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z
goto :goto_11
:catchall_31
move-exception v0
iput-boolean v3, p0, Lcom/subgraph/orchid/crypto/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z
throw v0
.end method