Перенос с маленькими правками

This commit is contained in:
2025-03-30 18:08:41 +03:00
parent 0134f6d689
commit 4b7a924752
544 changed files with 45301 additions and 0 deletions
@@ -0,0 +1,80 @@
package com.ea.nimble;
import android.annotation.SuppressLint;
import com.ea.nimble.Log;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
import java.security.Provider;
import java.security.Security;
import java.util.Iterator;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
/* loaded from: classes.dex */
class Encryptor {
private static int ENCRYPTION_KEY_LENGHT = 128;
private static int ENCRYPTION_KEY_ROUND = 997;
private Cipher m_encryptor = null;
private Cipher m_decryptor = null;
@SuppressLint({"NewApi"})
private void initialize() throws GeneralSecurityException {
for (Provider provider : Security.getProviders()) {
Log.Helper.LOGIS(null, "Cryptor Provider: " + provider.getName(), new Object[0]);
Iterator<Provider.Service> it = provider.getServices().iterator();
while (it.hasNext()) {
Log.Helper.LOGIS(null, "Cryptor Algorithm: " + it.next().getAlgorithm(), new Object[0]);
}
}
try {
String applicationBundleId = ApplicationEnvironment.getComponent().getApplicationBundleId();
byte[] bytes = "02:00:00:00:00:00".getBytes();
byte[] bArr = new byte[8];
int i = 0;
int i2 = 0;
while (i < bArr.length) {
int i3 = i2 + 1;
if (i3 % 3 == 0) {
i2 = i3;
}
bArr[i] = bytes[i2];
i++;
i2++;
}
SecretKey generateSecret = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(applicationBundleId.toCharArray(), bArr, ENCRYPTION_KEY_ROUND, ENCRYPTION_KEY_LENGHT));
PBEParameterSpec pBEParameterSpec = new PBEParameterSpec(bArr, ENCRYPTION_KEY_ROUND);
this.m_encryptor = Cipher.getInstance("PBEWithMD5AndDES");
this.m_encryptor.init(1, generateSecret, pBEParameterSpec);
this.m_decryptor = Cipher.getInstance("PBEWithMD5AndDES");
this.m_decryptor.init(2, generateSecret, pBEParameterSpec);
} catch (GeneralSecurityException e) {
Log.Helper.LOGFS(null, "Can't initialize Encryptor: " + e.toString(), new Object[0]);
throw e;
}
}
public ObjectInputStream encryptInputStream(InputStream inputStream) throws IOException, GeneralSecurityException {
Log.Helper.LOGFUNC(this);
if (this.m_encryptor == null || this.m_decryptor == null) {
initialize();
}
return new ObjectInputStream(new CipherInputStream(inputStream, this.m_decryptor));
}
public ObjectOutputStream encryptOutputStream(OutputStream outputStream) throws IOException, GeneralSecurityException {
Log.Helper.LOGFUNC(this);
if (this.m_encryptor == null || this.m_decryptor == null) {
initialize();
}
return new ObjectOutputStream(new CipherOutputStream(outputStream, this.m_encryptor));
}
}