// File: luigix25[P]SSLP/client_files/client.cpp
// Function: cmd_get()
bool cmd_get(){

	//if(!server_socket.sendInt(GET_COMMAND)) return;
	if(!send_command(GET_COMMAND)) return false;
	string filename;
	cin >> setw(MAX_FILENAME_LENGTH) >> filename;

	//clears the overflow, if any
	pulisci_buff();

	string path(CLIENT_PATH);

	EncryptManager em;
	Chunk c;
	c.setPlainText((char*)filename.c_str(),false);		//i don't need to free memory
	c.size = filename.size()+1;

	EncryptedChunk ec;

	if(!em.EncryptUpdate(ec,c)) return false;
	if(!em.EncryptFinal(ec))	return false;


	if(!sendDataHMAC(server_socket,ec.getCipherText(),ec.size)) return false;			
	if(!ReceiveFile(path,filename,server_socket,public_key_rsa,true)){
		//cout << "[Error] ReceiveFile" << endl;
		return false;
	}
	else{
		//cout << "[LOG] ReceiveFile Correct" << endl;
		return true;
	}
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl $0x2, %edi
callq 0x5290
testb $0x1, %al
jne 0x5df2
movb $0x0, -0x1(%rbp)
jmp 0x60c1
leaq -0x28(%rbp), %rdi
callq 0x4780
movl $0x64, %edi
callq 0x7830
movl %eax, -0xa8(%rbp)
jmp 0x5e0d
movl -0xa8(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
movq 0xd1b0(%rip), %rdi      # 0x12fd0
callq 0x44d0
movq %rax, -0xb0(%rbp)
jmp 0x5e2e
movq -0xb0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x46b0
jmp 0x5e40
callq 0x50b0
jmp 0x5e47
leaq -0x61(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x4910
movq -0xb8(%rbp), %rdx
leaq 0x831e(%rip), %rsi      # 0xe183
leaq -0x60(%rbp), %rdi
callq 0x76e0
jmp 0x5e70
leaq -0x61(%rbp), %rdi
callq 0x4530
leaq -0x70(%rbp), %rdi
callq 0xa300
jmp 0x5e84
leaq -0x88(%rbp), %rdi
callq 0xd6b0
jmp 0x5e92
leaq -0x28(%rbp), %rdi
callq 0x41e0
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
xorl %edx, %edx
callq 0xd7a0
jmp 0x5eae
leaq -0x28(%rbp), %rdi
callq 0x4350
incl %eax
movl %eax, -0x78(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xd860
jmp 0x5eca
leaq -0x70(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0xa490
movb %al, -0xb9(%rbp)
jmp 0x5ee9
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x5f87
jmp 0x5ef9
movb $0x0, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x6063
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x60b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x4530
jmp 0x60b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x60ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x60a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6098
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xd880
jmp 0x6098
leaq -0x70(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xa550
movb %al, -0xba(%rbp)
jmp 0x5f9f
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0x5fbe
jmp 0x5fab
movb $0x0, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x6063
leaq -0xa0(%rbp), %rdi
callq 0xd970
movq %rax, -0xc8(%rbp)
jmp 0x5fd3
movq -0xc8(%rbp), %rsi
movl -0x90(%rbp), %edx
leaq 0xd639(%rip), %rdi      # 0x13620
callq 0x87a0
movb %al, -0xc9(%rbp)
jmp 0x5ff4
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x6010
jmp 0x6000
movb $0x0, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x6063
leaq 0xd609(%rip), %rdx      # 0x13620
leaq 0xd5fa(%rip), %rcx      # 0x13618
leaq -0x60(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x1, %r8d
callq 0xbc50
movb %al, -0xca(%rbp)
jmp 0x6039
movb -0xca(%rbp), %al
testb $0x1, %al
jne 0x6055
jmp 0x6045
movb $0x0, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x6063
movb $0x1, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xd880
leaq -0x88(%rbp), %rdi
callq 0xd6d0
leaq -0x70(%rbp), %rdi
callq 0xa3d0
leaq -0x60(%rbp), %rdi
callq 0x42b0
leaq -0x28(%rbp), %rdi
callq 0x42b0
jmp 0x60c1
leaq -0x88(%rbp), %rdi
callq 0xd6d0
leaq -0x70(%rbp), %rdi
callq 0xa3d0
leaq -0x60(%rbp), %rdi
callq 0x42b0
leaq -0x28(%rbp), %rdi
callq 0x42b0
jmp 0x60cf
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x4900
nopl (%rax,%rax)