What happens if you increment MAX counter in AES-CTR?What is a safe maximum message size limit when encrypting files to disk with AES-GCM before the need to re-generate the key or NONCEMaking counter (CTR) mode robust against application state lossHow does the IV or initial counter increase internally for each block in AES CTR mode?Value of “counter” when decrypting AES in CTR mode?Message lengths with AES CTR mode?Can AES in CCM or GCM counter mode interoperate with AES in “plain” counter mode (CTR)?How to increment the counter value for CTR mode?Seekable cipher, is AES CTR a good solution?the counter mode of encryption CTR - AESAES-CTR-MAC alternative

Symbol for "not absolutely continuous" in Latex

Why are many Chinese characters almost symmetrical but not exactly symmetrical?

Should I report a leak of confidential HR information?

Getting geometries of hurricane's 'cone of uncertainty' using shapely?

In native German words, is Q always followed by U, as in English?

Is it bad to describe a character long after their introduction?

Why are 120V general receptacle circuits limited to 20A?

Who is Johanna in this Joan Baez song - The Winds of the Old Days

Prevent cacls asking for confirmation?

Spicket or spigot?

How do I delete a Bitcoin full node from my hard drive?

Did Wakanda officially get the stuff out of Bucky's head?

Does “comme on était à New York” mean “since” or “as though”?

Do sudoku answers always have a single minimal clue set?

Can another character physically take something that Mage Hand is carrying/holding?

What are good ways to spray paint a QR code on a footpath?

Was touching your nose a greeting in second millenium Mesopotamia?

What is the line crossing the Pacific Ocean that is shown on maps?

Golf the smallest circle!

What is the difference between x RadToDeg cos x div and COSC?

How hard is it to sell a home which is currently mortgaged?

Why does this function call behave sensibly after calling it through a typecasted function pointer?

What is a macro? Difference between macro and function?

Should I hide continue button until tasks are completed?



What happens if you increment MAX counter in AES-CTR?


What is a safe maximum message size limit when encrypting files to disk with AES-GCM before the need to re-generate the key or NONCEMaking counter (CTR) mode robust against application state lossHow does the IV or initial counter increase internally for each block in AES CTR mode?Value of “counter” when decrypting AES in CTR mode?Message lengths with AES CTR mode?Can AES in CCM or GCM counter mode interoperate with AES in “plain” counter mode (CTR)?How to increment the counter value for CTR mode?Seekable cipher, is AES CTR a good solution?the counter mode of encryption CTR - AESAES-CTR-MAC alternative






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1












$begingroup$


Suppose you use a IV/counter = ffffffffffffffffffffffffffffffffin AES-CTR. What will happen if you encrypt the next block, and thereby increment the counter by one? Will it result in an overflow error of sorts?










share|improve this question









$endgroup$











  • $begingroup$
    As far as I know behavior is specific to the implementation, it isn't standardized anywhere.
    $endgroup$
    – puzzlepalace
    Jun 10 at 19:39


















1












$begingroup$


Suppose you use a IV/counter = ffffffffffffffffffffffffffffffffin AES-CTR. What will happen if you encrypt the next block, and thereby increment the counter by one? Will it result in an overflow error of sorts?










share|improve this question









$endgroup$











  • $begingroup$
    As far as I know behavior is specific to the implementation, it isn't standardized anywhere.
    $endgroup$
    – puzzlepalace
    Jun 10 at 19:39














1












1








1





$begingroup$


Suppose you use a IV/counter = ffffffffffffffffffffffffffffffffin AES-CTR. What will happen if you encrypt the next block, and thereby increment the counter by one? Will it result in an overflow error of sorts?










share|improve this question









$endgroup$




Suppose you use a IV/counter = ffffffffffffffffffffffffffffffffin AES-CTR. What will happen if you encrypt the next block, and thereby increment the counter by one? Will it result in an overflow error of sorts?







aes block-cipher initialization-vector






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 10 at 2:48









KyomaKyoma

62 bronze badges




62 bronze badges











  • $begingroup$
    As far as I know behavior is specific to the implementation, it isn't standardized anywhere.
    $endgroup$
    – puzzlepalace
    Jun 10 at 19:39

















  • $begingroup$
    As far as I know behavior is specific to the implementation, it isn't standardized anywhere.
    $endgroup$
    – puzzlepalace
    Jun 10 at 19:39
















