-1

I was wondering, is it possible to extend the cipher byte length when block size 64bits (8byte) in DES?

Its like this, When the input Blocksize is <=64bits the cypher size is 128bits for sure because of the PaddingMode.PKCS7 in DES. The below code is an example of what I'm saying.

   static void Main(string[] args)
    {
            Console.WriteLine("Original String: ");
            string originalString = Console.ReadLine();
            string cryptedString = Encrypt(originalString);
            Console.WriteLine("Encrypt Result: " +cryptedString);
    }

    public static string Encrypt(string originalString)
    {

        const string AesIV = "!QAZ2WSX";
        const string AesKey = "5TGB&YHN";
        byte[] input_text = Encoding.UTF8.GetBytes(originalString);


        DESCryptoServiceProvider des = new DESCryptoServiceProvider();
        des.BlockSize = 64;
        des.IV = Encoding.UTF8.GetBytes(AesIV);
        des.Key = Encoding.UTF8.GetBytes(AesKey);
        des.Mode = CipherMode.CBC;
        des.Padding = PaddingMode.PKCS7;


        ICryptoTransform des_demo = des.CreateEncryptor();
        byte[] encrypted = des_demo.TransformFinalBlock(input_text , 0, input_text.Length );
        string encrypt = Convert.ToBase64String(encrypted );
        return encrypt;
    }

But I want to have cyphersize more than 128bits (specially 192bits) from same input Blocksize which is <=64bits from this code. How I can I do that? Is there any way to fix up the output cipher size to 24bytes?

Luanne
  • 19,145
  • 1
  • 39
  • 51
Giliweed
  • 4,997
  • 8
  • 26
  • 35
  • this problem is solved. Please no more answers . – Giliweed Jul 14 '14 at 01:57
  • That's not for you to decide, Giliweed. The idea of this *forum* is that everybody can use and learn from the Q/A. Additional answers may be given at any time. And answers and questions may even be modified. – Maarten Bodewes Jul 14 '14 at 07:45
  • You are mistaken if you think that Unicode - or any other encoding for that matter - has anything to do with the output of a cipher. The input, output, key (and other possible parameters such as the IV) are always defined as bits. Usually they are of course implemented as octets (commonly referred to as bytes). The paper you were reading was incorrect in that sense; it referred to input/output as characters. It's one of their many mistakes. This is often due to the fact that the C/C++ (based) languages refers to a byte as `char`. Both Java and C# use a correct separation between the two though – Maarten Bodewes Jul 14 '14 at 07:54

1 Answers1

-2

This problem can be solved very easily. Just change the UTF8 to Unicode. Now, each input data characters will be 2byte each instead of 1byte. So, 8byte (64bits) input will be 16byte (128bits) and when PKCS#7 is used in 16byte data it becomes 24byte (192bits). This is the way to get 192bit cipher from 64bit input.

Giliweed
  • 4,997
  • 8
  • 26
  • 35