I am testing CTR mode on STM32 board. I want to know how the auto increment of counter happens and what is the method to follow if I have to increment the counter manually.
Basically there are two ways:
decode the counter to be a big number in some kind of library, increase that number, then encode it back as unsigned, statically sized, big endian value, making sure you left pad with zero valued bytes when necessary;
increase the value of the right-most byte (highest index) as unsigned number, if the resulting value is zero then increase the value of the byte before that, up to the leftmost byte if required (i.e. use a bit of awkward carry-bit detection).
Probably 2 is easier and less error prone; you'd just need a single loop construct, one expression to increase the byte value and an if statement to detect the carry by comparing to 00 afterwards.