CN106375095A - 一种对apk完整性保护的方法 - Google Patents

一种对apk完整性保护的方法 Download PDF

Info

Publication number
CN106375095A
CN106375095A CN201610800513.XA CN201610800513A CN106375095A CN 106375095 A CN106375095 A CN 106375095A CN 201610800513 A CN201610800513 A CN 201610800513A CN 106375095 A CN106375095 A CN 106375095A
Authority
CN
China
Prior art keywords
apk
signature
data
file
hash value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610800513.XA
Other languages
English (en)
Inventor
高振鹏
杨思忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZHONGKE INFORMATION SECURITY COMMON TECHNOLOGY NATIONAL ENGINEERING RESEARCH CENTER Co Ltd
Original Assignee
ZHONGKE INFORMATION SECURITY COMMON TECHNOLOGY NATIONAL ENGINEERING RESEARCH CENTER Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZHONGKE INFORMATION SECURITY COMMON TECHNOLOGY NATIONAL ENGINEERING RESEARCH CENTER Co Ltd filed Critical ZHONGKE INFORMATION SECURITY COMMON TECHNOLOGY NATIONAL ENGINEERING RESEARCH CENTER Co Ltd
Priority to CN201610800513.XA priority Critical patent/CN106375095A/zh
Publication of CN106375095A publication Critical patent/CN106375095A/zh
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • H04L9/3249Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures using RSA or related signature schemes, e.g. Rabin scheme
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

一种对APK完整性保护的方法包括APK签名及签名验证两部分,其是在不破坏开发者的签名情况下,实现了基于SHA1的1024位RSA加密私钥对APK文件中的部分重要文件进行加密且不向APK中增加任何文件以达到安全签名的过程,并实现通过电子市场的二次验签来达到应用的完整性保护;另外,由于本发明所述加密数据是写入File comment区且不向apk中写入任何数据,与传统技术手段需要向apk中读写文件相比,本发明所述技术方案使得APK的运行速率有较大提升,同时减小了智能手机系统的开销,提升了智能手机的运行速度;其次,由于加密原始数据使用了原签名数据的加密数据,并且使用了只有应用市场或APK开发者自己知道的应用标记,使得加密后的数据更为安全。

Description

一种对APK完整性保护的方法
技术领域
本发明涉及信息安全技术领域,尤其涉及一种对APK完整性保护的方法。
背景技术
通常的,每个Android应用开发完成后,其开发者或作者都会对其开发的Android应用进行签名,用户安装Android应用时智能手机需要先检测签名信息是否准确无误。现各大应用市场在上传应用时,通常都会对应用程序进行二次签名,以确保应用程序的安全性。
而现有的处理方式是:不管是原作者的签名还是针对应用市场或服务的扩展签名都是用写文件的方式,把签名文件写入apk文件包中,同时,安装应用程序时,验证签名是读取apk中相应文件,以流的形式读取出来,由此导致安装速度收到很大影响,特别是对于运行速度本身就较慢的智能手机,其安装速度甚至会陷入卡顿状态。
发明内容
本发明针对现有技术的不足,提出的一种对APK完整性保护的方法,该方法能有效保护APK应用且能提高其安装运行速度。
一种对APK完整性保护的方法包括APK签名及签名验证两部分,具体为:
所述APK签名步骤包括:
步骤一:获得APK开发者的签名数据公钥moduls数据,即原签名数据;
步骤二:计算APK中开发者签名文件的hash值A;
步骤三:计算APK根目录下AndroidManifest.xml文件的hash值B,及计算resources.arsc文件的hash值C;
步骤四:将hash值A、hash值B、hash值C、原签名数据及应用标记依次顺序连接作为签名基础数据;
步骤五:采用基于SHA1的1024位RSA加密私钥对签名基础数据进行加密,由此形成签名数据;
步骤六:将加密后的签名数据写入APK的File comment区并保存,则完成签名;
所述签名验证包括:
步骤一:取出已经签名的签名基础数据,所述签名基础数据包括原签名数据、hash值A、hash值B、hash值C和签名基础数据;
步骤二:取出存储在APK文件File comment区的加密数据,取出的数据如果为空则验签失败,不为空则继续进行签名验证;
步骤三:使用SHA1的1024位RSA加密公约对签名验证步骤二获得的加密数据解密;
步骤三:将解密后的数据与签名验证步骤一中的签名基础数据进行比对,比对一致则签名验证通过,否则签名验证失败。
进一步的,所述APK签名中步骤二所述开发者签名文件是指CERT.RSA或.rsa格式的其他名字的文件。
进一步的,所述APK签名中步骤二所述应用标记是指APK的应用领域和范围的简写标记。
本发明所述技术方案的有益效果在于:在不破坏开发者的签名情况下,实现了基于SHA1的1024位RSA加密私钥对APK文件中的部分重要文件进行加密且不向APK中增加任何文件以达到安全签名的过程,并实现通过电子市场的二次验签来达到应用的完整性保护;另外,由于本发明所述加密数据是写入File comment区且不向apk中写入任何数据,与传统技术手段需要向apk中读写文件相比,本发明所述技术方案使得APK的运行速率有较大提升,同时减小了智能手机系统的开销,提升了智能手机的运行速度;其次,由于加密原始数据使用了原签名数据的加密数据,并且使用了只有应用市场或APK开发者自己知道的应用标记,使得加密后的数据更为安全。
具体实施方式
为了全面理解本发明,在以下详细描述中提到了诸多细节,但本领域技术人员应该理解,本发明可以无需这些具体细节而实现。在其实施例中,不详细描述公知的方法、过程和组件,以免不必要地使实施例模糊。
本发明所述的一种对APK完整性保护的方法包括APK签名及签名验证两部分,具体为:
所述APK签名步骤包括:
步骤一:获得APK开发者的签名数据公钥moduls数据,即原签名数据;
步骤二:计算APK中开发者签名文件的hash值A;
步骤三:计算APK根目录下AndroidManifest.xml文件的hash值B,及计算resources.arsc文件的hash值C;
步骤四:将hash值A、hash值B、hash值C、原签名数据及应用标记依次顺序连接作为签名基础数据;
步骤五:采用基于SHA1的1024位RSA加密私钥对签名基础数据进行加密,由此形成签名数据;
步骤六:将加密后的签名数据写入APK的File comment区并保存,则完成签名;
所述签名验证包括:
步骤一:取出已经签名的签名基础数据,所述签名基础数据包括原签名数据、hash值A、hash值B、hash值C和签名基础数据;
步骤二:取出存储在APK文件File comment区的加密数据,取出的数据如果为空则验签失败,不为空则继续进行签名验证;
步骤三:使用SHA1的1024位RSA加密公约对签名验证步骤二获得的加密数据解密;
步骤三:将解密后的数据与签名验证步骤一中的签名基础数据进行比对,比对一致则签名验证通过,否则签名验证失败。
只有通过签名验证的APK才能上载到应用市场中。
其中,所述APK签名中步骤二所述开发者签名文件是指CERT.RSA或.rsa格式的其他名字的文件;所述APK签名中步骤二所述应用标记是指APK的应用领域和范围的简写标记。
以上对本发明所提供的一种检测当前应用是否处于前台的方法进行了详细介绍,本文中应用了实施例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (4)

