Questions tagged [cbc-mode]

CBC Mode is cipher block chaining.

CBC mode was originally specified by NIST in FIPS 81. The standard, issued in 1981, only offers confidentiality. Other modes, such as CCM and GCM, offer authenticated encryption which places an integrity assurance over the encrpyted data.

In CBC mode, an initialization vector must be used in the first block of plaintext. Then each subsequent block of plaintext is XORed with the previous ciphertext block before being encrypted thus making all the blocks dependent on all the previous blocks. This means that in order to find the plaintext of a particular block, you need to know the ciphertext, the key, and the ciphertext for the previous block.

247 questions
0
votes
1 answer

Getting a javax.crypto.BadPaddingException for AES CBS encrypted data in python

I am porting code from java to python and this is my code in python self.BLOCK_SIZE = 16 def pkcs5_pad(self, s): padder = padding.PKCS7(128).padder() padded_data = padder.update(s) padded_data += padder.finalize() return…
Abhi
  • 261
  • 1
  • 3
  • 12
0
votes
1 answer

Can we use one mode for encryption and another for decryption in AES

Server side is using AES/ECB/PKCS5Padding mode of encryption and in client side (mobile)is it possible to decrypt it with AES/CBC/PKCS5Padding .or we need to use same mode for both server and client side? Please advise.
Kris
  • 891
  • 2
  • 18
  • 41
0
votes
1 answer

Why is there an extra block when encrypting?

I am passing input data 20 bytes long and java AES-CBC returns 48 bytes instead of 32 which is what I think it should output because of padding. My key is 16 bytes long. byte[] ciphertext; byte[] thekey = new byte[16]; new…
dfs
  • 35
  • 1
  • 4
0
votes
1 answer

JAVA: how to encrypt and view an image

I have to cipher an image using Java. I encrypt the image properly but I don't know how to visualize it because when I try to open the file the system tells me that the image is too long or is a corrupt file. How can I do to work with the pic body…
juliocb92
  • 96
  • 2
  • 12
0
votes
1 answer

AES. javax.crypto.Cipher returns empty array in decryption mode

I'm implementing CBC mode by myself. And I use AES as an E function for each CBC block. Here is my encryption code: public static List encrypt(List bytes, byte[] key) throws Exception { byte[] bytesArray =…
Anton Holovin
  • 5,513
  • 1
  • 31
  • 33
0
votes
2 answers

Encrypt data in Android and decrypt in Ruby using AESCrypt

I'm trying to encrypt a JSON string in Android and decrypt it in Ruby using AESCrypt. AESCrypt.decrypt(dataToDecrypt, secret) With this Java code I could decrypt second half of the data! MessageDigest md =…
Amir Karimi
  • 5,401
  • 4
  • 32
  • 51
0
votes
0 answers

Implement initial vector (IV) in CBC mode by DES

I don't understand how to use the Initial Vector into the DES. I have read how the formula of the Initial Vector with CBC mode Block cipher mode of operation. How to implement my plaintext into the formula. Can i have exemplified plaintext =…
user3425817
  • 27
  • 1
  • 4
0
votes
2 answers

How to write new line characters into a file in Java after converting a Byte Array into a String

I want to read a text file, convert it into a byte array, process the byte array and then write it into another file. To do so I don't want to lose any newline characters so that new lines shall also be written into the new file created in the…
DecodingLife
  • 73
  • 1
  • 3
  • 11
0
votes
1 answer

I use CBC_CTS_Mode_ExternalCipher and get garbled output

Ok I hate doing this but I am getting frustrated because there is little to no documentation on the CBC_CTS_Mode_ExternalCipher . I have a partially known key for AES128. I built a function to generate all possible combinations and permutations of…
Craig
  • 173
  • 4
  • 15
0
votes
1 answer

Java CBC decrypting works, but CTR is failing

I setup a program for a class I am taking on crypto. I will follow this with my code and another section for my variable differences. My goal is to decrypt the text for our homework. I do not want someone to decrypt this for me, but would like some…
SirGed
  • 3
  • 3
0
votes
2 answers

Print of unsigned char different each time

So I'm trying to use cbc_crypt to try encrypting and decrypting different strings. Here is my program so far. int main(int argc, char *argv[]) { unsigned char key[8] = {0x00, 0x00, 0x00, 0x68, 0x67, 0x01, 0x75, 0x19}; unsigned char iv[8] =…
user244145
  • 73
  • 1
  • 11
0
votes
0 answers

Objective-c AES CBC decryption with IV

I have been struggling with this problem for several days now and i can't seem to figure it out I tried using CCCrypt to decrypt an encrypted string, I have the encrypted string encoded with Base64 encode, I have the key and the iv. The encryption…
shay
  • 31
  • 5
0
votes
1 answer

Different output encryption both CryptoJS and Java Code

I need to encrypt certainly string from client-side (JavaScript) and decrypt from server-side (Java), so I found CryptoJS and I write the code with the same params/configuration of mi Java Code but the output is always different, do you have any…
SoldierCorp
  • 7,610
  • 16
  • 60
  • 100
0
votes
1 answer

Encrypt AES in C++(OpenSSL), decrypt in C#

I have a system consists of two parts - c++ and c# application. This parts have a shared file which both could read and write. To defend my file from regular user I use AES encryption. C++ application use openSSL ctypto library AES implementation…
vard
  • 2,142
  • 4
  • 30
  • 40
0
votes
1 answer

CBC with AES : Encrypting in Perl and Decrypting in Java

I am encrypting a file in perl and want to decrypt in java. here is my encryption code: == Encryption in Perl == $key = "1234567890123456"; $plain_text = "this is foo"; open ($fh, ">" . $output_file_path) || die ("open ($output_file_path):$!"); my…
nigam214
  • 301
  • 2
  • 7