// File: luigix25[P]SSLP/server_files/server.cpp
// Function: cmd_upload()
bool cmd_upload(){
	int len;

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


	EncryptedChunk ec;
	ec.setCipherText(encryted_data);				//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());

	string path(SERVER_PATH);
	if(!ReceiveFile(path,filename,client_socket,public_key_rsa,false)){
		cout << "[ERROR]" << endl;
		return false;
	}

	return true;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
leaq 0xdc1e(%rip), %rdi      # 0x14650
leaq -0x8(%rbp), %rsi
callq 0x9c30
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x6a4f
movb $0x0, -0x1(%rbp)
jmp 0x6cd7
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xebf0
movq -0xb8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xecc0
jmp 0x6a71
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xea40
jmp 0x6a82
leaq -0x58(%rbp), %rdi
callq 0xb990
jmp 0x6a8d
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0xba90
movb %al, -0xb9(%rbp)
jmp 0x6aa6
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x6af5
jmp 0x6ab2
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x6c9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x6ccc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x6cc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x6cba
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xbc50
movb %al, -0xba(%rbp)
jmp 0x6b0a
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0x6b26
jmp 0x6b16
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x6c9d
leaq -0x50(%rbp), %rdi
callq 0xeb70
movq %rax, -0xc8(%rbp)
jmp 0x6b38
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 0x6b64
leaq -0x81(%rbp), %rdi
callq 0x5580
leaq -0xa9(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x5990
movq -0xd8(%rbp), %rdx
leaq 0x8494(%rip), %rsi      # 0xf025
leaq -0xa8(%rbp), %rdi
callq 0x8820
jmp 0x6b9f
leaq -0xa9(%rbp), %rdi
callq 0x5580
leaq 0xda9e(%rip), %rdx      # 0x14650
leaq 0xdaa7(%rip), %rcx      # 0x14660
leaq -0xa8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
xorl %r8d, %r8d
callq 0xcfe0
movb %al, -0xd9(%rbp)
jmp 0x6bd4
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x6c70
jmp 0x6be4
movq 0xd3dd(%rip), %rdi      # 0x13fc8
leaq 0x84aa(%rip), %rsi      # 0xf09c
callq 0x5500
movq %rax, -0xe8(%rbp)
jmp 0x6c00
movq -0xe8(%rbp), %rdi
movq 0xd3aa(%rip), %rsi      # 0x13fb8
callq 0x5550
jmp 0x6c15
movb $0x0, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x6c7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x5580
jmp 0x6cba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x5580
jmp 0x6c92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5330
jmp 0x6c92
movb $0x1, -0x1(%rbp)
movl $0x1, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5330
leaq -0x80(%rbp), %rdi
callq 0x5330
jmp 0x6c9d
leaq -0x80(%rbp), %rdi
callq 0x5330
jmp 0x6cba
leaq -0x58(%rbp), %rdi
callq 0xba60
leaq -0x50(%rbp), %rdi
callq 0xea60
leaq -0x28(%rbp), %rdi
callq 0xec10
jmp 0x6cd7
leaq -0x58(%rbp), %rdi
callq 0xba60
leaq -0x50(%rbp), %rdi
callq 0xea60
leaq -0x28(%rbp), %rdi
callq 0xec10
jmp 0x6ce5
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xf0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5980
nop