1.一种对APK完整性保护的方法包括APK签名及签名验证两部分,具体为:
所述APK签名步骤包括:
步骤一:获得APK开发者的签名数据公钥moduls数据,即原签名数据;
步骤二:计算APK中开发者签名文件的hash值A;
步骤三:计算APK根目录下AndroidManifest.xml文件的hash值B,及计算resources.arsc文件的hash值C;
步骤四:将hash值A、hash值B、hash值C、原签名数据及应用标记依次顺序连接作为签名基础数据;
步骤五:采用基于SHA1的1024位RSA加密私钥对签名基础数据进行加密,由此形成签名数据;
步骤六:将加密后的签名数据写入APK的File comment区并保存,则完成签名;
所述签名验证包括:
步骤一:取出已经签名的签名基础数据,所述签名基础数据包括原签名数据、hash值A、hash值B、hash值C和签名基础数据;
步骤二:取出存储在APK文件File comment区的加密数据,取出的数据如果为空则验签失败,不为空则继续进行签名验证;
步骤三:使用SHA1的1024位RSA加密公约对签名验证步骤二获得的加密数据解密;
步骤三:将解密后的数据与签名验证步骤一中的签名基础数据进行比对,比对一致则签名验证通过,否则签名验证失败。
2.如权利要求1所述的一种对APK完整性保护的方法,其特征在于:所述APK签名中步骤二所述开发者签名文件是指CERT.RSA或.rsa格式的其他名字的文件。
3.如权利要求1所述的一种对APK完整性保护的方法,其特征在于:所述APK签名中步骤二所述开发者签名文件是指CERT.RSA或.rsa格式的其他名字的文件。
4.如权利要求1所述的一种对APK完整性保护的方法,其特征在于:所述APK签名中步骤二所述应用标记是指APK的应用领域和范围的简写标记。
CN201610800513.XA 2016-09-02 2016-09-02 一种对apk完整性保护的方法 Pending CN106375095A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610800513.XA CN106375095A (zh) 2016-09-02 2016-09-02 一种对apk完整性保护的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610800513.XA CN106375095A (zh) 2016-09-02 2016-09-02 一种对apk完整性保护的方法

Publications (1)

Publication Number Publication Date
CN106375095A true CN106375095A (zh) 2017-02-01

Family

ID=57900242

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610800513.XA Pending CN106375095A (zh) 2016-09-02 2016-09-02 一种对apk完整性保护的方法

Country Status (1)

