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

QTableWidget - Change the row color
Sum the first value of each tuple in a list
Keras : Fine Tune Training Inference weight file has incorrect # of layers
Applying operation to unevenly split portions of numpy array
Unhiding and Hiding columns within my workbook
How i will insert matrices in an array in python
Python: How to increment a special-purpose string?
Change range withouth scaling in matplot
Python ViolinPlots
How do I plot a histogram of months with dates in matplotlib
Can't switch between pages in flask when video is buffering [duplicate]
Python: What is the most optimised way to count number of 0's from a list of 0's and 1's without using any in-build functions?
Theano: Fastest large-scale symmetric linear system solve
Parallel processing with Python class object
How to use faulhaber sequence in python?
Unexpected issue when encoding data using LabelEncoder and OneHotEncoder from sklearn

Categories

HOME
erlang
bibtex
apollo
rfc
checksum
value
dataframe
ng-admin
gimp
dropbear
hosts
xamarin-studio
cpanel
qt-installer
multiple-monitors
eclipse-luna
dendrogram
apache-karaf
vs2017
ng2-dragula
scalaz7
delete-file
java-ee-7
opencart2.3
solidworks
forum
expand
outsystems
skygear
graph-databases
stocks
rhomobile
phpspreadsheet
threshold
lego
bing-maps-api
text-files
nodeclipse
swagger-editor
sql-like
concrete5-5.7
common.logging
jupyter-console
mediawiki-extensions
react-native-router-flux
cppunit
nsjsonserialization
crystal-reports-8.5
emoticons
emgu
verbose
sql-server-administration
system.web.ui.webcontrols
cfeclipse
pydio
wcf-ria-services
foxit
database-backups
soda
shipitjs
ng2-material
remoteapp
gradle-release-plugin
amazon-kcl
axes
eyeql
programming-paradigms
integral
ibm-data-studio
rspec3
pylearn
scrollspy
mdm-zinc
client-side-validation
scala-2.11
fragment-tab-host
grunt-express
proxies
slick-2.0
json-patch
android-json-rpc
db4o
pyjade
cling
angulartics
nsmatrix
gridworld
multiple-conditions
icsharpcode
dropdownlistfor
javascriptserializer
parameterization
ou
dcpu-16
server-error
chatroom
pantheios
open-graph-beta
task-management
dirty-data
usergroups
associativity

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