ipsec, esp: Which key is used to generate the HMAC The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What is the “shared secret” used for in IPSec VPN?What are the well known protocols that offer perfect forward secrecy?AES-GCM Hash sub key parameter in Intel's IPsec libraryIs IPsec IND-CCA secure provided the used block cipher is a pseudorandom function?where does the prime number taken in DH algorithm in IPSECWhy TLS uses in-band handshake signallingHow does OpenVPN work?

First use of “packing” as in carrying a gun

How to delete random line from file using Unix command?

Why can't wing-mounted spoilers be used to steepen approaches?

Would it be possible to rearrange a dragon's flight muscle to somewhat circumvent the square-cube law?

Windows 10: How to Lock (not sleep) laptop on lid close?

Typeface like Times New Roman but with "tied" percent sign

How to grep and cut numbers from a file and sum them

How does this infinite series simplify to an integral?

He got a vote 80% that of Emmanuel Macron’s

Can the prologue be the backstory of your main character?

Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?

Derivation tree not rendering

Can the DM override racial traits?

Can a 1st-level character have an ability score above 18?

Did God make two great lights or did He make the great light two?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Road tyres vs "Street" tyres for charity ride on MTB Tandem

Why can't devices on different VLANs, but on the same subnet, communicate?

How is simplicity better than precision and clarity in prose?

I could not break this equation. Please help me

Does Parliament hold absolute power in the UK?

Why not take a picture of a closer black hole?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

Segmentation fault output is suppressed when piping stdin into a function. Why?



ipsec, esp: Which key is used to generate the HMAC



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What is the “shared secret” used for in IPSec VPN?What are the well known protocols that offer perfect forward secrecy?AES-GCM Hash sub key parameter in Intel's IPsec libraryIs IPsec IND-CCA secure provided the used block cipher is a pseudorandom function?where does the prime number taken in DH algorithm in IPSECWhy TLS uses in-band handshake signallingHow does OpenVPN work?










1












$begingroup$


Short Question:
Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP?
Or do there exist two keys in the SA?



Long Question:
Before a new IPSEC-ESP connection is established, IKEv2 is used to start a new session.
This involves also a DH key agreement.
This key is than stored in the IKE-SA.



Once the session is established, ESP uses the key in the IKE-SA's for the message encryption/decryption.
After the payload was encrypted, the ICV is calculated by a HMAC calculation.
But this HMAC requires also a key.
I have already searched for a few hours without being successful.



Is it the same key that is used for encryption, is it calculated out of the encryption key or are there two keys stored in the SA?



I wasn't able to find the answer in rfc4303 (ESP), rfc2104 (HMAC) or rfc7296 (IKEv2).



And there are not many books about IPsec out there.










share|improve this question







New contributor




byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    1












    $begingroup$


    Short Question:
    Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP?
    Or do there exist two keys in the SA?



    Long Question:
    Before a new IPSEC-ESP connection is established, IKEv2 is used to start a new session.
    This involves also a DH key agreement.
    This key is than stored in the IKE-SA.



    Once the session is established, ESP uses the key in the IKE-SA's for the message encryption/decryption.
    After the payload was encrypted, the ICV is calculated by a HMAC calculation.
    But this HMAC requires also a key.
    I have already searched for a few hours without being successful.



    Is it the same key that is used for encryption, is it calculated out of the encryption key or are there two keys stored in the SA?



    I wasn't able to find the answer in rfc4303 (ESP), rfc2104 (HMAC) or rfc7296 (IKEv2).



    And there are not many books about IPsec out there.










    share|improve this question







    New contributor




    byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      1












      1








      1





      $begingroup$


      Short Question:
      Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP?
      Or do there exist two keys in the SA?



      Long Question:
      Before a new IPSEC-ESP connection is established, IKEv2 is used to start a new session.
      This involves also a DH key agreement.
      This key is than stored in the IKE-SA.



      Once the session is established, ESP uses the key in the IKE-SA's for the message encryption/decryption.
      After the payload was encrypted, the ICV is calculated by a HMAC calculation.
      But this HMAC requires also a key.
      I have already searched for a few hours without being successful.



      Is it the same key that is used for encryption, is it calculated out of the encryption key or are there two keys stored in the SA?



      I wasn't able to find the answer in rfc4303 (ESP), rfc2104 (HMAC) or rfc7296 (IKEv2).



      And there are not many books about IPsec out there.










      share|improve this question







      New contributor




      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      Short Question:
      Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP?
      Or do there exist two keys in the SA?



      Long Question:
      Before a new IPSEC-ESP connection is established, IKEv2 is used to start a new session.
      This involves also a DH key agreement.
      This key is than stored in the IKE-SA.



      Once the session is established, ESP uses the key in the IKE-SA's for the message encryption/decryption.
      After the payload was encrypted, the ICV is calculated by a HMAC calculation.
      But this HMAC requires also a key.
      I have already searched for a few hours without being successful.



      Is it the same key that is used for encryption, is it calculated out of the encryption key or are there two keys stored in the SA?



      I wasn't able to find the answer in rfc4303 (ESP), rfc2104 (HMAC) or rfc7296 (IKEv2).



      And there are not many books about IPsec out there.







      ipsec






      share|improve this question







      New contributor




      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 6 hours ago









      byteunitbyteunit

      1062




      1062




      New contributor




      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      byteunit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          2












          $begingroup$


          Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP? Or do there exist two keys in the SA?




          No, the keys are not the same. Yes, there do exist two keys in the SA (at least, for SAs that have separate encryption and integrity transforms - not all do).



          You do derive both the encryption and the HMAC key at the same time, from the same secret, but they are not the same (that'd be bad key hygene). Instead they are derived from the same secret (and also you generate the keys for the SA protecting traffic flowing in the opposite direction at the same time).



          That is, IKE generates a long random-looking string (which it refers to as KEYMAT); if the encryption key is n bits and the integrity (ICV) key is m bits (and AH is not being used), then at least 2n+2m bits of KEYMAT are generated, and then:



          • The first n bits is used as the initiator-to-responder encryption key (that is, used to protect traffic flowing from the initiator to the responder)

          • The next m bits is used as the initiator-to-responder integrity key

          • The next n bits is used as the responder-to-initiator encryption key

          • The next m bits is used as the responder-to-initiator integrity key

          To see the text of the standard, see section 2.17 of RFC7296:




          In any case, keying material
          for each Child SA MUST be taken from the expanded KEYMAT using the
          following rules:



          All keys for SAs carrying data from the initiator to the responder
          are taken before SAs going from the responder to the initiator.



          If multiple IPsec protocols are negotiated, keying material for
          each Child SA is taken in the order in which the protocol headers
          will appear in the encapsulated packet.



          If an IPsec protocol requires multiple keys, the order in which
          they are taken from the SA's keying material needs to be described
          in the protocol's specification. For ESP and AH, [IPSECARCH]
          defines the order, namely: the encryption key (if any) MUST be
          taken from the first bits and the integrity key (if any) MUST be
          taken from the remaining bits.




          The HMAC key is the 'integrity key'






          share|improve this answer











          $endgroup$













            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "281"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            byteunit is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f68754%2fipsec-esp-which-key-is-used-to-generate-the-hmac%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2












            $begingroup$


            Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP? Or do there exist two keys in the SA?




            No, the keys are not the same. Yes, there do exist two keys in the SA (at least, for SAs that have separate encryption and integrity transforms - not all do).



            You do derive both the encryption and the HMAC key at the same time, from the same secret, but they are not the same (that'd be bad key hygene). Instead they are derived from the same secret (and also you generate the keys for the SA protecting traffic flowing in the opposite direction at the same time).



            That is, IKE generates a long random-looking string (which it refers to as KEYMAT); if the encryption key is n bits and the integrity (ICV) key is m bits (and AH is not being used), then at least 2n+2m bits of KEYMAT are generated, and then:



            • The first n bits is used as the initiator-to-responder encryption key (that is, used to protect traffic flowing from the initiator to the responder)

            • The next m bits is used as the initiator-to-responder integrity key

            • The next n bits is used as the responder-to-initiator encryption key

            • The next m bits is used as the responder-to-initiator integrity key

            To see the text of the standard, see section 2.17 of RFC7296:




            In any case, keying material
            for each Child SA MUST be taken from the expanded KEYMAT using the
            following rules:



            All keys for SAs carrying data from the initiator to the responder
            are taken before SAs going from the responder to the initiator.



            If multiple IPsec protocols are negotiated, keying material for
            each Child SA is taken in the order in which the protocol headers
            will appear in the encapsulated packet.



            If an IPsec protocol requires multiple keys, the order in which
            they are taken from the SA's keying material needs to be described
            in the protocol's specification. For ESP and AH, [IPSECARCH]
            defines the order, namely: the encryption key (if any) MUST be
            taken from the first bits and the integrity key (if any) MUST be
            taken from the remaining bits.




            The HMAC key is the 'integrity key'






            share|improve this answer











            $endgroup$

















              2












              $begingroup$


              Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP? Or do there exist two keys in the SA?




              No, the keys are not the same. Yes, there do exist two keys in the SA (at least, for SAs that have separate encryption and integrity transforms - not all do).



              You do derive both the encryption and the HMAC key at the same time, from the same secret, but they are not the same (that'd be bad key hygene). Instead they are derived from the same secret (and also you generate the keys for the SA protecting traffic flowing in the opposite direction at the same time).



              That is, IKE generates a long random-looking string (which it refers to as KEYMAT); if the encryption key is n bits and the integrity (ICV) key is m bits (and AH is not being used), then at least 2n+2m bits of KEYMAT are generated, and then:



              • The first n bits is used as the initiator-to-responder encryption key (that is, used to protect traffic flowing from the initiator to the responder)

              • The next m bits is used as the initiator-to-responder integrity key

              • The next n bits is used as the responder-to-initiator encryption key

              • The next m bits is used as the responder-to-initiator integrity key

              To see the text of the standard, see section 2.17 of RFC7296:




              In any case, keying material
              for each Child SA MUST be taken from the expanded KEYMAT using the
              following rules:



              All keys for SAs carrying data from the initiator to the responder
              are taken before SAs going from the responder to the initiator.



              If multiple IPsec protocols are negotiated, keying material for
              each Child SA is taken in the order in which the protocol headers
              will appear in the encapsulated packet.



              If an IPsec protocol requires multiple keys, the order in which
              they are taken from the SA's keying material needs to be described
              in the protocol's specification. For ESP and AH, [IPSECARCH]
              defines the order, namely: the encryption key (if any) MUST be
              taken from the first bits and the integrity key (if any) MUST be
              taken from the remaining bits.




              The HMAC key is the 'integrity key'






              share|improve this answer











              $endgroup$















                2












                2








                2





                $begingroup$


                Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP? Or do there exist two keys in the SA?




                No, the keys are not the same. Yes, there do exist two keys in the SA (at least, for SAs that have separate encryption and integrity transforms - not all do).



                You do derive both the encryption and the HMAC key at the same time, from the same secret, but they are not the same (that'd be bad key hygene). Instead they are derived from the same secret (and also you generate the keys for the SA protecting traffic flowing in the opposite direction at the same time).



                That is, IKE generates a long random-looking string (which it refers to as KEYMAT); if the encryption key is n bits and the integrity (ICV) key is m bits (and AH is not being used), then at least 2n+2m bits of KEYMAT are generated, and then:



                • The first n bits is used as the initiator-to-responder encryption key (that is, used to protect traffic flowing from the initiator to the responder)

                • The next m bits is used as the initiator-to-responder integrity key

                • The next n bits is used as the responder-to-initiator encryption key

                • The next m bits is used as the responder-to-initiator integrity key

                To see the text of the standard, see section 2.17 of RFC7296:




                In any case, keying material
                for each Child SA MUST be taken from the expanded KEYMAT using the
                following rules:



                All keys for SAs carrying data from the initiator to the responder
                are taken before SAs going from the responder to the initiator.



                If multiple IPsec protocols are negotiated, keying material for
                each Child SA is taken in the order in which the protocol headers
                will appear in the encapsulated packet.



                If an IPsec protocol requires multiple keys, the order in which
                they are taken from the SA's keying material needs to be described
                in the protocol's specification. For ESP and AH, [IPSECARCH]
                defines the order, namely: the encryption key (if any) MUST be
                taken from the first bits and the integrity key (if any) MUST be
                taken from the remaining bits.




                The HMAC key is the 'integrity key'






                share|improve this answer











                $endgroup$




                Are the keys for the ICV calculation and the encryption the same in IPSEC/ESP? Or do there exist two keys in the SA?




                No, the keys are not the same. Yes, there do exist two keys in the SA (at least, for SAs that have separate encryption and integrity transforms - not all do).



                You do derive both the encryption and the HMAC key at the same time, from the same secret, but they are not the same (that'd be bad key hygene). Instead they are derived from the same secret (and also you generate the keys for the SA protecting traffic flowing in the opposite direction at the same time).



                That is, IKE generates a long random-looking string (which it refers to as KEYMAT); if the encryption key is n bits and the integrity (ICV) key is m bits (and AH is not being used), then at least 2n+2m bits of KEYMAT are generated, and then:



                • The first n bits is used as the initiator-to-responder encryption key (that is, used to protect traffic flowing from the initiator to the responder)

                • The next m bits is used as the initiator-to-responder integrity key

                • The next n bits is used as the responder-to-initiator encryption key

                • The next m bits is used as the responder-to-initiator integrity key

                To see the text of the standard, see section 2.17 of RFC7296:




                In any case, keying material
                for each Child SA MUST be taken from the expanded KEYMAT using the
                following rules:



                All keys for SAs carrying data from the initiator to the responder
                are taken before SAs going from the responder to the initiator.



                If multiple IPsec protocols are negotiated, keying material for
                each Child SA is taken in the order in which the protocol headers
                will appear in the encapsulated packet.



                If an IPsec protocol requires multiple keys, the order in which
                they are taken from the SA's keying material needs to be described
                in the protocol's specification. For ESP and AH, [IPSECARCH]
                defines the order, namely: the encryption key (if any) MUST be
                taken from the first bits and the integrity key (if any) MUST be
                taken from the remaining bits.




                The HMAC key is the 'integrity key'







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 4 hours ago









                ponchoponcho

                94k2148247




                94k2148247




















                    byteunit is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    byteunit is a new contributor. Be nice, and check out our Code of Conduct.












                    byteunit is a new contributor. Be nice, and check out our Code of Conduct.











                    byteunit is a new contributor. Be nice, and check out our Code of Conduct.














                    Thanks for contributing an answer to Cryptography Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f68754%2fipsec-esp-which-key-is-used-to-generate-the-hmac%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

                    Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

                    Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar