<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.code, li.code, div.code
        {mso-style-name:code;
        mso-style-link:"code Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:Consolas;
        color:black;}
span.codeChar
        {mso-style-name:"code Char";
        mso-style-link:code;
        font-family:Consolas;
        color:black;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">"i" is an abbreviation for "internal", meaning OpenSSL's internal format.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">"2" means "to".<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">"d" means "DER".<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">"b" means "blob", and refers to a "key blob" format used by Microsoft. (That's based on the OpenSSL source code; I haven't looked into the actual provenance
 of this blob format.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It appears the key blob format typically uses the "PVK" file extension.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Lots of things in OpenSSL aren't documented. It's not strange at all - programmers tend to write code first, documentation second (or later). This is true of
 a great many open-source projects, and many commercial ones as well. If you want something documented, your best bet is to research it in the code and write the documentation yourself.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regarding your second question: EVP_KEY is defined in evp.h, where we see it contains a pointer to one of the specific key types, such as rsa_st. rsa_st is
 defined in rsa.h, and if we look there we see that it contains all the RSA parameters, so it implicitly contains both the public and private key.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black">Michael Wojcik</span><span style="font-size:9.0pt;color:#1F497D">
<br>
</span><span style="font-size:9.0pt;font-family:"Courier New";color:black">Technology Specialist</span><span style="font-size:9.0pt;font-family:"Courier New";color:black">, Micro Focus</span><span style="font-size:9.0pt;color:#1F497D">
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> openssl-users [mailto:openssl-users-bounces@openssl.org]
<b>On Behalf Of </b>Serj<br>
<b>Sent:</b> Tuesday, February 03, 2015 06:22<br>
<b>To:</b> openssl-users@openssl.org<br>
<b>Subject:</b> Re: [openssl-users] i2d_ d2i_ b2i_ i2b_ functions and EVP_PKEY<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I have found some info and now some questions more clear for me. But still have 2 questions...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">i2d_ functions write the DER representation of the object into a buffer.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">d2i_ functions read the DER representation of the object from a buffer and creates the appropriate object in memory.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><strong>1. What is b2i_ and i2b_ functions?</strong><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">EVP_PKEY structure can hold public or private key. It's strangely why there is no this info in the official documentation on
<a href="http://www.openssl.org">www.openssl.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><strong>2. Can EVP_PKEY structure hold both private and public keys at once?</strong><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I have some example of code and there is a use of EVP_PKEY in this manner, that's why I am asking.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">03.02.2015, 13:21, "Serj" <<a href="mailto:rasjv@yandex.com">rasjv@yandex.com</a>>:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> Hello.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> I see many functions have prefixes: i2d_ d2i_ b2i_ i2b_<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> For example:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> i2d_PublicKey<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> i2d_PrivateKey<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> d2i_PublicKey<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> d2i_PrivateKey<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> b2i_PublicKey<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> b2i_PrivateKey<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> i2b_PublicKey_bio<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> i2b_PrivateKey_bio<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> I think these letters: 'i', 'd', 'b' have some meaning. Can somebody help me to understand what they are mean?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> And one more question.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> In accordance to: <a href="https://www.openssl.org/docs/crypto/EVP_PKEY_new.html">
https://www.openssl.org/docs/crypto/EVP_PKEY_new.html</a>, EVP_PKEY structure is used by OpenSSL to store private keys. But there are above functions which use as parameters pointer to EVP_PKEY structure and as they are named they can work with both public
 and private keys. So the questions are:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> 1. can we save to EVP_PKEY structure public key not private?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> 2. can we save to EVP_PKEY structure public and private keys at once?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> For example:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> EVP_PKEY * pkey;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> pkey = EVP_PKEY_new();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> RSA * rsa;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> rsa = RSA_generate_key(...)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> EVP_PKEY_assign_RSA(pkey, rsa);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> What key or keys will be in pkey after that?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Best Regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Serj<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="background:white"><o:p> </o:p></span></p>
<p align="center" style="text-align:center"><span style="background:white">Click <a href="https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==">
here</a> to report this email as spam.<o:p></o:p></span></p>
</div>
</div>
<br><br>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been scanned for malware by Websense.  </FONT><A href="http://www.websense.com/"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>www.websense.com</FONT></A></P>
</body>
</html>