prosyslab-classroom / cs348-information-security

61 stars 10 forks source link

[Question][Hw2] #256

Closed seeifsalem closed 1 year ago

seeifsalem commented 1 year ago

Name: Mohamed Seifeddine Salem

Hello, I am having a hard time debugging the CBC encryption because this is what I stumble upon image is there any way to obtain the actual characters instead of these ���� ?

KAIST-JongchanPark commented 1 year ago

Why don't you make a your own printer function and use it during encryption?

seeifsalem commented 1 year ago

Why don't you make a your own printer function and use it during encryption?

But how would I know what is the expected result ?

KAIST-JongchanPark commented 1 year ago

You can use an external tool like xxd

seeifsalem commented 1 year ago

I don't understand how it would make sense for me to have the same two last characters ("wu") but having a mistake in the middle. We are using CBC so the encryption depends on the previously encoded block. If any of my encoded blocks was wrong, then the last encoded blocks can't be correct.

KAIST-JongchanPark commented 1 year ago

You may catch the concept of enc/dec, but your implementation might have a bug. Please debug your code carefully.

leejy12 commented 1 year ago

@seeifsalem Have you checked if the expected file and your output have the same size?

seeifsalem commented 1 year ago

@seeifsalem Have you checked if the expected file and your output have the same size?

how would I check that ? I mean it seems to me that they have the same number of characters

leejy12 commented 1 year ago

Redirect your output from encrypting to another file like this:

./aes enc test/key.txt test/iv.txt test/helloworld.txt > test/helloworld.output

and compare the file sizes of helloworld.expected and helloworld.output.

Or, you can just use wc:

./aes enc test/key.txt test/iv.txt test/helloworld.txt | wc -c

This will count the number of characters. The expected value is 13 for helloworld.

seeifsalem commented 1 year ago

Redirect your output from encrypting to another file like this:

./aes enc test/key.txt test/iv.txt test/helloworld.txt > test/helloworld.output

and compare the file sizes of helloworld.expected and helloworld.output.

Or, you can just use wc:

./aes enc test/key.txt test/iv.txt test/helloworld.txt | wc -c

This will count the number of characters. The expected value is 13 for helloworld.

I just checked, I have the same number of characters but I think I solved my problem.