Author |
Message |
satfreak666
Joined: 16 May 2011 Posts: 11
|
|
|
|
Hmm ... I have coded the encoder-routine in Java. I can brute-force this message, but not the challange Message... am I missing something?
 |
 |
package challanges;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
public class EggWarmUpPre
{
public static void main(String[] args) throws UnsupportedEncodingException
{
byte[] key = new byte[]
{ 0x11, 0x12, 0x13, 0x14 };
EggWarmUpPre eggWarmUpPre = new EggWarmUpPre();
byte[] encoded = eggWarmUpPre.encode("This is a secret message".getBytes("ASCII"), key);
byte[] encodedLeadingZero = new byte[encoded.length + 1];
System.arraycopy(encoded, 0, encodedLeadingZero, 1, encoded.length);
System.out.println("Encoded : " + new BigInteger(encodedLeadingZero).toString(16));
}
private byte[] encode(byte[] b, byte[] key)
{
int SCR_WIDTH = 24;
int SCR_LOOPS = 3;
byte[] result = new byte[b.length];
for (int j = 0; j < b.length; j += 3)
{
int i, roll = 7;
int eggs = 0;
eggs = (b[j] & 0xff) + ((b[j + 1] & 0xff) << 8) + ((b[j + 2] & 0xff) << 16);
for (i = 0; i < SCR_LOOPS; i++)
{
eggs ^= ((key[eggs & 0x3] & 0xff) << 8);
eggs = (eggs << roll) | (eggs >> (SCR_WIDTH - roll));
eggs &= ((1 << SCR_WIDTH) - 1);
}
System.out.println("encoding tupel to : " + Integer.toHexString(eggs));
result[j] = (byte) ((eggs >> 16) & 0xff);
result[j + 1] = (byte) ((eggs >> 8) & 0xff);
result[j + 2] = (byte) (eggs & 0xff);
}
return result;
}
}
|
Actually the Integer is being displaed in Big-Endian (human readable) Order. Otherwise you have to revert every 3rd Byte with evry 1st byte of a 3byte tupel.
The Output of the code is :
 |
 |
encoding tupel to : c4af2e
encoding tupel to : 24268a
encoding tupel to : 25268a
encoding tupel to : c42c40
encoding tupel to : a5acc8
encoding tupel to : 45262a
encoding tupel to : 26ec28
encoding tupel to : e5aea8
Encoded : c4af2e24268a25268ac42c40a5acc845262a26ec28e5aea8
|
|
|
Thu May 19, 2011 12:31 pm |
|
 |
Tron
Joined: 22 Oct 2010 Posts: 30
|
|
|
|
Your text "This is a secret message" encoded with the key 11121314 and 3 rounds yields the cipher text: E30F49A6E649A6E648EC8C2824EC08660649A5ACEAE52EA8
It seems, that you are forming the eggs the wrong way round, i.e. first << 0, second << 8, third << 16, it should be first << 16, second << 8, third << 0.
|
|
Thu May 19, 2011 12:58 pm |
|
 |
whei
Joined: 04 Jul 2011 Posts: 1
|
|
|
|
>> with the key 11121314 ...
so you mean key[0] == 0x11, key[1] == 0x12, ...
or is it the other way so you mean key[0] == 0x14, key[1] == 0x13, ... ???
|
|
Sat Jul 16, 2011 6:47 am |
|
 |
AgRaven
Joined: 24 Feb 2013 Posts: 13
|
|
|
|
Oh man, this one is kicking my ass... I've loved the crypto challenges on this branch so far, no problems there, but I just can't figure out a sensible way to solve for the key without silly brute force (I'd love to understand rather than do that). Are any solvers still around who I can PM with my understanding and a question or two? Adum? I don't want to post my code/thoughts here; I think I'm somewhat close.
EDIT:
Cancel that, got it. 
|
|
Sat Aug 03, 2013 4:16 pm |
|
 |
one.kamila
Joined: 04 May 2018 Posts: 11
|
|
|
|
Alright, admittedly, I'm very new to computer science and programming as a whole (I would say that I'm somewhat competent in only three languages, but not 100% fluent in all three). With that said, could someone please tell me what language the algorithm given to us in the prompt is written in? Or at least explain to me what this line (below) means:
 |
 |
(key[eggs&0x3]<<8) |
If I can figure out what that line means, or which language this is algorithm is written in, I know that I will be able to translate it into the few languages I know.
Any and all help is greatly appreciated! (And yes, I know that I should learn more languages. I am trying to, but life is very good at keeping people busy.)
EDIT: After doing some research, I was able to figure out what the specific line means. (Side note: looks like the code given is written in a language that I know, so I won't need to translate )
|
|
Mon Jun 04, 2018 5:37 pm |
|
 |
one.kamila
Joined: 04 May 2018 Posts: 11
|
|
|
|
Ok, I have two new questions, regarding two different lines of code.
1.
 |
 |
key = {unknown four-byte value} |
So, just to make sure that I'm understanding this correctly, key is an array containing four different bytes, correct? (i.e. key = {a4, 91, f0, b6})
2.
 |
 |
for (int eggs = {each 3-byte tuple in plaintext}) |
I have two separate questions regarding this one.
1. Is the 3-byte tuple a string of three characters? (for example, would eggs = {38, 2d, 81})
2. Assuming that the above question is correct, do I need to convert each byte into an integer, or all three bytes into an integer?
I'm probably over thinking this, but I just want to make sure that I'm understanding this correctly.[/list]
|
|
Fri Jun 22, 2018 3:25 pm |
|
 |
eulerscheZahl
Joined: 29 Nov 2012 Posts: 56 Location: Germany |
|
|
|
1. Not necessarily distinct, but in this case they are.
2.1 yes
2.2 keep the 3 bytes as an integer or you break the shifting logic. Your first egg is 3681665 in decimal
|
|
Sat Jun 23, 2018 3:59 am |
|
 |
one.kamila
Joined: 04 May 2018 Posts: 11
|
|
|
|
Perfect. Exactly what I needed. A response with (relatively*) specific answers, and even a slight example. THANK YOU!
*relative as in if you know what you were looking for
|
|
Sun Jun 24, 2018 6:07 am |
|
 |
one.kamila
Joined: 04 May 2018 Posts: 11
|
|
|
|
Reading through this discussion board has confused me as to the nature of this line:
 |
 |
for (int eggs = {each 3-byte tuple in plaintext}) |
Do I need to convert the entire tuple into one hex string, and then convert that hex string into an integer?
(i.e. if the tuple was: (0x38, 0x2d, 0x81), would eggs = int("382d81", 16)?)
|
|
Mon Sep 30, 2019 4:33 pm |
|
 |
eulerscheZahl
Joined: 29 Nov 2012 Posts: 56 Location: Germany |
|
|
|
Yes, that's what is meant with the tuples.
|
|
Mon Sep 30, 2019 4:52 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|