$begingroup$
As far as I know behavior is specific to the implementation, it isn't standardized anywhere.
$endgroup$
– puzzlepalace
Jun 10 at 19:39





$begingroup$
As far as I know behavior is specific to the implementation, it isn't standardized anywhere.
$endgroup$
– puzzlepalace
Jun 10 at 19:39











3 Answers
3






active

oldest

votes


















3












$begingroup$

In AES-CTR, the ‘IV’ and ‘counter’ are different concepts. To encrypt a message, you specify a nonce, like a message sequence number—sometimes called an ‘IV’. The nonce is usually 64 or 96 bits, but it could be anywhere from 0 to 128 bits long. For security, you must never reuse a nonce with a key. The length of the nonce for the particular AES-CTR system you're using determines the maximum message length: inside AES-CTR, the remainder of a 128-bit string after filling part of it with a nonce is used to count blocks within a message.



So, for example, if you send the message $m_1 mathbin| m_2 mathbin| m_3$, and then the message $m'_1 mathbin| m'_2$, you might in your protocol choose the nonce 42 for the first message, and the nonce 69 for the second, and the ciphertexts will be internally computed as:



beginalign
c &= bigl(m_1 oplus operatornameAES_k(42 mathbin| 0)) mathbin| (m_2 oplus operatornameAES_k(42 mathbin| 1) mathbin| (m_3 oplus operatornameAES_k(42 mathbin| 2)bigr), \
c' &= bigl(m'_1 oplus operatornameAES_k(69 mathbin| 0)) mathbin| (m'_2 oplus operatornameAES_k(69 mathbin| 1)bigr).
endalign



(Here the $m_i$ and $m'_i$ are exactly 128 bits long apiece; it is inside AES-CTR that the block counter 0, 1, 2, …, is maintained.)



For (say) AES-CTR with a 96-bit nonce, the maximum message length is $2^32$ 128-bit blocks, or $2^36$ bytes. What happens if you try to encrypt a $(2^36 + 1)$-byte message? It's simply not defined in that case—like dividing by zero. You should avoid designing a protocol in which this question might even arise; what an implementation might do may vary: it could silently wrap around, effectively encrypting messages with a two-time pad; it could fail noisily and abort the computation; it could make demons fly out of your nose.



What if you use a 0-bit nonce, so that the maximum message length is $2^128$ 128-bit blocks, or $2^132$ bytes? You don't have that many bytes and you don't have enough time to wait for all the computers in the world to encrypt that many bytes.



What if—internal block counter aside—you use a 64-bit message sequence number as a nonce? Will you have to worry about wrapping around? Hint: You are doing this in sequence. Let's say it takes you a nanosecond to encrypt each message. How many centuries do you have to wait for a 64-bit message counter to overflow?






share|improve this answer









$endgroup$




















    1












    $begingroup$

    What do you expect to generate the overflow error? The AES function certainly doesn't know about the way you construct the 16 byte cleartext block.



    AES-CTR is usually done with 64 bits of nonce and 64 bits of counter, so it will overflow much sooner, after $ 2^64 - 1 $. The counter value will either wrap around, or raise an error / throw an exception, or will just become $ 2^64 $ and then $ 2^64 + 1 $, depending on the programming language you use (sometimes, depending on whether you're compiling in debug or release mode!).



    For C unsigned integer type like uint64_t, it will wrap around to 0. For a hypothetical signed C type that is big enough to fit that value, because signed overflow is undefined, the compiler is allowed to generate whatever code it wants (this would be very bad).



    Java plain doesn't have unsigned 64 bit ints, only signed ones, but the language spec says what happens to them at overflow.



    Python has only bigints (no fixed sized ints except as part of typed arrays), so it will happily be a 65 bit value (or a 6,500 bit value).



    Consult your programming language reference manual (or CPU ISA manual if programming in assembly).



    Depending on your authentication scheme or AEAD, you don't want to wait for that counter to wrap around, because you are supposed to re-key earlier. For example AES-GCM should use 96 bits nonce and 32 bits counter, for reasons.






    share|improve this answer











    $endgroup$




















      0












      $begingroup$

      To ignore the (important) security issues and to just answer the question:



      It depends. The 128-bit block can be separated into a "nonce" and a "counter", and then you would wrap around only on the counter. For example, if the counter is 32 bits, then you would go back to ffffffffffffffffffffffff00000000.



      However, the vast majority of implementations see the entire block as a counter, therefore you would go back to 00000000000000000000000000000000.






      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
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f71195%2fwhat-happens-if-you-increment-max-counter-in-aes-ctr%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3












        $begingroup$

        In AES-CTR, the ‘IV’ and ‘counter’ are different concepts. To encrypt a message, you specify a nonce, like a message sequence number—sometimes called an ‘IV’. The nonce is usually 64 or 96 bits, but it could be anywhere from 0 to 128 bits long. For security, you must never reuse a nonce with a key. The length of the nonce for the particular AES-CTR system you're using determines the maximum message length: inside AES-CTR, the remainder of a 128-bit string after filling part of it with a nonce is used to count blocks within a message.



        So, for example, if you send the message $m_1 mathbin| m_2 mathbin| m_3$, and then the message $m'_1 mathbin| m'_2$, you might in your protocol choose the nonce 42 for the first message, and the nonce 69 for the second, and the ciphertexts will be internally computed as:



        beginalign
        c &= bigl(m_1 oplus operatornameAES_k(42 mathbin| 0)) mathbin| (m_2 oplus operatornameAES_k(42 mathbin| 1) mathbin| (m_3 oplus operatornameAES_k(42 mathbin| 2)bigr), \
        c' &= bigl(m'_1 oplus operatornameAES_k(69 mathbin| 0)) mathbin| (m'_2 oplus operatornameAES_k(69 mathbin| 1)bigr).
        endalign



        (Here the $m_i$ and $m'_i$ are exactly 128 bits long apiece; it is inside AES-CTR that the block counter 0, 1, 2, …, is maintained.)



        For (say) AES-CTR with a 96-bit nonce, the maximum message length is $2^32$ 128-bit blocks, or $2^36$ bytes. What happens if you try to encrypt a $(2^36 + 1)$-byte message? It's simply not defined in that case—like dividing by zero. You should avoid designing a protocol in which this question might even arise; what an implementation might do may vary: it could silently wrap around, effectively encrypting messages with a two-time pad; it could fail noisily and abort the computation; it could make demons fly out of your nose.



        What if you use a 0-bit nonce, so that the maximum message length is $2^128$ 128-bit blocks, or $2^132$ bytes? You don't have that many bytes and you don't have enough time to wait for all the computers in the world to encrypt that many bytes.



        What if—internal block counter aside—you use a 64-bit message sequence number as a nonce? Will you have to worry about wrapping around? Hint: You are doing this in sequence. Let's say it takes you a nanosecond to encrypt each message. How many centuries do you have to wait for a 64-bit message counter to overflow?






        share|improve this answer









        $endgroup$

















          3












          $begingroup$

          In AES-CTR, the ‘IV’ and ‘counter’ are different concepts. To encrypt a message, you specify a nonce, like a message sequence number—sometimes called an ‘IV’. The nonce is usually 64 or 96 bits, but it could be anywhere from 0 to 128 bits long. For security, you must never reuse a nonce with a key. The length of the nonce for the particular AES-CTR system you're using determines the maximum message length: inside AES-CTR, the remainder of a 128-bit string after filling part of it with a nonce is used to count blocks within a message.



          So, for example, if you send the message $m_1 mathbin| m_2 mathbin| m_3$, and then the message $m'_1 mathbin| m'_2$, you might in your protocol choose the nonce 42 for the first message, and the nonce 69 for the second, and the ciphertexts will be internally computed as:



          beginalign
          c &= bigl(m_1 oplus operatornameAES_k(42 mathbin| 0)) mathbin| (m_2 oplus operatornameAES_k(42 mathbin| 1) mathbin| (m_3 oplus operatornameAES_k(42 mathbin| 2)bigr), \
          c' &= bigl(m'_1 oplus operatornameAES_k(69 mathbin| 0)) mathbin| (m'_2 oplus operatornameAES_k(69 mathbin| 1)bigr).
          endalign



          (Here the $m_i$ and $m'_i$ are exactly 128 bits long apiece; it is inside AES-CTR that the block counter 0, 1, 2, …, is maintained.)



          For (say) AES-CTR with a 96-bit nonce, the maximum message length is $2^32$ 128-bit blocks, or $2^36$ bytes. What happens if you try to encrypt a $(2^36 + 1)$-byte message? It's simply not defined in that case—like dividing by zero. You should avoid designing a protocol in which this question might even arise; what an implementation might do may vary: it could silently wrap around, effectively encrypting messages with a two-time pad; it could fail noisily and abort the computation; it could make demons fly out of your nose.



          What if you use a 0-bit nonce, so that the maximum message length is $2^128$ 128-bit blocks, or $2^132$ bytes? You don't have that many bytes and you don't have enough time to wait for all the computers in the world to encrypt that many bytes.



          What if—internal block counter aside—you use a 64-bit message sequence number as a nonce? Will you have to worry about wrapping around? Hint: You are doing this in sequence. Let's say it takes you a nanosecond to encrypt each message. How many centuries do you have to wait for a 64-bit message counter to overflow?






          share|improve this answer









          $endgroup$















            3












            3








            3





            $begingroup$

            In AES-CTR, the ‘IV’ and ‘counter’ are different concepts. To encrypt a message, you specify a nonce, like a message sequence number—sometimes called an ‘IV’. The nonce is usually 64 or 96 bits, but it could be anywhere from 0 to 128 bits long. For security, you must never reuse a nonce with a key. The length of the nonce for the particular AES-CTR system you're using determines the maximum message length: inside AES-CTR, the remainder of a 128-bit string after filling part of it with a nonce is used to count blocks within a message.



            So, for example, if you send the message $m_1 mathbin| m_2 mathbin| m_3$, and then the message $m'_1 mathbin| m'_2$, you might in your protocol choose the nonce 42 for the first message, and the nonce 69 for the second, and the ciphertexts will be internally computed as:



            beginalign
            c &= bigl(m_1 oplus operatornameAES_k(42 mathbin| 0)) mathbin| (m_2 oplus operatornameAES_k(42 mathbin| 1) mathbin| (m_3 oplus operatornameAES_k(42 mathbin| 2)bigr), \
            c' &= bigl(m'_1 oplus operatornameAES_k(69 mathbin| 0)) mathbin| (m'_2 oplus operatornameAES_k(69 mathbin| 1)bigr).
            endalign



            (Here the $m_i$ and $m'_i$ are exactly 128 bits long apiece; it is inside AES-CTR that the block counter 0, 1, 2, …, is maintained.)



            For (say) AES-CTR with a 96-bit nonce, the maximum message length is $2^32$ 128-bit blocks, or $2^36$ bytes. What happens if you try to encrypt a $(2^36 + 1)$-byte message? It's simply not defined in that case—like dividing by zero. You should avoid designing a protocol in which this question might even arise; what an implementation might do may vary: it could silently wrap around, effectively encrypting messages with a two-time pad; it could fail noisily and abort the computation; it could make demons fly out of your nose.



            What if you use a 0-bit nonce, so that the maximum message length is $2^128$ 128-bit blocks, or $2^132$ bytes? You don't have that many bytes and you don't have enough time to wait for all the computers in the world to encrypt that many bytes.



            What if—internal block counter aside—you use a 64-bit message sequence number as a nonce? Will you have to worry about wrapping around? Hint: You are doing this in sequence. Let's say it takes you a nanosecond to encrypt each message. How many centuries do you have to wait for a 64-bit message counter to overflow?






            share|improve this answer









            $endgroup$



            In AES-CTR, the ‘IV’ and ‘counter’ are different concepts. To encrypt a message, you specify a nonce, like a message sequence number—sometimes called an ‘IV’. The nonce is usually 64 or 96 bits, but it could be anywhere from 0 to 128 bits long. For security, you must never reuse a nonce with a key. The length of the nonce for the particular AES-CTR system you're using determines the maximum message length: inside AES-CTR, the remainder of a 128-bit string after filling part of it with a nonce is used to count blocks within a message.



            So, for example, if you send the message $m_1 mathbin| m_2 mathbin| m_3$, and then the message $m'_1 mathbin| m'_2$, you might in your protocol choose the nonce 42 for the first message, and the nonce 69 for the second, and the ciphertexts will be internally computed as:



            beginalign
            c &= bigl(m_1 oplus operatornameAES_k(42 mathbin| 0)) mathbin| (m_2 oplus operatornameAES_k(42 mathbin| 1) mathbin| (m_3 oplus operatornameAES_k(42 mathbin| 2)bigr), \
            c' &= bigl(m'_1 oplus operatornameAES_k(69 mathbin| 0)) mathbin| (m'_2 oplus operatornameAES_k(69 mathbin| 1)bigr).
            endalign



            (Here the $m_i$ and $m'_i$ are exactly 128 bits long apiece; it is inside AES-CTR that the block counter 0, 1, 2, …, is maintained.)



            For (say) AES-CTR with a 96-bit nonce, the maximum message length is $2^32$ 128-bit blocks, or $2^36$ bytes. What happens if you try to encrypt a $(2^36 + 1)$-byte message? It's simply not defined in that case—like dividing by zero. You should avoid designing a protocol in which this question might even arise; what an implementation might do may vary: it could silently wrap around, effectively encrypting messages with a two-time pad; it could fail noisily and abort the computation; it could make demons fly out of your nose.



            What if you use a 0-bit nonce, so that the maximum message length is $2^128$ 128-bit blocks, or $2^132$ bytes? You don't have that many bytes and you don't have enough time to wait for all the computers in the world to encrypt that many bytes.



            What if—internal block counter aside—you use a 64-bit message sequence number as a nonce? Will you have to worry about wrapping around? Hint: You are doing this in sequence. Let's say it takes you a nanosecond to encrypt each message. How many centuries do you have to wait for a 64-bit message counter to overflow?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 10 at 3:44









            Squeamish OssifrageSqueamish Ossifrage

            29.1k1 gold badge44 silver badges123 bronze badges




            29.1k1 gold badge44 silver badges123 bronze badges























                1












                $begingroup$

                What do you expect to generate the overflow error? The AES function certainly doesn't know about the way you construct the 16 byte cleartext block.



                AES-CTR is usually done with 64 bits of nonce and 64 bits of counter, so it will overflow much sooner, after $ 2^64 - 1 $. The counter value will either wrap around, or raise an error / throw an exception, or will just become $ 2^64 $ and then $ 2^64 + 1 $, depending on the programming language you use (sometimes, depending on whether you're compiling in debug or release mode!).



                For C unsigned integer type like uint64_t, it will wrap around to 0. For a hypothetical signed C type that is big enough to fit that value, because signed overflow is undefined, the compiler is allowed to generate whatever code it wants (this would be very bad).



                Java plain doesn't have unsigned 64 bit ints, only signed ones, but the language spec says what happens to them at overflow.



                Python has only bigints (no fixed sized ints except as part of typed arrays), so it will happily be a 65 bit value (or a 6,500 bit value).



                Consult your programming language reference manual (or CPU ISA manual if programming in assembly).



                Depending on your authentication scheme or AEAD, you don't want to wait for that counter to wrap around, because you are supposed to re-key earlier. For example AES-GCM should use 96 bits nonce and 32 bits counter, for reasons.






                share|improve this answer











                $endgroup$

















                  1












                  $begingroup$

                  What do you expect to generate the overflow error? The AES function certainly doesn't know about the way you construct the 16 byte cleartext block.



                  AES-CTR is usually done with 64 bits of nonce and 64 bits of counter, so it will overflow much sooner, after $ 2^64 - 1 $. The counter value will either wrap around, or raise an error / throw an exception, or will just become $ 2^64 $ and then $ 2^64 + 1 $, depending on the programming language you use (sometimes, depending on whether you're compiling in debug or release mode!).



                  For C unsigned integer type like uint64_t, it will wrap around to 0. For a hypothetical signed C type that is big enough to fit that value, because signed overflow is undefined, the compiler is allowed to generate whatever code it wants (this would be very bad).



                  Java plain doesn't have unsigned 64 bit ints, only signed ones, but the language spec says what happens to them at overflow.



                  Python has only bigints (no fixed sized ints except as part of typed arrays), so it will happily be a 65 bit value (or a 6,500 bit value).



                  Consult your programming language reference manual (or CPU ISA manual if programming in assembly).



                  Depending on your authentication scheme or AEAD, you don't want to wait for that counter to wrap around, because you are supposed to re-key earlier. For example AES-GCM should use 96 bits nonce and 32 bits counter, for reasons.






                  share|improve this answer











                  $endgroup$















                    1












                    1








                    1





                    $begingroup$

                    What do you expect to generate the overflow error? The AES function certainly doesn't know about the way you construct the 16 byte cleartext block.



                    AES-CTR is usually done with 64 bits of nonce and 64 bits of counter, so it will overflow much sooner, after $ 2^64 - 1 $. The counter value will either wrap around, or raise an error / throw an exception, or will just become $ 2^64 $ and then $ 2^64 + 1 $, depending on the programming language you use (sometimes, depending on whether you're compiling in debug or release mode!).



                    For C unsigned integer type like uint64_t, it will wrap around to 0. For a hypothetical signed C type that is big enough to fit that value, because signed overflow is undefined, the compiler is allowed to generate whatever code it wants (this would be very bad).



                    Java plain doesn't have unsigned 64 bit ints, only signed ones, but the language spec says what happens to them at overflow.



                    Python has only bigints (no fixed sized ints except as part of typed arrays), so it will happily be a 65 bit value (or a 6,500 bit value).



                    Consult your programming language reference manual (or CPU ISA manual if programming in assembly).



                    Depending on your authentication scheme or AEAD, you don't want to wait for that counter to wrap around, because you are supposed to re-key earlier. For example AES-GCM should use 96 bits nonce and 32 bits counter, for reasons.






                    share|improve this answer











                    $endgroup$



                    What do you expect to generate the overflow error? The AES function certainly doesn't know about the way you construct the 16 byte cleartext block.



                    AES-CTR is usually done with 64 bits of nonce and 64 bits of counter, so it will overflow much sooner, after $ 2^64 - 1 $. The counter value will either wrap around, or raise an error / throw an exception, or will just become $ 2^64 $ and then $ 2^64 + 1 $, depending on the programming language you use (sometimes, depending on whether you're compiling in debug or release mode!).



                    For C unsigned integer type like uint64_t, it will wrap around to 0. For a hypothetical signed C type that is big enough to fit that value, because signed overflow is undefined, the compiler is allowed to generate whatever code it wants (this would be very bad).



                    Java plain doesn't have unsigned 64 bit ints, only signed ones, but the language spec says what happens to them at overflow.



                    Python has only bigints (no fixed sized ints except as part of typed arrays), so it will happily be a 65 bit value (or a 6,500 bit value).



                    Consult your programming language reference manual (or CPU ISA manual if programming in assembly).



                    Depending on your authentication scheme or AEAD, you don't want to wait for that counter to wrap around, because you are supposed to re-key earlier. For example AES-GCM should use 96 bits nonce and 32 bits counter, for reasons.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 10 at 3:28

























                    answered Jun 10 at 3:22









                    Z.T.Z.T.

                    5893 silver badges16 bronze badges




                    5893 silver badges16 bronze badges





















                        0












                        $begingroup$

                        To ignore the (important) security issues and to just answer the question:



                        It depends. The 128-bit block can be separated into a "nonce" and a "counter", and then you would wrap around only on the counter. For example, if the counter is 32 bits, then you would go back to ffffffffffffffffffffffff00000000.



                        However, the vast majority of implementations see the entire block as a counter, therefore you would go back to 00000000000000000000000000000000.






                        share|improve this answer









                        $endgroup$

















                          0












                          $begingroup$

                          To ignore the (important) security issues and to just answer the question:



                          It depends. The 128-bit block can be separated into a "nonce" and a "counter", and then you would wrap around only on the counter. For example, if the counter is 32 bits, then you would go back to ffffffffffffffffffffffff00000000.



                          However, the vast majority of implementations see the entire block as a counter, therefore you would go back to 00000000000000000000000000000000.






                          share|improve this answer









                          $endgroup$















                            0












                            0








                            0





                            $begingroup$

                            To ignore the (important) security issues and to just answer the question:



                            It depends. The 128-bit block can be separated into a "nonce" and a "counter", and then you would wrap around only on the counter. For example, if the counter is 32 bits, then you would go back to ffffffffffffffffffffffff00000000.



                            However, the vast majority of implementations see the entire block as a counter, therefore you would go back to 00000000000000000000000000000000.






                            share|improve this answer









                            $endgroup$



                            To ignore the (important) security issues and to just answer the question:



                            It depends. The 128-bit block can be separated into a "nonce" and a "counter", and then you would wrap around only on the counter. For example, if the counter is 32 bits, then you would go back to ffffffffffffffffffffffff00000000.



                            However, the vast majority of implementations see the entire block as a counter, therefore you would go back to 00000000000000000000000000000000.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 10 at 13:58









                            ConradoConrado

                            2,67813 silver badges27 bronze badges




                            2,67813 silver badges27 bronze badges



























                                draft saved

                                draft discarded
















































                                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%2f71195%2fwhat-happens-if-you-increment-max-counter-in-aes-ctr%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

                                Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

                                Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

                                What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company