gpt4 book ai didi

iphone - iOS - 从指数+模数创建 SecKeyRef

转载 作者:技术小花猫 更新时间:2023-10-29 10:39:54 25 4
gpt4 key购买 nike

我想通过将指数和模数作为私钥来解密 iPhone 上的 RSA 编码的 blob。在 Java 中(使用 javax.crypto),这可以通过如下代码轻松实现:

// 1) key
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(myModulus, myPublicExponent);
KeyFactory fact = KeyFactory.getInstance("RSA");
Key pubKey = fact.generatePublic(keySpec);

// 2) cypher
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, keySpec);

// 3) use cypher to decode my block to an output stream

但是对于 iPhone 安全 API,我无法创建 SecKeyRef( key ),只能生成一对或导入一个我没有/想要的证书。

有没有办法手动创建具有模数 + 指数的 key ?如果是这样,你能告诉我怎么做吗?

提前致谢

最佳答案

您的指数和模数是如何编码的?如果他们在 PKCS#12 blob,你可以使用 SecPKCS12Import()SecIdentityCopyPrivateKey() 来实现你想要的。

编辑:鉴于您拥有原始 key ,您可能有兴趣查看-[SecKeyWrapper addPeerPublicKey:keyBits:] 示例provided由 Apple。

关于iphone - iOS - 从指数+模数创建 SecKeyRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5942712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com