.class public Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom; .super Ljava/security/SecureRandomSpi; .source "PRNGFixes.java" # annotations .annotation system Ldalvik/annotation/EnclosingClass; value = Lcz/msebera/android/httpclient/extras/PRNGFixes; .end annotation .annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x9 name = "LinuxPRNGSecureRandom" .end annotation # static fields .field private static final URANDOM_FILE:Ljava/io/File; .field private static final sLock:Ljava/lang/Object; .field private static sUrandomIn:Ljava/io/DataInputStream; .field private static sUrandomOut:Ljava/io/OutputStream; # instance fields .field private mSeeded:Z # direct methods .method public static constructor ()V .locals 2 .line 1 new-instance v0, Ljava/io/File; const-string v1, "/dev/urandom" invoke-direct {v0, v1}, Ljava/io/File;->(Ljava/lang/String;)V sput-object v0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->URANDOM_FILE:Ljava/io/File; .line 2 new-instance v0, Ljava/lang/Object; invoke-direct {v0}, Ljava/lang/Object;->()V sput-object v0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object; return-void .end method .method public constructor ()V .locals 0 .line 1 invoke-direct {p0}, Ljava/security/SecureRandomSpi;->()V return-void .end method .method private getUrandomInputStream()Ljava/io/DataInputStream; .locals 5 .line 1 sget-object v0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object; monitor-enter v0 .line 2 :try_start_0 sget-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sUrandomIn:Ljava/io/DataInputStream; :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 if-nez v1, :cond_0 .line 3 :try_start_1 new-instance v1, Ljava/io/DataInputStream; new-instance v2, Ljava/io/FileInputStream; sget-object v3, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->URANDOM_FILE:Ljava/io/File; invoke-direct {v2, v3}, Ljava/io/FileInputStream;->(Ljava/io/File;)V invoke-direct {v1, v2}, Ljava/io/DataInputStream;->(Ljava/io/InputStream;)V sput-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sUrandomIn:Ljava/io/DataInputStream; :try_end_1 .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0 .catchall {:try_start_1 .. :try_end_1} :catchall_0 goto :goto_0 :catch_0 move-exception v1 .line 4 :try_start_2 new-instance v2, Ljava/lang/SecurityException; new-instance v3, Ljava/lang/StringBuilder; invoke-direct {v3}, Ljava/lang/StringBuilder;->()V const-string v4, "Failed to open " invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; sget-object v4, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->URANDOM_FILE:Ljava/io/File; invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; const-string v4, " for reading" invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v3 invoke-direct {v2, v3, v1}, Ljava/lang/SecurityException;->(Ljava/lang/String;Ljava/lang/Throwable;)V throw v2 .line 5 :cond_0 :goto_0 sget-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sUrandomIn:Ljava/io/DataInputStream; monitor-exit v0 return-object v1 :catchall_0 move-exception v1 .line 6 monitor-exit v0 :try_end_2 .catchall {:try_start_2 .. :try_end_2} :catchall_0 throw v1 .end method .method private getUrandomOutputStream()Ljava/io/OutputStream; .locals 3 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation .line 1 sget-object v0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object; monitor-enter v0 .line 2 :try_start_0 sget-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sUrandomOut:Ljava/io/OutputStream; if-nez v1, :cond_0 .line 3 new-instance v1, Ljava/io/FileOutputStream; sget-object v2, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->URANDOM_FILE:Ljava/io/File; invoke-direct {v1, v2}, Ljava/io/FileOutputStream;->(Ljava/io/File;)V sput-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sUrandomOut:Ljava/io/OutputStream; .line 4 :cond_0 sget-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sUrandomOut:Ljava/io/OutputStream; monitor-exit v0 return-object v1 :catchall_0 move-exception v1 .line 5 monitor-exit v0 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 throw v1 .end method # virtual methods .method public engineGenerateSeed(I)[B .locals 0 .line 1 new-array p1, p1, [B .line 2 invoke-virtual {p0, p1}, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->engineNextBytes([B)V return-object p1 .end method .method public engineNextBytes([B)V .locals 3 .line 1 iget-boolean v0, p0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z if-nez v0, :cond_0 .line 2 invoke-static {}, Lcz/msebera/android/httpclient/extras/PRNGFixes;->a()[B move-result-object v0 invoke-virtual {p0, v0}, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->engineSetSeed([B)V .line 3 :cond_0 :try_start_0 sget-object v0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object; monitor-enter v0 :try_end_0 .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 .line 4 :try_start_1 invoke-direct {p0}, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->getUrandomInputStream()Ljava/io/DataInputStream; move-result-object v1 .line 5 monitor-exit v0 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_1 .line 6 :try_start_2 monitor-enter v1 :try_end_2 .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0 .line 7 :try_start_3 invoke-virtual {v1, p1}, Ljava/io/DataInputStream;->readFully([B)V .line 8 monitor-exit v1 return-void :catchall_0 move-exception p1 monitor-exit v1 :try_end_3 .catchall {:try_start_3 .. :try_end_3} :catchall_0 :try_start_4 throw p1 :try_end_4 .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0 :catchall_1 move-exception p1 .line 9 :try_start_5 monitor-exit v0 :try_end_5 .catchall {:try_start_5 .. :try_end_5} :catchall_1 :try_start_6 throw p1 :try_end_6 .catch Ljava/io/IOException; {:try_start_6 .. :try_end_6} :catch_0 :catch_0 move-exception p1 .line 10 new-instance v0, Ljava/lang/SecurityException; const-string v1, "Failed to read from " invoke-static {v1}, Landroid/support/v4/media/d;->a(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v1 sget-object v2, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->URANDOM_FILE:Ljava/io/File; invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v1 invoke-direct {v0, v1, p1}, Ljava/lang/SecurityException;->(Ljava/lang/String;Ljava/lang/Throwable;)V throw v0 .end method .method public engineSetSeed([B)V .locals 3 const/4 v0, 0x1 .line 1 :try_start_0 sget-object v1, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->sLock:Ljava/lang/Object; monitor-enter v1 :try_end_0 .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 .catchall {:try_start_0 .. :try_end_0} :catchall_1 .line 2 :try_start_1 invoke-direct {p0}, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->getUrandomOutputStream()Ljava/io/OutputStream; move-result-object v2 .line 3 monitor-exit v1 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_0 .line 4 :try_start_2 invoke-virtual {v2, p1}, Ljava/io/OutputStream;->write([B)V .line 5 invoke-virtual {v2}, Ljava/io/OutputStream;->flush()V :try_end_2 .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0 .catchall {:try_start_2 .. :try_end_2} :catchall_1 .line 6 :goto_0 iput-boolean v0, p0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z goto :goto_1 :catchall_0 move-exception p1 .line 7 :try_start_3 monitor-exit v1 :try_end_3 .catchall {:try_start_3 .. :try_end_3} :catchall_0 :try_start_4 throw p1 :try_end_4 .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0 .catchall {:try_start_4 .. :try_end_4} :catchall_1 :catchall_1 move-exception p1 goto :goto_2 .line 8 :catch_0 :try_start_5 const-class p1, Lcz/msebera/android/httpclient/extras/PRNGFixes; invoke-virtual {p1}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String; move-result-object p1 new-instance v1, Ljava/lang/StringBuilder; invoke-direct {v1}, Ljava/lang/StringBuilder;->()V const-string v2, "Failed to mix seed into " invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; sget-object v2, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->URANDOM_FILE:Ljava/io/File; invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v1 invoke-static {p1, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I :try_end_5 .catchall {:try_start_5 .. :try_end_5} :catchall_1 goto :goto_0 :goto_1 return-void .line 9 :goto_2 iput-boolean v0, p0, Lcz/msebera/android/httpclient/extras/PRNGFixes$LinuxPRNGSecureRandom;->mSeeded:Z throw p1 .end method