Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Download the following reference files to answer the questions: • blowfish.h ( h

ID: 3716135 • Letter: D

Question

Download the following reference files to answer the questions:

• blowfish.h ( https://cis.temple.edu/%7Ejfiore/2016/fall/2107/assignments/05/GDB_part/files/blowfish.h )

• blowfish.c ( https://cis.temple.edu/%7Ejfiore/2016/fall/2107/assignments/05/GDB_part/files/blowfish.c )
• GDBassign.c ( https://cis.temple.edu/%7Ejfiore/2016/fall/2107/assignments/05/GDB_part/files/GDBassign.c )

Remember that to compile and link several separate files at the command line using gcc, you'd list all of the .c files on the same line. For example, if we were to compile these files without including the debugging information, we'd type:

Questions

What is the command to compile the files with extra symbols that are useful for GDB?

What's the address of stuff?

What's the address of stuff[0]?

Do we expect these to be the same? Why? Explain what the [ ] operator does in C.

In Blowfish_Init( ), what is the value of key?

What command(s) did you type in order to learn this?

In Blowfish_Init( ), what are the values of i and j after the nested for loops have finished?

i.e., after:

What command(s) did you type in order to learn this?

Before the Blowfish_Encrypt function is called, what is the value of stuff[3] (for each, print the value, and the command used to obtain the value):

o in hex?
o in binary? o as a float? o as 4 chars?

Before the Blowfish_Encrypt function is called, what is the value of stuff if we treat it as a string? (You don't have to write the whole string. Just describe what's there.) What was the command typed in order to obtain this value?

What is the value of x the first time that the function F() in Blowfish.c is called?

What is the output if we run GDB's backtrace (abbreviated "bt") command inside the function F() in Blowfish.c the first time F() is called? Briefly explain the output of the command in your own words.

Explanation / Answer

As per rules we should asnwer only 1 question, anyways i am helping you out with few answers.

Ans 1:

-g or -g[leve] where 1 <= level <= 3 example gcc -g3

Ans 2:

print &stuff
$2 = (uint32_t (*)[720]) 0x7fffffffd350

Ans 3:

p &stuff[0]
$3 = (uint32_t *) 0x7fffffffd350

Ans 4:

yes both should be same, as &stuff[0] is same as (stuff + 0)

[] oprator adds subscript to base address of array and then get value on resulting address

ie. arr[2] = *(arr+2)

Ans 5:

value is a address which stored a character string (null terminated) =

(unsigned char *) 0x400be0 "LAME_KEY"

Ans 6:

gcc -g3 -c blowfish.c -o blowfish.o

gcc -g3 GDBassign.c blowfish.o

gdb commands -> break Blowfish_Init, run, bt, print key, p &stuff, p &stuff[0], next, continue

Ans 7:

i =4, j = 256  

loop finished execution once it failed comparision condition i < 4 and j < 256

Ans 8 :

break Blowfish_Init        -- put a brekpoint on function

run     --run program in debug mode

break 722   -- break on line 722 in current file

continue   -- continue execution

print i     --print value of i

print j -- print vaue of j

Ans9:

p stuff[3]
$1 = 543516788 -- decimal

(gdb) p /o stuff[3]
$4 = 04031264164 -- octal
(gdb) p /x stuff[3]
$5 = 0x20656874 --hexadecimal
(gdb) p /t stuff[3]
$6 = 100000011001010110100001110100   --binary

(gdb) p (float) stuff[3]
$8 = 543516736       --float

as 4 characters

(gdb) p *((char *)&stuff[3]+0)
$25 = 116 't'
(gdb) p *((char *)&stuff[3]+1)
$26 = 104 'h'
(gdb) p *((char *)&stuff[3]+2)
$27 = 101 'e'
(gdb) p *((char *)&stuff[3]+3)
$28 = 32 ' '
(gdb)

ans 10:

only printing til first 100 char

(gdb) p *((char*)&stuff[3])@100
$32 = "the people in your neighborhood? In your neighborhood? In your neighborhood? Say, who are the pe"

Ans 11:

p x
$1 = 1753098189

Ans 12:

(gdb) bt
#0 F (ctx=0x7fffffffb7c0, x=1753098189) at blowfish.c:550
#1 0x00000000004007b4 in Blowfish_Encrypt (ctx=0x7fffffffb7c0, xl=0x7fffffffb79c, xr=0x7fffffffb798) at blowfish.c:602
#2 0x00000000004009e0 in Blowfish_Init (ctx=0x7fffffffb7c0, key=0x400be0 "LAME_KEY", keyLen=8) at blowfish.c:754
#3 0x00000000004005f6 in main () at GDBassign.c:383

backtrace command show the call stack information top of stack is marked with #0 and the n#1 and so on last stack frame is #n for main.

so here we can see main called Blowfishn_init which called Blowfish_encrypy which called F().

in bt we can alo see arguments passed to each function passed from caller in stack frame below the callee function.

so main is caller for callee function Blowfish_init .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote