Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anr when generateAESKey and call mStore.containsAlias(AES_KEY_ALIAS) #53

Open
risechen opened this issue Aug 9, 2019 · 0 comments
Open

Comments

@risechen
Copy link

risechen commented Aug 9, 2019

1.device and version: Samsung Galaxy J7 Prime (on7xelte), Android 8.1
2.anr log
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x732abec0 self=0xee07b000
| sysTid=19949 nice=0 cgrp=default sched=0/0 handle=0xf23304b8
| state=S schedstat=( 0 0 0 ) utm=9 stm=8 core=2 HZ=100
| stack=0xff334000-0xff336000 stackSize=8MB
| held mutexes=
#00 pc 0000000000049ff8 /system/lib/libc.so (__ioctl+8)
#1 pc 000000000001e215 /system/lib/libc.so (ioctl+40)
#2 pc 0000000000042839 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+204)
#3 pc 000000000004324f /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+246)
#4 pc 000000000003d45d /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+36)
#5 pc 00000000000c608d /system/lib/libandroid_runtime.so (???)
#6 pc 0000000000791c65 /system/framework/arm/boot-framework.oat (Java_android_os_BinderProxy_transactNative__ILandroid_os_Parcel_2Landroid_os_Parcel_2I+132)
at android.os.BinderProxy.transactNative (Native method)
at android.os.BinderProxy.transact (Binder.java:784)
at android.security.IKeystoreService$Stub$Proxy.exist (IKeystoreService.java:846)
at android.security.KeyStore.contains (KeyStore.java:527)
at android.security.keystore.AndroidKeyStoreSpi.engineContainsAlias (AndroidKeyStoreSpi.java:951)
at java.security.KeyStore.containsAlias (KeyStore.java:1293)
at ai.totok.chat.fqz.e (EncryptionManager.java:730)
at ai.totok.chat.fqz.a (EncryptionManager.java:717)
at ai.totok.chat.fqz.a (EncryptionManager.java:228)
at ai.totok.chat.fqz. (EncryptionManager.java:200)
at ai.totok.chat.frd. (SecuredPreferenceStoreExt.java:85)
at ai.totok.chat.frd.a (SecuredPreferenceStoreExt.java:161)
at ai.totok.chat.etm.a (SecureStoreUtil.java:86)
at ai.totok.chat.etm.b (SecureStoreUtil.java:146)
at ai.totok.chat.etm.b (SecureStoreUtil.java:292)
at ai.totok.chat.ehi.a (ZayhuPref.java:29)
at com.zayhu.app.ZayhuApplication.b (ZayhuApplication.java:403)
at com.zayhu.app.ZayhuApplication.onCreate (ZayhuApplication.java:190)

3.this is the code:
@TargetApi(Build.VERSION_CODES.M)
boolean generateAESKey(@nullable byte[] seed) throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException {
if (!mStore.containsAlias(AES_KEY_ALIAS)) {
KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, KEYSTORE_PROVIDER);

        KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(AES_KEY_ALIAS, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
                .setCertificateSubject(new X500Principal("CN = Secured Preference Store, O = Devliving Online"))
                .setCertificateSerialNumber(BigInteger.ONE)
                .setKeySize(AES_BIT_LENGTH)
                .setBlockModes(KeyProperties.BLOCK_MODE_GCM)
                .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
                .setRandomizedEncryptionRequired(false) //TODO: set to true and let the Cipher generate a secured IV
                .build();
        if(seed != null && seed.length > 0){
            SecureRandom random = new SecureRandom(seed);
            keyGen.init(spec, random);
        } else {
            keyGen.init(spec);
        }

        keyGen.generateKey();

        return true;
    }

    return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant