AESHelper.smali
.class public Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;
.super Ljava/lang/Object;
.source "AESHelper.java"
# instance fields
.field final KEY_ALGORITHM:Ljava/lang/String;
.field final algorithmStr:Ljava/lang/String;
.field private cipher:Ljavax/crypto/Cipher;
.field iv:[B
.field private key:Ljava/security/Key;
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>()V
.registers 2
.line 24
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 27
const-string v0, "AES"
iput-object v0, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->KEY_ALGORITHM:Ljava/lang/String;
.line 29
const-string v0, "AES/CBC/PKCS7Padding"
iput-object v0, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->algorithmStr:Ljava/lang/String;
return-void
.end method
# virtual methods
.method public PKCS7Padding([B)[B
.registers 8
.param p1, "inputByte" # [B
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
}
.end annotation
.line 39
:try_start_0
array-length v0, p1
.line 41
.local v0, "length":I
rem-int/lit8 v1, v0, 0x10
const/16 v2, 0x10
if-nez v1, :cond_a
const/16 v1, 0x10
goto :goto_c
:cond_a
rem-int/lit8 v1, v0, 0x10
:goto_c
rsub-int/lit8 v1, v1, 0x10
.line 43
.local v1, "leftLength":I
add-int v3, v0, v1
new-array v3, v3, [B
.line 45
.local v3, "arrayReturn":[B
new-array v2, v2, [B
const/4 v4, 0x0
aput-byte v4, v2, v4
const/4 v4, 0x1
aput-byte v4, v2, v4
const/4 v4, 0x2
aput-byte v4, v2, v4
const/4 v4, 0x3
aput-byte v4, v2, v4
const/4 v4, 0x4
aput-byte v4, v2, v4
const/4 v4, 0x5
aput-byte v4, v2, v4
const/4 v4, 0x6
aput-byte v4, v2, v4
const/4 v4, 0x7
aput-byte v4, v2, v4
const/16 v4, 0x8
aput-byte v4, v2, v4
const/16 v4, 0x9
aput-byte v4, v2, v4
const/16 v4, 0xa
aput-byte v4, v2, v4
const/16 v4, 0xb
aput-byte v4, v2, v4
const/16 v4, 0xc
aput-byte v4, v2, v4
const/16 v4, 0xd
aput-byte v4, v2, v4
const/16 v4, 0xe
aput-byte v4, v2, v4
const/16 v4, 0xf
aput-byte v4, v2, v4
.line 49
.local v2, "plusbyte":[B
if-lez v1, :cond_64
.line 51
const/4 v4, 0x0
.local v4, "i":I
:goto_4f
add-int v5, v0, v1
if-ge v4, v5, :cond_61
.line 52
if-ge v4, v0, :cond_5a
.line 54
aget-byte v5, p1, v4
aput-byte v5, v3, v4
goto :goto_5e
.line 57
:cond_5a
aget-byte v5, v2, v1
aput-byte v5, v3, v4
.line 51
:goto_5e
add-int/lit8 v4, v4, 0x1
goto :goto_4f
.line 65
.end local v4 # "i":I
:cond_61
iput-object v3, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->iv:[B
.line 66
return-object v3
.line 62
:cond_64
iput-object v3, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->iv:[B
:try_end_66
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_66} :catch_67
.line 63
return-object p1
.line 67
.end local v0 # "length":I
.end local v1 # "leftLength":I
.end local v2 # "plusbyte":[B
.end local v3 # "arrayReturn":[B
:catch_67
move-exception v0
.line 68
.local v0, "e":Ljava/lang/Exception;
new-instance v1, Ljava/lang/Exception;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "\u6570\u636e\u5f02\u5e38\uff0cPKCS5Padding\u586b\u5145\u6a21\u5f0f\u9519\u8bef\uff0c\u5f02\u5e38\u629b\u51fa\uff01"
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;
move-result-object v3
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V
goto :goto_84
:goto_83
throw v1
:goto_84
goto :goto_83
.end method
.method public decrypt([B[B)[B
.registers 9
.param p1, "encryptedData" # [B
.param p2, "keyBytes" # [B
.line 131
const/4 v0, 0x0
.line 132
.local v0, "encryptedText":[B
invoke-virtual {p0, p2}, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->init([B)V
.line 133
sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "IV\uff1a"
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
new-instance v3, Ljava/lang/String;
iget-object v4, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->iv:[B
invoke-direct {v3, v4}, Ljava/lang/String;-><init>([B)V
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
.line 135
:try_start_21
iget-object v1, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->cipher:Ljavax/crypto/Cipher;
const/4 v2, 0x2
iget-object v3, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->key:Ljava/security/Key;
new-instance v4, Ljavax/crypto/spec/IvParameterSpec;
iget-object v5, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->iv:[B
invoke-direct {v4, v5}, Ljavax/crypto/spec/IvParameterSpec;-><init>([B)V
invoke-virtual {v1, v2, v3, v4}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V
.line 136
iget-object v1, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->cipher:Ljavax/crypto/Cipher;
invoke-virtual {v1, p1}, Ljavax/crypto/Cipher;->doFinal([B)[B
move-result-object v1
:try_end_36
.catch Ljava/lang/Exception; {:try_start_21 .. :try_end_36} :catch_38
move-object v0, v1
.line 140
goto :goto_3c
.line 137
:catch_38
move-exception v1
.line 139
.local v1, "e":Ljava/lang/Exception;
invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V
.line 141
.end local v1 # "e":Ljava/lang/Exception;
:goto_3c
return-object v0
.end method
.method public encrypt([B[B)[B
.registers 9
.param p1, "content" # [B
.param p2, "keyBytes" # [B
.line 110
const/4 v0, 0x0
.line 111
.local v0, "encryptedText":[B
invoke-virtual {p0, p2}, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->init([B)V
.line 112
sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "IV\uff1a"
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
new-instance v3, Ljava/lang/String;
iget-object v4, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->iv:[B
invoke-direct {v3, v4}, Ljava/lang/String;-><init>([B)V
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
.line 114
:try_start_21
iget-object v1, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->cipher:Ljavax/crypto/Cipher;
const/4 v2, 0x1
iget-object v3, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->key:Ljava/security/Key;
new-instance v4, Ljavax/crypto/spec/IvParameterSpec;
iget-object v5, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->iv:[B
invoke-direct {v4, v5}, Ljavax/crypto/spec/IvParameterSpec;-><init>([B)V
invoke-virtual {v1, v2, v3, v4}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V
.line 115
iget-object v1, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->cipher:Ljavax/crypto/Cipher;
invoke-virtual {v1, p1}, Ljavax/crypto/Cipher;->doFinal([B)[B
move-result-object v1
:try_end_36
.catch Ljava/lang/Exception; {:try_start_21 .. :try_end_36} :catch_38
move-object v0, v1
.line 119
goto :goto_3c
.line 116
:catch_38
move-exception v1
.line 118
.local v1, "e":Ljava/lang/Exception;
invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V
.line 120
.end local v1 # "e":Ljava/lang/Exception;
:goto_3c
return-object v0
.end method
.method public init([B)V
.registers 4
.param p1, "keyBytes" # [B
.line 77
:try_start_0
invoke-virtual {p0, p1}, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->PKCS7Padding([B)[B
move-result-object v0
:try_end_4
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_4} :catch_6
move-object p1, v0
.line 80
goto :goto_a
.line 78
:catch_6
move-exception v0
.line 79
.local v0, "e":Ljava/lang/Exception;
invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
.line 86
.end local v0 # "e":Ljava/lang/Exception;
:goto_a
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
iput-object v0, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->key:Ljava/security/Key;
.line 89
:try_start_13
const-string v0, "AES/CBC/PKCS7Padding"
const-string v1, "BC"
invoke-static {v0, v1}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;Ljava/lang/String;)Ljavax/crypto/Cipher;
move-result-object v0
iput-object v0, p0, Lim/tpelyyftgw/ui/hui/friendscircle/okhttphelper/AESHelper;->cipher:Ljavax/crypto/Cipher;
:try_end_1d
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_13 .. :try_end_1d} :catch_28
.catch Ljavax/crypto/NoSuchPaddingException; {:try_start_13 .. :try_end_1d} :catch_23
.catch Ljava/security/NoSuchProviderException; {:try_start_13 .. :try_end_1d} :catch_1e
goto :goto_2c
.line 96
:catch_1e
move-exception v0
.line 98
.local v0, "e":Ljava/security/NoSuchProviderException;
invoke-virtual {v0}, Ljava/security/NoSuchProviderException;->printStackTrace()V
goto :goto_2d
.line 93
.end local v0 # "e":Ljava/security/NoSuchProviderException;
:catch_23
move-exception v0
.line 95
.local v0, "e":Ljavax/crypto/NoSuchPaddingException;
invoke-virtual {v0}, Ljavax/crypto/NoSuchPaddingException;->printStackTrace()V
.end local v0 # "e":Ljavax/crypto/NoSuchPaddingException;
goto :goto_2c
.line 90
:catch_28
move-exception v0
.line 92
.local v0, "e":Ljava/security/NoSuchAlgorithmException;
invoke-virtual {v0}, Ljava/security/NoSuchAlgorithmException;->printStackTrace()V
.line 99
.end local v0 # "e":Ljava/security/NoSuchAlgorithmException;
:goto_2c
nop
.line 100
:goto_2d
return-void
.end method