1

Given Values: Parameter which should be encrypted KEY to encrypt

Algorithm @>Net 1.1 C#:

  1. first converts original Parameter to bytesarry (using Unicode little-endian encoding) ->Byte_Expression
  2. Fillup Byte_Expression with padding chars (0): Fillfactor is 8 (fill up to 8Bytes) -> Byte_Expression8
  3. Now converts the KEY from String to Base64encoded ByteArray -> ByteKEY
  4. Crypted Byte_Expression8 with DES3:
  5. Ciphermode: ECB (Electronic Code Book)
  6. Padding: with Zeros
  7. DEFAULTINITIALVECTOR: = {0×00, 0×00, 0×00, 0×00, 0×00, 0×00, 0×00, 0×00}
  8. Key = ByteKEY (ref 3)
  9. DES3ecryptedByteArray
  10. Convert the DES3ecryptedByteArray with Base64Encryption to String -> Encrypted Parameter
  11. Finish

Have used above Alogorithm @Java7. In ECB Encryption mode it is throwing an error, however it is working fine with CBC mode.

Result : OUTPUT of .Net & Java not is snyc

Issue: java.security.InvalidAlgorithmParameterException: ECB mode cannot use IV

3
  • How about not passing an IV? ECB doesn't support IVs. Commented Feb 12, 2015 at 7:24
  • 1
    Please supply source code and a full stack trace next time. Step 3 doesn't make any sense to me. Commented Feb 12, 2015 at 7:45
  • Are you sure you are not decoding the key in step 3? Not that it matters for the answer, but encoding a key in base64 would not be secure. Commented Feb 12, 2015 at 7:52

1 Answer 1

2

ECB does not support an IV, so in Java the Cipher.init method with a third parameter should not be used. Some libraries allow inserting an IV value for ECB (notably PHP's mcrypt wrapper and apparently .NET) but in those cases the IV is simply ignored. Fortunately I haven't seen an implementation yet that uses the IV only for the first block during ECB encryption.

If CBC mode is used - ECB is not secure - then a zero IV means that the first block will be identical to ECB mode (direct AES encryption). This means that multiple encrypts with the same key are not secure either. CBC requires a random IV value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.