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

                                Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                                Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                                Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020