Country Link
CN (1) CN106375095A (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106656513A (zh) * 2017-02-24 2017-05-10 福建魔方电子科技有限公司 安卓平台上apk文件的二次打包签名验证方法
CN108875082A (zh) * 2018-07-17 2018-11-23 北京奇安信科技有限公司 一种大容量数据读写处理方法及装置
CN109214146A (zh) * 2018-08-10 2019-01-15 北京邮电大学 应用软件的签名方法、验签方法和装置
CN109918948A (zh) * 2019-01-23 2019-06-21 西安邮电大学 基于国密算法sm3的apk完整性校验方法、计算机程序
CN111787529A (zh) * 2020-07-17 2020-10-16 江苏海全科技有限公司 适于Android智能POS机应用的签名方法和系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130246796A1 (en) * 2011-09-29 2013-09-19 Mcafee, Inc. System and method for securing database activity
CN103886260A (zh) * 2014-04-16 2014-06-25 中国科学院信息工程研究所 一种基于二次签名验签技术的应用程序管控方法
CN104346167A (zh) * 2014-08-25 2015-02-11 腾讯科技(深圳)有限公司 生成应用渠道包的方法及装置
US9311317B1 (en) * 2012-05-14 2016-04-12 Symantec Corporation Injecting custom data into files in zip format containing apps, without unzipping, resigning or re-zipping the files
CN105760202A (zh) * 2016-03-14 2016-07-13 广州爱九游信息技术有限公司 服务器、计算设备、软件压缩包处理装置及方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130246796A1 (en) * 2011-09-29 2013-09-19 Mcafee, Inc. System and method for securing database activity
US9311317B1 (en) * 2012-05-14 2016-04-12 Symantec Corporation Injecting custom data into files in zip format containing apps, without unzipping, resigning or re-zipping the files
CN103886260A (zh) * 2014-04-16 2014-06-25 中国科学院信息工程研究所 一种基于二次签名验签技术的应用程序管控方法
CN104346167A (zh) * 2014-08-25 2015-02-11 腾讯科技(深圳)有限公司 生成应用渠道包的方法及装置
CN105760202A (zh) * 2016-03-14 2016-07-13 广州爱九游信息技术有限公司 服务器、计算设备、软件压缩包处理装置及方法

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106656513A (zh) * 2017-02-24 2017-05-10 福建魔方电子科技有限公司 安卓平台上apk文件的二次打包签名验证方法
CN106656513B (zh) * 2017-02-24 2019-09-13 福建魔方电子科技有限公司 安卓平台上apk文件的二次打包签名验证方法
CN108875082A (zh) * 2018-07-17 2018-11-23 北京奇安信科技有限公司 一种大容量数据读写处理方法及装置
CN108875082B (zh) * 2018-07-17 2021-01-01 奇安信科技集团股份有限公司 一种大容量数据读写处理方法及装置
CN109214146A (zh) * 2018-08-10 2019-01-15 北京邮电大学 应用软件的签名方法、验签方法和装置
CN109918948A (zh) * 2019-01-23 2019-06-21 西安邮电大学 基于国密算法sm3的apk完整性校验方法、计算机程序
CN111787529A (zh) * 2020-07-17 2020-10-16 江苏海全科技有限公司 适于Android智能POS机应用的签名方法和系统

Similar Documents

Publication Publication Date Title
CN106375095A (zh) 一种对apk完整性保护的方法
US9112854B1 (en) Secure communication between applications on untrusted platforms
CN113012008B (zh) 一种基于可信硬件的身份管理方法、装置及设备
KR101382222B1 (ko) 파일 시스템 가상화를 이용한 모바일 정보유출방지 시스템 및 방법
CN103210396B (zh) 包括用于保护敏感代码和数据的架构的方法和装置
US10536274B2 (en) Cryptographic protection for trusted operating systems
US10778447B2 (en) Method and system for safely switching between product mode and development mode of terminal
US20110016330A1 (en) Information leak prevention device, and method and program thereof
EP2759955A1 (en) Secure backup and restore of protected storage
CN105493097A (zh) 用于远程存储的数据的保护方案
CN113010870A (zh) 基于数字凭证的业务处理方法、装置及设备
KR20130114733A (ko) 보안 시스템에서 랜덤하게 할당된 메모리 범위로 jit를 지원하는 시스템 및 방법
CN109313677A (zh) 用于动态可执行验证的方法和装置
CN105718807A (zh) 基于软tcm和可信软件栈的安卓系统及其可信认证系统与方法
CN111770063B (zh) 数字身份信息的派生、验证方法、装置及设备
CN108229144B (zh) 一种应用程序的验证方法、终端设备及存储介质
TW201530344A (zh) 應用程式存取保護方法及應用程式存取保護裝置
CN109086578A (zh) 一种软件授权使用的方法、设备及存储介质
CN112001376B (zh) 基于开源组件的指纹识别方法、装置、设备及存储介质
CN110830257B (zh) 一种文件签名方法、装置、电子设备及可读存储介质
CN112560110A (zh) 授权协议的签署方法、装置、电子设备及存储介质
CN111737304B (zh) 一种区块链数据的处理方法、装置及设备
US11934539B2 (en) Method and apparatus for storing and processing application program information
CN117610083A (zh) 文件校验方法、装置、电子设备及计算机存储介质
Alendal et al. Chip chop—smashing the mobile phone secure chip for fun and digital forensics

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20170201

WD01 Invention patent application deemed withdrawn after publication