initialization-vector

openssl- decrypting a base64 string with a key and IV

笑着哭i 提交于 2019-12-07 08:10:31
I'm trying to decrypt a base64 string which has been encrypted with aes256 in openssl. I was given the session key and IV, which were encrypted with my key. I converted them to hexadecimal so that I can use the following openssl command: openssl enc -d -aes256 -iv iv.hex -K sessionkey.hex -in message.b64 -out message.txt I get the error saying the IV is a non-hex value. I started out with IV and session key in base64, which was encrypted with my key. So I did the following: //convert base64 to binary openssl base64 -d -in iv.b64 -out iv.bin openssl base64 -d -in sessionkey.b64 -out sessionkey

Why is random IV fine for AES-CBC but not for AES-GCM

烂漫一生 提交于 2019-12-06 05:48:43
问题 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 anything with this but from everything I have read, basically the nonce is just a shorted IV and there is an internal counter that is used for each encryption call. The developer / needs to make sure the nonce changes before the 32 bit counter cycles

Initialization vector length in AES

若如初见. 提交于 2019-12-05 06:14:00
问题 I used AES with AES/CBC/PKCS5Padding with the following encryption and decryption code sections in Android: cipher.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(IV1)); cipher.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(IV2)); where IV1 and IV2 are randomly generated 16-byte initialization vectors. I did this to check if the original and decrypted texts will be different using different IVs in encryption and decryption parties. This leads the bytes of the decrypted text to

CTR mode use of Initial Vector(IV)

我与影子孤独终老i 提交于 2019-12-03 10:41:10
问题 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 encryption they XOR the plaintext with an Initial Vector. So here is my problem. I have the following code in Java(using bouncycastle library): Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding", "BC"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[]

AES encryption how to transport IV

江枫思渺然 提交于 2019-11-30 06:24:36
问题 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 any security holes in sending the IV in clear text? Or would it need to be encrypted with the same public/private key that was used to send the symmetric key? If the IV needs to be sent encrypted, then why not generate a new symmetric key each time

Generating random IV for AES in Java

做~自己de王妃 提交于 2019-11-28 19:52:12
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 randomSecureRandom = SecureRandom.getInstance("SHA1PRNG"); byte[] iv = new byte[cipher.getBlockSize()]; randomSecureRandom.nextBytes(iv); IvParameterSpec ivParams = new IvParameterSpec(iv); Method #2: AlgorithmParameters params = cipher.getParameters(); byte[] iv2 = params.getParameterSpec(IvParameterSpec.class).getIV(); ivParams = new IvParameterSpec(iv2); I

AES encryption how to transport IV

╄→尐↘猪︶ㄣ 提交于 2019-11-28 18:16:05
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 any security holes in sending the IV in clear text? Or would it need to be encrypted with the same public/private key that was used to send the symmetric key? If the IV needs to be sent encrypted, then why not generate a new symmetric key each time and consider the IV as part of the key? Is it that generating a symmetric key is too costly? Or is it to

Need solution for wrong IV length in AES

天涯浪子 提交于 2019-11-28 06:38:57
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 cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(sessionKey, "AES"), new IvParameterSpec(iv)); byte[] ciphertext = cipher.doFinal(plaintext); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(sessionKey, "AES"), new IvParameterSpec(iv)); byte[] deciphertext = cipher.doFinal(ciphertext); I need this

Secret vs. Non-secret Initialization Vector

一曲冷凌霜 提交于 2019-11-27 19:23:51
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 this: An Approved key derivation function (KDF) shall be used to derive secret keying material from a shared secret. The output from a KDF shall only be used for secret keying material, such as a symmetric key used for data encryption or message integrity, a secret initialization vector, or a master key that will be used to generate other keys

Secret vs. Non-secret Initialization Vector

偶尔善良 提交于 2019-11-26 19:51:27
问题 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 this: An Approved key derivation function (KDF) shall be used to derive secret keying material from a shared secret. The output from a KDF shall only be used for secret keying material, such as a symmetric key used for data encryption or message