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

Plotting Coordinate Lines Using Matplotlib
BASH - Summarising information present in 2 genotype data columns in one column (ped file) [closed]
Python 3: How to call function from another file and pass arguments to that function ?
Streaming mp3 files in Django through Nginx
Opening PE file with Bokken
Python exercise: last letter / first letter
Python/Pygame: Can you run a program whilst having a Pygame window that can still update?
Replacing values in array from netCDF
confused about Python list syntax
Object orientated function parameter to alter variables
Batch processing and breaking up an image
How can I connect multiple if statements when using regular expressions?
Using A For Loop to Return Unique Values in a Pandas Dataframe
Scraping a paginated website with fixed url for every page (Python)
How to index a Cartesian product
A numpy.ravel-likely way to deal with list directly [duplicate]

Categories

HOME
xbox-live
tinyos
reverse-engineering
cpu-architecture
visualization
playframework
sbt-assembly
simpy
urlencode
sudo
gimp
ssr
google-shopping
dryioc
local
cosmicmind
rapidjson
ida
sendkeys
scaling
mule-studio
pyyaml
aptana
clover
multicore
cython
os161
spring-test
badge
vcard
datadog
gpib
twitter-bootstrap-2
outsystems
oracle-xml-db
ifstream
swiftcharts
mms
liquid-xml
xamarin.uitest
axis-labels
visualstudio.testtools
s3cmd
lexical-analysis
upsert
mod-fcgid
jtds
livefyre
decompress
ticker
mercury
festival
shinyjs
garrys-mod
gulp-typescript
libreadline
hspec
xib
audioqueue
software-product-lines
instruments
dbscan
spring-repositories
logcat
web-essentials
android-viewholder
evo
rad
mptcp
urn
rspec3
git-checkout
custom-url
consensus
tilestache
libsndfile
odftoolkit
scala-2.11
fragment-tab-host
node-imagemagick
ghostdoc
log4cplus
phpdocx
zipalign
xenocode
loop-invariant
trimming
adomd.net
symphony-cms
xslkey
zend-lucene
client-library
template-haskell
code-conversion
socketstream
usn
cadisplaylink
caliper
hibernate3
jpf
flexicious
selectonemenu
nemerle
requestfactory
hadoop-plugins
grooveshark

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