简体   繁体   English

如何使用Cordova在IOS和Android中生成KeyPair?

[英]How to generate KeyPair in IOS and Android using Cordova?

I am creating a banking app using angularjs1 and ionic1 for IOS and Android. 我正在使用用于iOS和Android的angularjs1和ionic1创建银行应用程序。 Due to some security concerns from clients the device should generate public and private key using SHA/RSA. 由于客户端的某些安全问题, 设备应使用SHA / RSA生成公钥和私钥。 I don't want to use any javascript plugin, strictly denied by the client. 我不想使用任何JavaScript插件,但客户端严格拒绝。 I digged a lot, OpenSSL and LetsEncrypt are the only options left as far as I know. 据我所知, OpenSSLLetsEncrypt是我所知的唯一剩下的选项。 Both the websites discuss manual command prompt key generation on an operating system. 这两个网站都讨论了在操作系统上手动生成命令提示符键的问题。 I want a mechanism where I can: 我想要一种可以做到的机制:

  1. Generate keypair on the device. 在设备上生成密钥对。
  2. Generate Json Web Key(JWK). 生成Json Web密钥(JWK)。
  3. Sign/Hash the data using private key. 使用私钥签名/哈希数据。 Below is a reference in .net/Java(I want this in cordova) 以下是.net / Java中的参考(我想在cordova中使用它)

signature = RSA256SignData(ASCIIBytes(data to be signed), rsaPrivateKey) 签名= RSA256SignData(ASCIIBytes(要签名的数据),rsaPrivateKey)

Encoded Signature = Base64Encode(signature) 编码签名= Base64Encode(签名)

I couldn't find any cordova plugin which can handle this. 我找不到任何可以处理此问题的cordova插件。 If there is no cordova plugin I'll be glad if anyone can tell me to do this in pieces or anything which is native. 如果没有cordova插件,如果有人可以告诉我分步进行或进行任何本地操作,我将非常高兴。

Thanks. 谢谢。

I do not know of a Cordova plugin that can accomplish these tasks. 我不知道可以完成这些任务的Cordova插件。

There are some excellent javascript libraries that do provide these functions. 有一些出色的javascript库确实提供了这些功能。 Have a look at node-jose which allows you to work with JWK, JWE and JWS. 看一下node-jose ,它使您可以使用JWK,JWE和JWS。 The library depends on (a slightly altered version of) node-forge which can do almost anything, including generating a keypair and signing/hashing data. 该库依赖于node-forge (略有改动的版本),它几乎可以执行任何操作,包括生成密钥对和签名/哈希数据。

The only drawback of using these libraries is that the speed may not be sufficient for the mobile devices you need to support. 使用这些库的唯一缺点是速度可能不足以支持您需要支持的移动设备。 My personal experience is that mobile devices are perfectly capable of working with 1024-bit keypairs. 我的个人经验是,移动设备完全能够使用1024位密钥对。 Working with 2048-bits is somewhat slow and generating a 2048-bit pair simply takes too long on most devices. 使用2048位比较慢,并且在大多数设备上生成2048位对仅花费太长时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android KeyStore中生成KeyPair,受自定义密码保护 - How to generate KeyPair in android KeyStore, protected by custom password 如何在Android中使用kso​​ap2库发送密钥对值? - how to send keypair valuie using ksoap2 library in android? 如何在android / ios中使用cordova ionic 2在打印过程中添加打印机 - how to add printer during print using cordova ionic 2 in android/ios 如何使用适用于Android和iOS的Cordova为应用设置图标 - How to set Icon for app using Cordova for Android and iOS 如何使用 ionic cordova 生成适用于 Android 4.1.2 的 APK - How to generate an APK for Android 4.1.2 with ionic cordova 如何使用cordova-plugin-file在cordova应用程序之间共享数据? (Android,IOS) - How to share data between cordova apps using cordova-plugin-file? (Android, IOS) 使用Cordova从工作的Android应用程序生成iOS应用程序是否可行? - Is it posible to generate ios app from working android app with cordova? 检查更新时,Android Studio显示“无法生成DH密钥对” - Android Studio shows “Could not generate DH keypair” when checking for update 使用cordova在Android / Ios中显示徽章编号 - Display badge number in Android/Ios using cordova 使用cordova的Android / ios异步通知 - Android/ios async notification using cordova
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM