当前位置:网站首页>Ultra simple integration of Huawei system integrity testing, complete equipment security protection
Ultra simple integration of Huawei system integrity testing, complete equipment security protection
2020-11-09 16:56:00 【Huawei Developer Forum】
In unsafe devices , If root Or unlock the phone , Running an application is usually accompanied by a certain security risk , For example, it is used by malicious virus or Trojan software root Permission to implant virus 、 Tamper with user equipment information and destroy the system . therefore , How to do a good job in the application of security protection 、 Avoid safety risks in the environment of unsafe equipment , Has become a factor that developers must consider . Regarding this , Huawei opens security detection service , Provide system integrity check (SysIntegrity API), It can be used to detect whether the equipment environment in which the application is running is safe , If the device is root、 Being unlocked, etc .
One 、 The service is introduced
Huawei system integrity testing includes the following features :
- Based on trusted execution environment TEE Provide system integrity test results : When the device starts safely , stay TEE To evaluate the integrity of the detection system , High credibility , And dynamically evaluate the integrity of the system .
- The system integrity test results are safe and reliable : The system integrity test results are signed by digital certificate , The test results cannot be tampered with .
The business flow chart is shown in the figure below :

(1). Your application integration HMS Core SDK call Safety Detect service. (2). request TSMS(Trusted Security Management Service) Server signature detection results Server. (3). Your app requests its own service test results . ---- end
Two 、 Scene case introduction
Now there is finance 、 entertainment 、 Convenient life 、 News reading and many other fields App Integrated with Huawei system integrity detection : Financial application integration Huawei SysIntegrity, It can effectively improve transaction security . for example , You can enter the credit card security code in the user (CVC) when , Make sure the system environment of the mobile phone is safe . If the mobile phone device fails to pass the system integrity test verification , You are not allowed to use the app , In order to protect the transaction security :


life 、 News reading class application , Integrate SysIntegrity Can effectively prevent hacker attacks , Ensure the security of in app payment and other activities :

Video entertainment application integration SysIntegrity, Can help protect content copyright ; When a user registers 、 When watching and downloading offline video , You can ensure that users are on content provider approved devices , Complete streaming and video playback :

3、 ... and 、 Developing code
1 stay AppGallery Connect Configuration information in
Before developing applications , Need to be in AppGallery Connect Configuration information in . Specific operation steps :https://developer.huawei.com/consumer/cn/doc/HMSCore-Guides-V5/config-agc-0000001050416303-V5
2 To configure HMS Core SDK Of Maven Warehouse address
2.1 open Android Studio Project level “build.gradle" file

2.2 add to HUAWEI agcp Plugins and Maven The code base stay allprojects-> repositories It's equipped with HMS Core SDK Of Maven Warehouse address .
1. allprojects {
2. repositories {
3. google()
4. jcenter()
5. maven {url 'https://developer.huawei.com/repo/'}
6. }
7. }
stay buildscript->repositories It's equipped with HMS Core SDK Of Maven Warehouse address .
1. buildscript {
2. repositories {
3. google()
4. jcenter()
5. maven {url 'https://developer.huawei.com/repo/'}
6. }
7. }
stay buildscript ->dependencies Add configuration to it .
1. buildscript{
2. dependencies {
3. classpath 'com.huawei.agconnect:agcp:1.3.1.300'
4. }
5. }
3 establish SafetyDetectClient And generate nonce value
1. // establish SafetyDetectClient
2. SafetyDetectClient mClient = SafetyDetect.getClient(MainActivity.this);
3. // Generate nonce value
4. byte[] nonce = new byte[24];
5. try {
6. SecureRandom random;
7. if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
8. random = SecureRandom.getInstanceStrong();
9. } else {
10. random = SecureRandom.getInstance("SHA1PRNG");
11. }
12. random.nextBytes(nonce);
13. } catch (NoSuchAlgorithmException e) {
14. Log.e(TAG, e.getMessage());
15. }
4 Create a test result monitor
1. // Realization OnSuccessListener Interface , And from onSuccess Get test results
2. protected class SysIntegrityOnSuccessListener implements OnSuccessListener<SysIntegrityResp> {
3.
4. // Get system integrity test results
5. @Override
6. public void onSuccess(SysIntegrityResp sysIntegrityResp) {
7.
8. }
9.
10. }
11. // Realization OnFailureListener Interface , And from onFailure Exception details
12. protected class SysIntegrityOnFailureListener implements OnFailureListener {
13. // Get exception error code, exception details
14. @Override
15. public void onFailure(Exception e) {
16.
17. }
18. }
5 Call system integrity check
1. // Call the system integrity detection interface ,******** Pass in appid
2. Task task = mClient.sysIntegrity(nonce,"********");
3. task.addOnSuccessListener(new SysIntegrityOnSuccessListener()).addOnFailureListener(new SysIntegrityOnFailureListener());
6 The results verify that
Server to verify the integrity of the system detection results can refer to the developer alliance official website .
DEMO demonstration

