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

Django: How do I validate unique_together from within the model
Munging non-printable characters to dots using string.translate()
Error when using astWCS trying to create WCS object
if there any better way to read bb function souce code.i was very faint
PyQt4 signals and slots
Sql Alchemy What is wrong?
How do I plot a graph in Python?
Reordering matrix elements to reflect column and row clustering in naiive python
making urllib request in Python from the client side
Grid within a frame?
how to create http headers from scratch
Mapping a range of values to another
maya2008 win32api 64 bit python
Python importing modules differently when run interactively/non-interactively
Why do I get this error in this Python code?
what is the correct way to close a socket in python 2.6?

Categories

HOME
xbox-live
cntk
mql4
payment-gateway
nlp
ipython
nuxeo
json-ld
histogrammar
currency
nixos
google-shopping
onsen-ui2
store
jcl
prestodb
sql-update
extractor
jquery-scrollify
fabric
rhandsontable
widevine
upnp
spring-data-neo4j
aurelia-binding
bxslider
pygooglechart
ioc-container
crt
pari
backup-strategies
passenger
nlb
polyfills
distributed-transactions
constants
excel-interop
matlab-cvst
catia
estimation
goquery
jgraph
etherpad
pycurl
infinite-scroll
bettercms
rxvt
cleditor
software-product-lines
gradle-eclipse
selecteditem
spinlock
financial
anti-cheat
cmocka
anythingslider
intellitest
wikitext
programming-paradigms
viper-architecture
criteria-api
subversion-edge
adodb
tilestache
symfony-2.6
and-operator
em
ogr2ogr
facebook-wall
surrogate-key
jstack
uipickerviewcontroller
sim900
cling
onselect
trimming
html-form-post
adomd.net
sharpmap
mailcore
symphony-cms
arbor.js
moq-3
fotoware
supersized
authenticode
msbuildextensionpack
clause
requestfactory
msn
gwt-2.2-celltable
act
hmacsha1
divx
cots

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