455 lines
15 KiB
Smali
455 lines
15 KiB
Smali
.class Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;
|
|
.super Ljava/lang/Object;
|
|
.source "CognitoUser.java"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/EnclosingClass;
|
|
value = Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/InnerClass;
|
|
accessFlags = 0x9
|
|
name = "AuthenticationHelper"
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field private static final DERIVED_KEY_INFO:Ljava/lang/String; = "Caldera Derived Key"
|
|
|
|
.field private static final DERIVED_KEY_SIZE:I = 0x10
|
|
|
|
.field private static final EPHEMERAL_KEY_LENGTH:I = 0x400
|
|
|
|
.field private static final GG:Ljava/math/BigInteger;
|
|
|
|
.field private static final HEX_N:Ljava/lang/String; = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
|
|
|
|
.field private static final KK:Ljava/math/BigInteger;
|
|
|
|
.field private static final N:Ljava/math/BigInteger;
|
|
|
|
.field private static final SECURE_RANDOM:Ljava/security/SecureRandom;
|
|
|
|
.field private static final THREAD_MESSAGE_DIGEST:Ljava/lang/ThreadLocal;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/lang/ThreadLocal<",
|
|
"Ljava/security/MessageDigest;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# instance fields
|
|
.field private A:Ljava/math/BigInteger;
|
|
|
|
.field private a:Ljava/math/BigInteger;
|
|
|
|
.field private poolName:Ljava/lang/String;
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 4
|
|
|
|
.line 1
|
|
new-instance v0, Ljava/math/BigInteger;
|
|
|
|
const-string v1, "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
|
|
|
|
const/16 v2, 0x10
|
|
|
|
invoke-direct {v0, v1, v2}, Ljava/math/BigInteger;-><init>(Ljava/lang/String;I)V
|
|
|
|
sput-object v0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->N:Ljava/math/BigInteger;
|
|
|
|
const-wide/16 v1, 0x2
|
|
|
|
.line 2
|
|
invoke-static {v1, v2}, Ljava/math/BigInteger;->valueOf(J)Ljava/math/BigInteger;
|
|
|
|
move-result-object v1
|
|
|
|
sput-object v1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->GG:Ljava/math/BigInteger;
|
|
|
|
.line 3
|
|
new-instance v2, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper$1;
|
|
|
|
invoke-direct {v2}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper$1;-><init>()V
|
|
|
|
sput-object v2, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->THREAD_MESSAGE_DIGEST:Ljava/lang/ThreadLocal;
|
|
|
|
:try_start_0
|
|
const-string v3, "SHA1PRNG"
|
|
|
|
.line 4
|
|
invoke-static {v3}, Ljava/security/SecureRandom;->getInstance(Ljava/lang/String;)Ljava/security/SecureRandom;
|
|
|
|
move-result-object v3
|
|
|
|
sput-object v3, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->SECURE_RANDOM:Ljava/security/SecureRandom;
|
|
|
|
.line 5
|
|
invoke-virtual {v2}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/security/MessageDigest;
|
|
|
|
.line 6
|
|
invoke-virtual {v2}, Ljava/security/MessageDigest;->reset()V
|
|
|
|
.line 7
|
|
invoke-virtual {v0}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v2, v0}, Ljava/security/MessageDigest;->update([B)V
|
|
|
|
.line 8
|
|
invoke-virtual {v1}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v2, v0}, Ljava/security/MessageDigest;->digest([B)[B
|
|
|
|
move-result-object v0
|
|
|
|
.line 9
|
|
new-instance v1, Ljava/math/BigInteger;
|
|
|
|
const/4 v2, 0x1
|
|
|
|
invoke-direct {v1, v2, v0}, Ljava/math/BigInteger;-><init>(I[B)V
|
|
|
|
sput-object v1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->KK:Ljava/math/BigInteger;
|
|
:try_end_0
|
|
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
return-void
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
.line 10
|
|
new-instance v1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/exceptions/CognitoInternalErrorException;
|
|
|
|
invoke-virtual {v0}, Ljava/security/NoSuchAlgorithmException;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-direct {v1, v2, v0}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/exceptions/CognitoInternalErrorException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
|
|
|
throw v1
|
|
.end method
|
|
|
|
.method public constructor <init>(Ljava/lang/String;)V
|
|
.locals 3
|
|
|
|
.line 1
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
.line 2
|
|
:cond_0
|
|
new-instance v0, Ljava/math/BigInteger;
|
|
|
|
const/16 v1, 0x400
|
|
|
|
sget-object v2, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->SECURE_RANDOM:Ljava/security/SecureRandom;
|
|
|
|
invoke-direct {v0, v1, v2}, Ljava/math/BigInteger;-><init>(ILjava/util/Random;)V
|
|
|
|
sget-object v1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->N:Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {v0, v1}, Ljava/math/BigInteger;->mod(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object v0
|
|
|
|
iput-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->a:Ljava/math/BigInteger;
|
|
|
|
.line 3
|
|
sget-object v2, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->GG:Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {v2, v0, v1}, Ljava/math/BigInteger;->modPow(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object v0
|
|
|
|
iput-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->A:Ljava/math/BigInteger;
|
|
|
|
.line 4
|
|
invoke-virtual {v0, v1}, Ljava/math/BigInteger;->mod(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object v0
|
|
|
|
sget-object v1, Ljava/math/BigInteger;->ZERO:Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {v0, v1}, Ljava/math/BigInteger;->equals(Ljava/lang/Object;)Z
|
|
|
|
move-result v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
const-string v0, "_"
|
|
|
|
.line 5
|
|
invoke-virtual {p1, v0}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_1
|
|
|
|
const/4 v1, 0x2
|
|
|
|
.line 6
|
|
invoke-virtual {p1, v0, v1}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 v0, 0x1
|
|
|
|
aget-object p1, p1, v0
|
|
|
|
iput-object p1, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->poolName:Ljava/lang/String;
|
|
|
|
goto :goto_0
|
|
|
|
.line 7
|
|
:cond_1
|
|
iput-object p1, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->poolName:Ljava/lang/String;
|
|
|
|
:goto_0
|
|
return-void
|
|
.end method
|
|
|
|
.method public static synthetic access$3000()Ljava/math/BigInteger;
|
|
.locals 1
|
|
|
|
.line 1
|
|
sget-object v0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->N:Ljava/math/BigInteger;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public getA()Ljava/math/BigInteger;
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->A:Ljava/math/BigInteger;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public getPasswordAuthenticationKey(Ljava/lang/String;Ljava/lang/String;Ljava/math/BigInteger;Ljava/math/BigInteger;)[B
|
|
.locals 5
|
|
|
|
.line 1
|
|
sget-object v0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->THREAD_MESSAGE_DIGEST:Ljava/lang/ThreadLocal;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, Ljava/security/MessageDigest;
|
|
|
|
.line 2
|
|
invoke-virtual {v0}, Ljava/security/MessageDigest;->reset()V
|
|
|
|
.line 3
|
|
iget-object v1, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->A:Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {v1}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Ljava/security/MessageDigest;->update([B)V
|
|
|
|
.line 4
|
|
new-instance v1, Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {p3}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object v2
|
|
|
|
invoke-virtual {v0, v2}, Ljava/security/MessageDigest;->digest([B)[B
|
|
|
|
move-result-object v2
|
|
|
|
const/4 v3, 0x1
|
|
|
|
invoke-direct {v1, v3, v2}, Ljava/math/BigInteger;-><init>(I[B)V
|
|
|
|
.line 5
|
|
sget-object v2, Ljava/math/BigInteger;->ZERO:Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {v1, v2}, Ljava/math/BigInteger;->equals(Ljava/lang/Object;)Z
|
|
|
|
move-result v2
|
|
|
|
if-nez v2, :cond_0
|
|
|
|
.line 6
|
|
invoke-virtual {v0}, Ljava/security/MessageDigest;->reset()V
|
|
|
|
.line 7
|
|
iget-object v2, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->poolName:Ljava/lang/String;
|
|
|
|
sget-object v4, Lcom/amazonaws/util/StringUtils;->UTF8:Ljava/nio/charset/Charset;
|
|
|
|
invoke-virtual {v2, v4}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
|
|
|
|
move-result-object v2
|
|
|
|
invoke-virtual {v0, v2}, Ljava/security/MessageDigest;->update([B)V
|
|
|
|
.line 8
|
|
invoke-virtual {p1, v4}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v0, p1}, Ljava/security/MessageDigest;->update([B)V
|
|
|
|
const-string p1, ":"
|
|
|
|
.line 9
|
|
invoke-virtual {p1, v4}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v0, p1}, Ljava/security/MessageDigest;->update([B)V
|
|
|
|
.line 10
|
|
invoke-virtual {p2, v4}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v0, p1}, Ljava/security/MessageDigest;->digest([B)[B
|
|
|
|
move-result-object p1
|
|
|
|
.line 11
|
|
invoke-virtual {v0}, Ljava/security/MessageDigest;->reset()V
|
|
|
|
.line 12
|
|
invoke-virtual {p4}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {v0, p2}, Ljava/security/MessageDigest;->update([B)V
|
|
|
|
.line 13
|
|
new-instance p2, Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/security/MessageDigest;->digest([B)[B
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {p2, v3, p1}, Ljava/math/BigInteger;-><init>(I[B)V
|
|
|
|
.line 14
|
|
sget-object p1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->KK:Ljava/math/BigInteger;
|
|
|
|
sget-object p4, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->GG:Ljava/math/BigInteger;
|
|
|
|
sget-object v0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->N:Ljava/math/BigInteger;
|
|
|
|
invoke-virtual {p4, p2, v0}, Ljava/math/BigInteger;->modPow(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p4
|
|
|
|
invoke-virtual {p1, p4}, Ljava/math/BigInteger;->multiply(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p3, p1}, Ljava/math/BigInteger;->subtract(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p1
|
|
|
|
iget-object p3, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->a:Ljava/math/BigInteger;
|
|
|
|
.line 15
|
|
invoke-virtual {v1, p2}, Ljava/math/BigInteger;->multiply(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p3, p2}, Ljava/math/BigInteger;->add(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p1, p2, v0}, Ljava/math/BigInteger;->modPow(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p1, v0}, Ljava/math/BigInteger;->mod(Ljava/math/BigInteger;)Ljava/math/BigInteger;
|
|
|
|
move-result-object p1
|
|
|
|
:try_start_0
|
|
const-string p2, "HmacSHA256"
|
|
|
|
.line 16
|
|
invoke-static {p2}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/util/Hkdf;->getInstance(Ljava/lang/String;)Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/util/Hkdf;
|
|
|
|
move-result-object p2
|
|
:try_end_0
|
|
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
.line 17
|
|
invoke-virtual {p1}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v1}, Ljava/math/BigInteger;->toByteArray()[B
|
|
|
|
move-result-object p3
|
|
|
|
invoke-virtual {p2, p1, p3}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/util/Hkdf;->init([B[B)V
|
|
|
|
const/16 p1, 0x10
|
|
|
|
const-string p3, "Caldera Derived Key"
|
|
|
|
.line 18
|
|
invoke-virtual {p2, p3, p1}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/util/Hkdf;->deriveKey(Ljava/lang/String;I)[B
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
|
|
:catch_0
|
|
move-exception p1
|
|
|
|
.line 19
|
|
new-instance p2, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/exceptions/CognitoInternalErrorException;
|
|
|
|
invoke-virtual {p1}, Ljava/security/NoSuchAlgorithmException;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object p3
|
|
|
|
invoke-direct {p2, p3, p1}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/exceptions/CognitoInternalErrorException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
|
|
|
throw p2
|
|
|
|
.line 20
|
|
:cond_0
|
|
new-instance p1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/exceptions/CognitoInternalErrorException;
|
|
|
|
const-string p2, "Hash of A and B cannot be zero"
|
|
|
|
invoke-direct {p1, p2}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/exceptions/CognitoInternalErrorException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public geta()Ljava/math/BigInteger;
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser$AuthenticationHelper;->a:Ljava/math/BigInteger;
|
|
|
|
return-object v0
|
|
.end method
|