【问题标题】:How to get public and private key from CNG (BCrypt) RSA algorithm?如何从 CNG (BCrypt) RSA 算法中获取公钥和私钥?
【发布时间】:2022-11-22 11:16:17
【问题描述】:

我有点卡住了,我想生成一对新的公钥和私钥。 但我找不到提取它们的方法。

我用过这个:(C++)

    status = BCryptOpenAlgorithmProvider(&hAlg,
                                         BCRYPT_RSA_ALGORITHM,
                                         NULL,
                                         0);

    if (status) {}

    status = BCryptGenerateKeyPair(hAlg, &hKey, 1024, 0);

    if (status) {}

    status = BCryptFinalizeKeyPair(&hKey, 0);

    if (status) {}

(不要介意状态,我稍后会检查它:-)) 但现在我想提取这对键,找不到示例或匹配函数 我可能做错了什么,但是什么?

【问题讨论】:

  • 可能与 BCryptExportKey
  • @user253751 导出到?我试过了,但是我怎么能看到关键值呢?
  • BCRYPT_RSAPRIVATE_BLOB,大概。

标签: c++ winapi rsa public-key-encryption cng


【解决方案1】:

“出口到?” BCryptExportKey function将密钥导出到内存 BLOB,可以保留以备后用。

然后您可以使用 the BCryptImportKeyPair function 从密钥 BLOB 导入公钥/私钥对。

【讨论】:

    猜你喜欢
    • 2012-01-02
    • 2018-11-27
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 2011-07-31
    • 2014-09-05
    • 2019-08-15
    • 1970-01-01
    相关资源
    最近更新 更多