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

	int len;

	char *encryptedData = recvDataHMAC(client_socket,len);
	if(encryptedData == NULL)
		return false;

	EncryptedChunk ec;
	ec.setCipherText(encryptedData);				//now in charge of memory management
	ec.size = len;

	Chunk c;

	DecryptManager dm;
	if(!dm.DecryptUpdate(c,ec))			return false;
	if(!dm.DecryptFinal(c))				return false;

	string filename(c.getPlainText());

	if(filename.size() >= MAX_FILENAME_LENGTH){
		return false;
	}

	string path(SERVER_PATH);
	cout<<path<<endl;
	if(!SendFile(path,client_socket,filename,SERVER_PRIVKEY_PATH,false)){
		cout << "[ERROR] sendFile failed" << endl;
		return false;
	}
	else{
		cout << "[LOG] sendFile correct" << endl;
		return true;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
leaq 0xdf6e(%rip), %rdi      # 0x14650
leaq -0x8(%rbp), %rsi
callq 0x9c30
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x66ff
movb $0x0, -0x1(%rbp)
jmp 0x6a07
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xebf0
movq -0xb8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xecc0
jmp 0x6721
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xea40
jmp 0x6732
leaq -0x58(%rbp), %rdi
callq 0xb990
jmp 0x673d
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0xba90
movb %al, -0xb9(%rbp)
jmp 0x6756
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x67a5
jmp 0x6762
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x69cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x69fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x69f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x69ea
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xbc50
movb %al, -0xba(%rbp)
jmp 0x67ba
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0x67d6
jmp 0x67c6
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x69cd
leaq -0x50(%rbp), %rdi
callq 0xeb70
movq %rax, -0xc8(%rbp)
jmp 0x67e8
leaq -0x81(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x5990
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x8820
jmp 0x6814
leaq -0x81(%rbp), %rdi
callq 0x5580
leaq -0x80(%rbp), %rdi
callq 0x53c0
cmpq $0x64, %rax
jb 0x685c
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x69b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x5580
jmp 0x69ea
leaq -0xa9(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x5990
movq -0xd8(%rbp), %rdx
leaq 0x87a8(%rip), %rsi      # 0xf025
leaq -0xa8(%rbp), %rdi
callq 0x8820
jmp 0x688b
leaq -0xa9(%rbp), %rdi
callq 0x5580
movq 0xd72a(%rip), %rdi      # 0x13fc8
leaq -0xa8(%rbp), %rsi
callq 0x54d0
movq %rax, -0xe0(%rbp)
jmp 0x68b3
movq -0xe0(%rbp), %rdi
movq 0xd6f7(%rip), %rsi      # 0x13fb8
callq 0x5550
jmp 0x68c8
leaq 0xdd81(%rip), %rsi      # 0x14650
leaq 0x877f(%rip), %rcx      # 0xf055
leaq -0xa8(%rbp), %rdi
leaq -0x80(%rbp), %rdx
xorl %r8d, %r8d
callq 0xc7f0
movb %al, -0xe1(%rbp)
jmp 0x68f1
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x696f
jmp 0x68fd
movq 0xd6c4(%rip), %rdi      # 0x13fc8
leaq 0x8762(%rip), %rsi      # 0xf06d
callq 0x5500
movq %rax, -0xf0(%rbp)
jmp 0x6919
movq -0xf0(%rbp), %rdi
movq 0xd691(%rip), %rsi      # 0x13fb8
callq 0x5550
jmp 0x692e
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x69ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x5580
jmp 0x69c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5330
jmp 0x69c2
movq 0xd652(%rip), %rdi      # 0x13fc8
leaq 0x8708(%rip), %rsi      # 0xf085
callq 0x5500
movq %rax, -0xf8(%rbp)
jmp 0x698b
movq -0xf8(%rbp), %rdi
movq 0xd61f(%rip), %rsi      # 0x13fb8
callq 0x5550
jmp 0x69a0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5330
leaq -0x80(%rbp), %rdi
callq 0x5330
jmp 0x69cd
leaq -0x80(%rbp), %rdi
callq 0x5330
jmp 0x69ea
leaq -0x58(%rbp), %rdi
callq 0xba60
leaq -0x50(%rbp), %rdi
callq 0xea60
leaq -0x28(%rbp), %rdi
callq 0xec10
jmp 0x6a07
leaq -0x58(%rbp), %rdi
callq 0xba60
leaq -0x50(%rbp), %rdi
callq 0xea60
leaq -0x28(%rbp), %rdi
callq 0xec10
jmp 0x6a15
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5980
nop