Menu
  • HOME
  • TAGS

Where is the IV in Triple DES?

java,encryption,3des,tripledes

You can get the IV from the cipher: ecipher.getIV(); The problem is that the IV is generated during init. Since you init in the constructor you would run into the problem of using the same IV for every encryption of different ciphertexts. It's always best to generate a new Cipher...

3des encrypting/decrypting of file java

java,encryption,3des

The usage byte[] fileByteArray = new byte[fileInputStream.available()]; is specifically warned against in the Javadoc: " It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream." Files should be processed a record or a buffer at...

C# and PHP encryption compatibility - 3DES ECB with PKCS7

c#,php,encryption,pkcs7,3des

PHP code: $key = "6702BC24DD0527E7"; $key = md5($key,TRUE); $key .= substr($key,0,8); The C# code is "ok" as it is. "ok" is a big word here. I would probably use SHA256 and trim it to 24 bytes: C#: SHA256Managed sha256 = new SHA256Managed(); keyArray = sha256.ComputeHash(UTF8Encoding.UTF8.GetBytes(key)); Array.Resize(ref keyArray, 24); //Always release...

ios 3DES encryption/decription CBC

ios,encryption,3des,cbc-mode

i Found my problem. It was the way i was reading the key. i created this method for converting hex string into NSData: + (NSData *)dataFromHexString: (NSString *) hex { const char *chars = [hex UTF8String]; int i = 0, len = hex.length; NSMutableData *data = [NSMutableData dataWithCapacity:len / 2];...

Having wired outputs while Rfc2898DeriveBytes implementation in TripleDES

c#,3des,pbkdf2

You're using the original (encryptor) tripledes instance, rather than the decryptor instance tripledes1 to decrypt.

Why my smart card accepts two different keys as its MAC key?

smartcard,javacard,3des,parity,globalplatform

You are only flipping the parity bit which is not used nor checked by the card (or software). Which means the outcome of ciphers is the same, yes.

iOS 3DES with ECB return half correct data

ios,swift,encryption,3des,tripledes

It is probably a different padding being used. DES has a block size of 8 byte. So the first block is 12345678 and the second block is 9. Since DES is a block cipher the plaintext must be padded to the next block size. The online tool probably uses zero...

Trying to port old encryption algorithm to C#

c#,vb6-migration,encryption-symmetric,3des

There's actually a very simple solution, although it's not at all obvious. You have a block of code which says "If this data isn't exactly a multiple of 8, pad it." However, this is changing the value you're encrypting, so you get a different result. Simply remove the whole if(streamToEncrypt.Length.Dump("Length")...

Java's 3DES encryption generates trash at the end of encrypted data

java,encryption,3des

The block size of DES is 64-bit or 8 bytes. When the plaintext size is a multiple of the plaintext the padding used will add another block of data to the plaintext filled with 0x08. This is how PKCS#5/PKCS#7 padding works. It seems that your HSM expects that no padding...

Encrypt using 3DES EDE / ECB / NOPadding

c#,php,encryption,3des

You could use token as a vector on TripleDESCryptoServiceProvider, together with the key. ICryptoTransform cTransform = tdes.CreateEncryptor(key, token); ...

3DES result in PHP produces different result from 3DES in Python

php,python,3des

PHP mcrypt doesn't handle PKCS5 padding, instead it uses simple zero padding. This is why you get different results compared to Python libs which use PKCS5 padding. Here a workaround to get PKCS5 padding in PHP: https://chrismckee.co.uk/handling-tripledes-ecb-pkcs5padding-php/ EDIT I confirm it works with this guy's lib: $key = '111111111111111111111111'; $x...