<html 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=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Happy 2018 everyone.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I figured out this issue, I think it would be good to share it here in case if anyone is interested in knowing. The right way to make a hash is by calculating hash individually for the messages client certificate, client key exchange and store the message buffer in an array before calculating the signature in certificate verify message. later after forming the certificate verify message append this to the previous array and write the whole buffer into the wire with ssl3_write_bytes().This way all three message CC, CKE and CV goes in a single record as multiple handshake messages.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The function ssl3_finish_mac() is the one that does the hash (Digest) of bytes which ever are to be written to or read from wire.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Regards</p><p class=MsoNormal>Saiteja.</p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:openssl-users@dukhovni.org">Viktor Dukhovni</a><br><b>Sent: </b>Saturday, December 30, 2017 10:48 AM<br><b>To: </b><a href="mailto:openssl-users@openssl.org">openssl-users@openssl.org</a><br><b>Subject: </b>Re: [openssl-users] How to form a proper hash after writing somethinginto SSL handshake.(Revised)</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> On Dec 29, 2017, at 10:18 PM, Sai Teja Chowdary <asteja.chowdary.ece13@iitbhu.ac.in> wrote:</p><p class=MsoNormal>> </p><p class=MsoNormal>> I want to send client certificate, client key exchange and client verify in a single handshake message which appears as multiple handshake messages in a single record. But to sent the client verify I need to first make a hash of previous messages(client certificate and client key exchange) to create the signature. I tried framing the record with above three messages and then directly sending the record in the wire using SSL3_write_machine() which is giving me Bad signature error. So i thought of doing a hash of client certificate and client key exchange messages that go before client verify.</p><p class=MsoNormal>> </p><p class=MsoNormal>> Can anyone help me to find the function in OpenSSL 1.1.1-dev  xx XXX xxxx (or right procedure that needs to be done before creating a certificate verify message)that can do a proper transcript(digest or hash not clear). I tried using ssl3_finish_mac() on the message containing client certificate and client key exchange and then tried to generate the signature in certificate verify message.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>There is no such feature, and none is likely to ever be offered.</p><p class=MsoNormal>The reason is that you're essentially trying to write your own</p><p class=MsoNormal>TLS implementation, and SSL library in OpenSSL is provides public</p><p class=MsoNormal>interfaces for SSL users, not for new SSL implementations.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>You can of course build your OpenSSL implementation based on the</p><p class=MsoNormal>OpenSSL source code, but figuring out how the code works is then</p><p class=MsoNormal>up to you. :-(</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-- </p><p class=MsoNormal>           Viktor.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-- </p><p class=MsoNormal>openssl-users mailing list</p><p class=MsoNormal>To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>