python


Can't use 256-bits counter in AES.MODE_CTR cipher in python


guys. I use crypto library for AES encryption and decryption. AES-128 works perfect:
ctr = Counter.new(128)
key = os.urandom(16)
obj = AES.new(key, AES.MODE_CTR, counter=ctr)
But when I change 128 to 256, and 16 to 32 error occurs:
ValueError: unsupported format character 'b' (0x62) at index 29
Could you help me, any suggestions?
The counter size is the same as the block size of the block cipher. The block size and key size of a cipher are not directly related.
Now AES-256 has a key size of 256 bit and a block size of 128 bits. Rijndael, of which AES is a subset, can have a block size of 256 bit. But AES, using a key size of 128, 192 or 256 bits, will still have a block size of precisely 128 bits. And that's just because it has been defined that way.
So basically you should always leave ctr to Counter.new(128). If you want to use AES-256, increase your key to 32 bytes using os.urandom(32).
If you want to have hints on how to use / format the counter, please take a look at NIST SP 800-38A, Appendix B.

Related Links

How to create an infinite iterator to generate an incrementing alphabet pattern?
Python RTMP Authenticiation Script
How to change background colour in Kivy
Is it correct to use kwargs in the following scenario of python code?
List comprehension with elements appearing twice
How to unread a single char in Python?
Python - pass console command to 3rd party console application
Use select_related for comma separated field
Tensorflow Slim: 'module' object has no attribute 'sum_of_squares'
Trouble trying to test Tensorflow's RNN PTB example
Assert two variables are almost equal in python
PyQt: How to expand all children in a QTreeWidget
How to insert into sqlite faster [duplicate]
How to read and extract and merge multiple huge size csv(1G~)?
how to extract data from json. other answers here did not work for me
How to execute a script or a funciton through python setuptoos?

Categories

HOME
erlang
payment-gateway
freepascal
facebook-graph-api
laravel-5.3
ubuntu-16.04
formal-verification
laravel-5.2
amazon-product-api
computer-vision
azureservicebus
console
quill
java-home
avl-tree
currency
slim-3
aruco
cartodb
ssr
lagom
sql-tuning
multicore
plupload
nmake
rworldmap
jquery-scrollify
kong
mef2
pentaho-report-designer
pep8-assembly
strophe
entity-system
consumer
spring-insight
fractals
phpspreadsheet
windows-10-iot-core
text-files
rhel.net
coreclr
duktape
intellilock
exiftool
sendgrid-templates
mediawiki-extensions
android-maps-v2
pdftk
dojox.mobile
pytest-django
asmx
onmouseover
azure-availability-set
recycle-bin
httplib2
iphone-developer-program
qos
garrys-mod
cfeclipse
hspec
windows-azure-pack
spark-cassandra-connector
linkageerror
boost-hana
multilingual-app-toolkit
dac
xmp
git-rebase
galaxy
jta
app.xaml
base32
leadtools-sdk
type-mismatch
coypu
low-level
chaining
obfuscar
django-1.6
sysctl
surrogate-key
ssms-addin
jstack
unison
mimosa
gfs
sqljdbc
installshield-2011
robospice
grunt-contrib-compass
process-monitor
snapjs
radchart
redirectstandardoutput
hinstance
ou
easygui
paintcomponent
collect
server-error
pivotal-crm
surefire
file-encodings
jquery-ui-button
iphone-sdk-3.2
gears
weborb
document-library

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App