Results 1 to 3 of 3

Thread: Safer-K128

  1. #1



    I have the following C# code <<attached>>, the class SaferKn encrypts and decrypts blocks bytes, it is Safer-K128 with 10 rounds.

    if I do:
    byte[] array1_crypted;
    byte[] array1_decrypted;
    byte[] array1 = new byte[] { (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o' };

    SaferKn MyCipher = new SaferKn();
    array1_crypted = MyCipher.EncryptBlock(array1);
    array1_decrypted = MyCipher.DecryptBlock(array1_crypted);

    then I can see that "array1_decrypted == array1 == Hello" as expected,
    but if I use MyCipher.KeyScheduling(...) with my own userkey1 and userkey2
    before encrypt/decrypt then "array1_decrypted != array1" will be different!!!

    Sorry if I'm missing something basic here, but if the users keys are the same, why "array1_decrypted != array1", the userkey1 and userkey2 is not the same for encrypt and decrypt? If not how to retrieve decrypt user keys if I know the encrypt keys?

    thank u for your attention,
    Attached Files Attached Files
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  2. #2
    הבּרוּ נשׂאי כּלי יהוה mike's Avatar
    Join Date
    Mar 2001
    OK, the two user keys are there so you can have a 64-bit key or a 128-bit key. You're using 128-bit, so all 16 bytes should be generated randomly.

    The way it's supposed to work, you call KeySchedule once and then can encrypt & decrypt blocks to your heart's content. If that doesn't work, there may be an error in the code.
    has test vectors and the state in each round, so you can check your implementation.

  3. #3
    Yeah, thanks mike, I solved the problem, this code was ripped of from an app, I just used original code C code of safer and I got it to work.

    I promise that I have read the FAQ and tried to use the Search to answer my question.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts