<tfoot id='n4kVW'></tfoot>

    1. <i id='n4kVW'><tr id='n4kVW'><dt id='n4kVW'><q id='n4kVW'><span id='n4kVW'><b id='n4kVW'><form id='n4kVW'><ins id='n4kVW'></ins><ul id='n4kVW'></ul><sub id='n4kVW'></sub></form><legend id='n4kVW'></legend><bdo id='n4kVW'><pre id='n4kVW'><center id='n4kVW'></center></pre></bdo></b><th id='n4kVW'></th></span></q></dt></tr></i><div id='n4kVW'><tfoot id='n4kVW'></tfoot><dl id='n4kVW'><fieldset id='n4kVW'></fieldset></dl></div>
      <legend id='n4kVW'><style id='n4kVW'><dir id='n4kVW'><q id='n4kVW'></q></dir></style></legend>
    2. <small id='n4kVW'></small><noframes id='n4kVW'>

        <bdo id='n4kVW'></bdo><ul id='n4kVW'></ul>

        如何使用 OpenSSL C 库将 RSA 密钥从二进制数据加载到 RSA 结构?

        时间:2024-08-14

            <bdo id='hgLCO'></bdo><ul id='hgLCO'></ul>
            <legend id='hgLCO'><style id='hgLCO'><dir id='hgLCO'><q id='hgLCO'></q></dir></style></legend>
            <tfoot id='hgLCO'></tfoot>

            1. <i id='hgLCO'><tr id='hgLCO'><dt id='hgLCO'><q id='hgLCO'><span id='hgLCO'><b id='hgLCO'><form id='hgLCO'><ins id='hgLCO'></ins><ul id='hgLCO'></ul><sub id='hgLCO'></sub></form><legend id='hgLCO'></legend><bdo id='hgLCO'><pre id='hgLCO'><center id='hgLCO'></center></pre></bdo></b><th id='hgLCO'></th></span></q></dt></tr></i><div id='hgLCO'><tfoot id='hgLCO'></tfoot><dl id='hgLCO'><fieldset id='hgLCO'></fieldset></dl></div>
              • <small id='hgLCO'></small><noframes id='hgLCO'>

                  <tbody id='hgLCO'></tbody>

                  本文介绍了如何使用 OpenSSL C 库将 RSA 密钥从二进制数据加载到 RSA 结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  目前我将我的私钥保存在一个文件 private.key 中,我使用以下函数加载它:

                  Currently I have my private key saved in a file, private.key, and I use the following function to load it:

                  RSA *r = PEM_read_RSAPrivateKey("private.key", NULL, NULL, NULL);

                  RSA *r = PEM_read_RSAPrivateKey("private.key", NULL, NULL, NULL);

                  这很完美,但我对基于文件的格式不满意;我想在 char* 变量中以纯二进制形式(即,没有 base64 或类似格式)保存我的密钥,并从中加载/保存密钥.这样我有更多的自由:我将能够将密钥直接存储到应用程序 const char key[] { 0x01, 0x02, ... };,通过网络套接字发送等

                  This works perfectly but I'm not happy with the file-based format; I want to save my key in pure binary form (ie, no base64 or similar) in a char* variable and load/save the key from/to it. This way I have much more freedom: I'll be able to store the key directly into the application const char key[] { 0x01, 0x02, ... };, send it over a network socket, etc.

                  不幸的是,虽然我还没有找到一种方法来做到这一点.我所知道的保存和加载密钥的唯一方法是直接将其读取/保存到文件中.

                  Unfortunately though I haven't found a way to do that. The only way to save and load a key I know of reads/saves it to a file directly.

                  推荐答案

                  使用 d2i_RSAPrivateKey 直接从包含二进制 DER 格式的缓冲区加载:

                  Use d2i_RSAPrivateKey to load directly from a buffer containing binary DER format:

                  const unsigned char *p = key;
                  RSA *r = d2i_RSAPrivateKey(NULL, &p, keylen);
                  

                  这篇关于如何使用 OpenSSL C 库将 RSA 密钥从二进制数据加载到 RSA 结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:聚合“BIGNUM foo"的类型不完整,无法定义 下一篇:如何在 Qt 中实现 OpenSSL?

                  相关文章

                • <tfoot id='HHAsL'></tfoot>

                  1. <i id='HHAsL'><tr id='HHAsL'><dt id='HHAsL'><q id='HHAsL'><span id='HHAsL'><b id='HHAsL'><form id='HHAsL'><ins id='HHAsL'></ins><ul id='HHAsL'></ul><sub id='HHAsL'></sub></form><legend id='HHAsL'></legend><bdo id='HHAsL'><pre id='HHAsL'><center id='HHAsL'></center></pre></bdo></b><th id='HHAsL'></th></span></q></dt></tr></i><div id='HHAsL'><tfoot id='HHAsL'></tfoot><dl id='HHAsL'><fieldset id='HHAsL'></fieldset></dl></div>
                      <bdo id='HHAsL'></bdo><ul id='HHAsL'></ul>
                    1. <small id='HHAsL'></small><noframes id='HHAsL'>

                      <legend id='HHAsL'><style id='HHAsL'><dir id='HHAsL'><q id='HHAsL'></q></dir></style></legend>