r.smali
.class public final Lcom/subgraph/orchid/crypto/r;
.super Ljava/lang/Object;
.source "TorStreamCipher.java"
# instance fields
.field private bGs:I
.field final bGt:Ljavax/crypto/spec/SecretKeySpec;
.field private final cipher:Ljavax/crypto/Cipher;
.field private final counter:[B
.field private final counterOut:[B
# direct methods
.method constructor <init>([B)V
.registers 3
.prologue
.line 38
const/4 v0, 0x0
invoke-direct {p0, p1, v0}, Lcom/subgraph/orchid/crypto/r;-><init>([B[B)V
.line 39
return-void
.end method
.method public constructor <init>([B[B)V
.registers 7
.prologue
const/4 v3, 0x0
const/16 v2, 0x10
.line 41
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 33
const/4 v0, -0x1
iput v0, p0, Lcom/subgraph/orchid/crypto/r;->bGs:I
.line 1073
new-instance v0, Ljavax/crypto/spec/SecretKeySpec;
const-string v1, "AES"
invoke-direct {v0, p1, v1}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V
.line 42
iput-object v0, p0, Lcom/subgraph/orchid/crypto/r;->bGt:Ljavax/crypto/spec/SecretKeySpec;
.line 43
iget-object v0, p0, Lcom/subgraph/orchid/crypto/r;->bGt:Ljavax/crypto/spec/SecretKeySpec;
invoke-static {v0}, Lcom/subgraph/orchid/crypto/r;->a(Ljavax/crypto/spec/SecretKeySpec;)Ljavax/crypto/Cipher;
move-result-object v0
iput-object v0, p0, Lcom/subgraph/orchid/crypto/r;->cipher:Ljavax/crypto/Cipher;
.line 44
new-array v0, v2, [B
iput-object v0, p0, Lcom/subgraph/orchid/crypto/r;->counter:[B
.line 45
new-array v0, v2, [B
iput-object v0, p0, Lcom/subgraph/orchid/crypto/r;->counterOut:[B
.line 47
if-eqz p2, :cond_32
.line 2053
array-length v0, p2
if-eq v0, v2, :cond_2d
.line 2054
new-instance v0, Ljava/lang/IllegalArgumentException;
invoke-direct {v0}, Ljava/lang/IllegalArgumentException;-><init>()V
throw v0
.line 2056
:cond_2d
iget-object v0, p0, Lcom/subgraph/orchid/crypto/r;->counter:[B
invoke-static {p2, v3, v0, v3, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
.line 50
:cond_32
return-void
.end method
.method static Ml()Ljavax/crypto/SecretKey;
.registers 2
.prologue
.line 88
:try_start_0
const-string v0, "AES"
invoke-static {v0}, Ljavax/crypto/KeyGenerator;->getInstance(Ljava/lang/String;)Ljavax/crypto/KeyGenerator;
move-result-object v0
.line 89
const/16 v1, 0x80
invoke-virtual {v0, v1}, Ljavax/crypto/KeyGenerator;->init(I)V
.line 90
invoke-virtual {v0}, Ljavax/crypto/KeyGenerator;->generateKey()Ljavax/crypto/SecretKey;
:try_end_e
.catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_e} :catch_10
move-result-object v0
return-object v0
.line 91
:catch_10
move-exception v0
.line 92
new-instance v1, Lcom/subgraph/orchid/TorException;
invoke-direct {v1, v0}, Lcom/subgraph/orchid/TorException;-><init>(Ljava/lang/Throwable;)V
throw v1
.end method
.method private Mm()V
.registers 7
.prologue
.line 109
:try_start_0
iget-object v0, p0, Lcom/subgraph/orchid/crypto/r;->cipher:Ljavax/crypto/Cipher;
iget-object v1, p0, Lcom/subgraph/orchid/crypto/r;->counter:[B
const/4 v2, 0x0
const/16 v3, 0x10
iget-object v4, p0, Lcom/subgraph/orchid/crypto/r;->counterOut:[B
const/4 v5, 0x0
invoke-virtual/range {v0 .. v5}, Ljavax/crypto/Cipher;->doFinal([BII[BI)I
:try_end_d
.catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_d} :catch_e
.line 112
return-void
.line 110
:catch_e
move-exception v0
.line 111
new-instance v1, Lcom/subgraph/orchid/TorException;
invoke-direct {v1, v0}, Lcom/subgraph/orchid/TorException;-><init>(Ljava/lang/Throwable;)V
throw v1
.end method
.method private static a(Ljavax/crypto/spec/SecretKeySpec;)Ljavax/crypto/Cipher;
.registers 3
.prologue
.line 78
:try_start_0
const-string v0, "AES/ECB/NoPadding"
invoke-static {v0}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;
move-result-object v0
.line 79
const/4 v1, 0x1
invoke-virtual {v0, v1, p0}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;)V
:try_end_a
.catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_a} :catch_b
.line 80
return-object v0
.line 81
:catch_b
move-exception v0
.line 82
new-instance v1, Lcom/subgraph/orchid/TorException;
invoke-direct {v1, v0}, Lcom/subgraph/orchid/TorException;-><init>(Ljava/lang/Throwable;)V
throw v1
.end method
.method public static ao([B)Lcom/subgraph/orchid/crypto/r;
.registers 2
.prologue
.line 21
new-instance v0, Lcom/subgraph/orchid/crypto/r;
invoke-direct {v0, p0}, Lcom/subgraph/orchid/crypto/r;-><init>([B)V
return-object v0
.end method
# virtual methods
.method public final ap([B)V
.registers 4
.prologue
.line 60
const/4 v0, 0x0
array-length v1, p1
invoke-virtual {p0, p1, v0, v1}, Lcom/subgraph/orchid/crypto/r;->n([BII)V
.line 61
return-void
.end method
.method public final declared-synchronized n([BII)V
.registers 13
.prologue
const/4 v1, 0x1
const/4 v2, 0x0
.line 64
monitor-enter p0
move v4, v2
:goto_4
if-ge v4, p3, :cond_49
.line 65
add-int v5, v4, p2
:try_start_8
aget-byte v6, p1, v5
.line 2097
iget v0, p0, Lcom/subgraph/orchid/crypto/r;->bGs:I
const/4 v3, -0x1
if-eq v0, v3, :cond_15
iget v0, p0, Lcom/subgraph/orchid/crypto/r;->bGs:I
const/16 v3, 0x10
if-lt v0, v3, :cond_37
.line 2102
:cond_15
invoke-direct {p0}, Lcom/subgraph/orchid/crypto/r;->Mm()V
.line 2117
const/16 v0, 0xf
move v3, v0
move v0, v1
:goto_1c
if-ltz v3, :cond_34
.line 2118
iget-object v7, p0, Lcom/subgraph/orchid/crypto/r;->counter:[B
aget-byte v7, v7, v3
and-int/lit16 v7, v7, 0xff
add-int/2addr v7, v0
.line 2119
const/16 v0, 0xff
if-le v7, v0, :cond_32
move v0, v1
.line 2123
:goto_2a
iget-object v8, p0, Lcom/subgraph/orchid/crypto/r;->counter:[B
int-to-byte v7, v7
aput-byte v7, v8, v3
.line 2117
add-int/lit8 v3, v3, -0x1
goto :goto_1c
:cond_32
move v0, v2
.line 2122
goto :goto_2a
.line 2104
:cond_34
const/4 v0, 0x0
iput v0, p0, Lcom/subgraph/orchid/crypto/r;->bGs:I
.line 2099
:cond_37
iget-object v0, p0, Lcom/subgraph/orchid/crypto/r;->counterOut:[B
iget v3, p0, Lcom/subgraph/orchid/crypto/r;->bGs:I
add-int/lit8 v7, v3, 0x1
iput v7, p0, Lcom/subgraph/orchid/crypto/r;->bGs:I
aget-byte v0, v0, v3
.line 65
xor-int/2addr v0, v6
int-to-byte v0, v0
aput-byte v0, p1, v5
:try_end_45
.catchall {:try_start_8 .. :try_end_45} :catchall_4b
.line 64
add-int/lit8 v0, v4, 0x1
move v4, v0
goto :goto_4
.line 66
:cond_49
monitor-exit p0
return-void
.line 64
:catchall_4b
move-exception v0
monitor-exit p0
throw v0
.end method