<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 结构?

        How to load an RSA key from binary data to an RSA structure using the OpenSSL C Library?(如何使用 OpenSSL C 库将 RSA 密钥从二进制数据加载到 RSA 结构?)

            <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 结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  How should a size-limited stl-like container be implemented?(应该如何实现大小受限的 stl 类容器?)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)

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

                          <tbody id='HHAsL'></tbody>
                        <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>

                            <small id='HHAsL'></small><noframes id='HHAsL'>

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