If you're interested in implementation , You can refer to Github Source link :https://github.com/HMS-Core/hms-safetydetect-demo-android
More detailed development guidelines , Please refer to the official website of Huawei developer alliance : Huawei developer Alliance :https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/dysintegritydevelopment-0000001050156331
Get development guidance document : https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/introduction-0000001050156325ha_source=hms1
download demo And sample code go to Github:https://github.com/HMS-Core
To solve the integration problem, please go to Stack Overflow: https://stackoverflow.com/questions/tagged/huawei-mobile-services?tab=Newest
Link to the original text :https://developer.huawei.com/consumer/cn/forum/topic/0201393882637910006?fid=18
The original author : Eat anything at night
版权声明
本文为[Huawei Developer Forum]所创,转载请带上原文链接,感谢
边栏推荐
- 知识图谱描边1.1——从NER上手
- Kubernetes-17: kubernets package management tool -- Introduction and use of Helm
- 高性能库DPDK精简理解
- QML Repeater
- Mit6.824 distributed system course translation & learning notes (3) GFS
- The internal network penetration of raspberry is built and maintained. No server is required for intranet penetration
- 程序模拟感知机算法(梯度下降法、sklearn.linear_model中perception方法)
- Application of pull wire displacement sensor in slope cracks
- From next year, about 30% of the web pages will be inaccessible to older Android devices
- Flash Book curd project
猜你喜欢

高性能库DPDK精简理解

谷粒商城学习笔记,第五天:ES全文检索
![[share] interface tests how to transfer files in post request](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[share] interface tests how to transfer files in post request

Application of pull wire displacement sensor in slope cracks

Full stack technology experience tells you: how much does it cost to develop a mall small program?

解决微信小程序使用switchTab跳转后页面不刷新的问题

5分钟GET我使用Github 5 年总结的这些骚操作!

超简单集成华为系统完整性检测,搞定设备安全防护

2020中国电信终端技术与标准论坛上专家解读四大热门产业

使用基于GAN的过采样技术提高非平衡COVID-19死亡率预测的模型准确性
随机推荐
High quality defect analysis: let yourself write fewer bugs
Using GaN based oversampling technique to improve the accuracy of model for mortality prediction of unbalanced covid-19
EasyExcel根据筛选列导出(中间不空列,顺序可调整)
It's so easy to replace the video background with the sound and shadow
Colleague notes - small program entry point
你以为学编程很简单吗,其实它很难!你以为学编程很难吗,其实它很简单!
电商/直播速看!双11跑赢李佳琦就看这款单品了!
Which industries are suitable for enterprises to develop wechat applet?
揭秘在召唤师峡谷中移动路径选择逻辑?
Learning notes of millet mall, day 5: ES full text search
拉线式位移传感器在边坡裂缝中的作用
The selection of wire displacement encoder needs the guidance of precise electronics
最新版PyCharm 2020.3 :可实现结对编程,智能文本校对等|附下载体验
使用基于GAN的过采样技术提高非平衡COVID-19死亡率预测的模型准确性
Serilog 源码解析——Sink 的实现
In the third stage, day16 user module jumps to SSO single sign on jsonp / CORS cross domain user login verification
深入分析商淘多用户商城系统如何从搜索着手打造盈利点
flask图书CURD小项目
从一次需求改良漫谈php文件分片上传
Data consistency of cache