English 中文(简体)
我能否在安乐斯使用最新的博爱提供商?
原标题:Can I use latest BouncyCastle provider on Android?

I am writing the app for Android 1.6.
Can anyone tell me if it is possible to use latest Bouncy Castle provider (version 1.46) instead of old one contained in SDK?
If so, correct instructions will be appreciated.

最佳回答

Found the issue on google and SpongyCastle. After I added jar and called addProvider(), the app became bigger but could use BC 1.46 features like "Whirlpool" digest.

...the Android platform unfortunately incorporates a cut-down version of Bouncy Castle, which also makes installing an updated version of the libraries difficult due to classloader conflicts.

如果你真的需要你信安的Bouncy城堡图书馆的全文,你可能会发现它方便地使用Spongy城堡,这是对Bouncy城堡的重新包装。

问题回答

In the meanwhile Android has changed the package name and BC can be used in its latest version. But there is still at least one problem:

The provider name "BC" is taken by the old built-in BC version. Adding BC with Security.addProvider(new BouncyCastleProvider(), 0) as first provider might work in simple cases, but Android Pie introduced a nasty check for the BouncyCastleProvider not allowing several modes, e.g. the X.509 certificate path checking cannot be instantiated and some other algorithms. This problem occurs when BC is added with Security.addProvider before sun.security.jca.Providers is first touched. Adding BC to the list of providers is usually required to be able to route indirect calls from other code referring the BC to the new BC version. E.g. the PKCS12 key store is using in its code a call to build a CertificateFactory using BC.

核对载于<代码>sun.security.jca.Providers,并称作java.security.cert.CertificateFactory。 该法典不能区分包括《巴塞尔公约》文本在内的安乐斯和新的工作版本。 解决这一问题的 ha脚石是,在时间开始之前就执行这一法典。 该守则必须在<代码>sun.security.jca.Providers被触动之前执行,否则,现有的加密供应商已经完成了静态代码碎片的读写:

private static final String SUN_PROVIDERS = "sun.security.jca.Providers";

...
    // remove BC provider first
    Security.removeProvider("BC");
    // also remove not sufficient AndroidOpenSSL provider for X.509 - most likely only needed if BouncyCastleJsseProvider is used
    Security.removeProvider("AndroidOpenSSL");
    // touch the internal Providers class to trigger the static provider loading
    // see http://androidxref.com/9.0.0_r3/xref/libcore/ojluni/src/main/java/sun/security/jca/Providers.java#SYSTEM_BOUNCY_CASTLE_PROVIDER
    try {
        Class.forName(SUN_PROVIDERS);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(String.format("%s to patch not found.", SUN_PROVIDERS), e);
    }
    // insert modern BC as first crypto provider
    Security.insertProviderAt(new BouncyCastleProvider(), 0);




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

MALICIOUS_CODE EI_EXPOSE_REP Medium

I run findbugs against all of my code and only tackle the top stuff. I finally got the top stuff resolved and now am looking at the details. I have a simple entity, say a user: public class User ...

XSS on jsbin.com

Anyone know if jsbin.com implements any protection for XSS or other javascript attacks? I see jsbin links used fairly regularly on sites like this one and I can t find any indication from the site ...

Make md5 strong

Im making a website that will intergrate with game that only support md5 hashing metod (atm). Which ofc is not especially safe anymore. But how could i make it stronger? Should I just generate long ...

Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

热门标签