Questions tagged [initialization-vector]
121 questions
212
votes
16 answers
Encrypt and decrypt using PyCrypto AES-256
I'm trying to build two functions using PyCrypto that accept two parameters: the message and the key, and then encrypt/decrypt the message.
I found several links on the web to help me out, but each one of them has flaws:
This one at codekoala uses…

Cyril N.
- 38,875
- 36
- 142
- 243
72
votes
8 answers
Good AES Initialization Vector practice
per my question Aes Encryption... missing an important piece, I have now learned that my assumption for creating a reversible encryption on a string was a bit off. I now have
public static byte[] EncryptString(string toEncrypt, byte[]…

Jeremy Holovacs
- 22,480
- 33
- 117
- 254
41
votes
2 answers
AES encryption how to transport IV
I understand that unique IV is important in encrypting to prevent attacks like frequency analysis. The question: For AES CBC encryption, whats the importance of the IV? has a pretty clear answer explaining the importance of the IV.
Would there be…

RunHolt
- 1,892
- 2
- 19
- 26
28
votes
4 answers
Secret vs. Non-secret Initialization Vector
Today I was doing some leisurely reading and stumbled upon Section 5.8 (on page 45) of Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography (Revised) (NIST Special Publication 800-56A). I was very confused by…

Hut8
- 6,080
- 4
- 42
- 59
26
votes
5 answers
What is an openssl iv, and why do I need a key and an iv?
I am about to use the following script to encrypt and decrypt some data. I am using it because my current encryption does not work on our new server. We are currently using mcrypt so I want to change to openssl.
In our database we use aes encryption…

Thomas Williams
- 1,528
- 1
- 18
- 37
15
votes
1 answer
Generating random IV for AES in Java
I'm implementing and AES encryption engine for PBE in android, and I've found two ways to implement the creation of the IV and I would like to know which one is better and more secure for getting IvParameterSpec:
Method #1:
SecureRandom…

user1576396
- 341
- 1
- 2
- 7
14
votes
1 answer
Characteristics of an Initialization Vector
I'm by no means a cryptography expert, I have been reading a few questions around Stack Overflow and on Wikipedia but nothing is really 'clear cut' in terms of defining an IV and its usage.
Points I have discovered:
An IV is prepended to a…

Jamie Chapman
- 4,229
- 5
- 29
- 47
13
votes
2 answers
PyCrypto - How does the Initialization Vector work?
I'm trying to understand how PyCrypto works to use in a project but I'm not fully understanding the significance of the Initialization Vector (IV). I've found that I can use the wrong IV when decoding a string and I still seem to get the message…

Tim Tisdall
- 9,914
- 3
- 52
- 82
12
votes
3 answers
Why is random IV fine for AES-CBC but not for AES-GCM
I have been using AES-CBC for encryption and I use a random IV each time I encrypt plain text. As far as I can tell, this is the recommended approach.
I have been looking into AES-GCM / AES-CTR, primarily for the AEAD. I have not yet implemented…

garys
- 115
- 1
- 1
- 5
9
votes
6 answers
Need solution for wrong IV length in AES
I'm trying to implement AES in Java and this is the code I use:
byte[] sessionKey = {00000000000000000000000000000000};
byte[] iv = {00000000000000000000000000000000};
byte[] plaintext = "6a84867cd77e12ad07ea1be895c53fa3".getBytes();
Cipher…

Shahed
- 131
- 1
- 2
- 6
8
votes
3 answers
CTR mode use of Initial Vector(IV)
from what I know, CTR mode doesn't use an Initial Vector.
It just takes a counter, encrypts it with a given key and then XOR's the result with the plaintext in order to get the ciphertext.
Other block cipher modes like CBC before doing the…

Antonys
- 83
- 1
- 1
- 3
7
votes
1 answer
Storing the Initialization Vector - Separate field?
When encryption sensitive information using the .NET AesCryptoServiceProvider library I generate a unique Initialization Vector (IV) for each value that is encrypted. In the database record where I save the encrypted data I have a field named "IV"…

webworm
- 10,587
- 33
- 120
- 217
7
votes
2 answers
AES-GCM with BouncyCastle throws "mac check in GCM failed" when used with IV
I'm relatively new to developing something with encryption. Right now I'm trying to write a class which encrypts and decrypts Strings using BouncyCastle with AES-GCM. I read about the things you have to consider when implementing encryption. One of…

thaasoph
- 325
- 1
- 3
- 11
6
votes
2 answers
Generate random bytes Cocoa?
I need to generate some random data to append to my file for encryption. How would I go about doing this? Would it be sort of the same idea as generating a string of random characters?
Something like:
NSData *randomData = @"what should i put…
user762034
5
votes
1 answer
AES 256 Encryption -> Changing inititialization vector slightly changes decrypted message without knowing key
I made the following observation with an AES encrypt/decrypt example which is very counter intuitive for me.
I tried to encrypt and the decrypt a simple payload with AES in CBC mode.
My understanding is/was that the initialization vector does not…

DanEEStar
- 6,140
- 6
- 37
- 52