package o; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.KeyStoreException; import java.util.Arrays; /* loaded from: classes2.dex */ public final class NNk implements Tdz { private KeyStore c; private final String e; public NNk() throws GeneralSecurityException { this(new IeS()); } private NNk(IeS ieS) { this.e = ieS.a; this.c = ieS.b; } /* loaded from: classes2.dex */ public static final class IeS { String a = null; KeyStore b; public IeS() { this.b = null; try { KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); this.b = keyStore; keyStore.load(null); } catch (IOException | GeneralSecurityException e) { throw new IllegalStateException(e); } } } /* JADX WARN: Code restructure failed: missing block: B:13:0x001e, code lost: if (r3.toLowerCase(java.util.Locale.US).startsWith("android-keystore://") == false) goto L13; */ @Override // o.Tdz /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final boolean a(java.lang.String r3) { /* r2 = this; monitor-enter(r2) java.lang.String r0 = r2.e // Catch: java.lang.Throwable -> L23 r1 = 1 if (r0 == 0) goto Le boolean r0 = r0.equals(r3) // Catch: java.lang.Throwable -> L23 if (r0 == 0) goto Le monitor-exit(r2) return r1 Le: java.lang.String r0 = r2.e // Catch: java.lang.Throwable -> L23 if (r0 != 0) goto L20 java.util.Locale r0 = java.util.Locale.US // Catch: java.lang.Throwable -> L23 java.lang.String r3 = r3.toLowerCase(r0) // Catch: java.lang.Throwable -> L23 java.lang.String r0 = "android-keystore://" boolean r3 = r3.startsWith(r0) // Catch: java.lang.Throwable -> L23 if (r3 != 0) goto L21 L20: r1 = 0 L21: monitor-exit(r2) return r1 L23: r3 = move-exception monitor-exit(r2) throw r3 */ throw new UnsupportedOperationException("Method not decompiled: o.NNk.a(java.lang.String):boolean"); } @Override // o.Tdz public final InterfaceC4280bVg d(String str) throws GeneralSecurityException { iJF ijf; synchronized (this) { String str2 = this.e; if (str2 != null && !str2.equals(str)) { throw new GeneralSecurityException(String.format("this client is bound to %s, cannot load keys bound to %s", this.e, str)); } ijf = new iJF(ifG.c("android-keystore://", str), this.c); byte[] b = YTf.b(10); byte[] bArr = new byte[0]; if (!Arrays.equals(b, ijf.d(ijf.b(b, bArr), bArr))) { throw new KeyStoreException("cannot use Android Keystore: encryption/decryption of non-empty message and empty aad returns an incorrect result"); } } return ijf; } /* JADX INFO: Access modifiers changed from: package-private */ public final boolean e(String str) throws GeneralSecurityException { boolean containsAlias; synchronized (this) { String c = ifG.c("android-keystore://", str); try { containsAlias = this.c.containsAlias(c); } catch (NullPointerException unused) { try { Thread.sleep(20L); KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); this.c = keyStore; keyStore.load(null); } catch (IOException e) { throw new GeneralSecurityException(e); } catch (InterruptedException unused2) { } return this.c.containsAlias(c); } } return containsAlias; } }