// File: luigix25[P]SSLP/library/library.cpp
// Function: recvDataHMAC(NetSocket&, int&)
char* recvDataHMAC(NetSocket& receiver_socket,int32_t &length){

	if(!recvIntHMAC(receiver_socket,length))
		return false;

	length -= HASH_SIZE;

	char *data = receiver_socket.recvData(length);

	HMACManager hmac;
	if(!hmac.HMACUpdate(data,length)) return NULL;

	char *digest = hmac.HMACFinal(REMOTE_NONCE);

	if(digest == NULL) return NULL;

	char *received_digest = receiver_socket.recvData(HASH_SIZE);

	if(received_digest == NULL){
		delete[] digest;
		return NULL;
	}

	if(CRYPTO_memcmp(received_digest,digest,HASH_SIZE)){
		cout<<"HASH DIVERSI"<<endl;
		delete[] digest;
		delete[] received_digest;
		return NULL;
	}

	delete[] digest;
	delete[] received_digest;
	return data;


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x85b0
testb $0x1, %al
jne 0x88f1
movq $0x0, -0x8(%rbp)
jmp 0x8ad7
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $-0x20, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x8090
movq %rax, -0x20(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x58(%rbp)
callq 0xa900
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
callq 0xaa70
movb %al, -0x49(%rbp)
jmp 0x8934
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x896b
jmp 0x893d
movq $0x0, -0x8(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x8ace
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xabf0
jmp 0x8ae4
leaq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0xaac0
movq %rax, -0x60(%rbp)
jmp 0x897f
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x89a2
movq $0x0, -0x8(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x8ace
movq -0x10(%rbp), %rdi
movl $0x20, %esi
callq 0x8090
movq %rax, -0x68(%rbp)
jmp 0x89b6
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x89f0
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x89dc
movq -0x70(%rbp), %rdi
callq 0x46d0
movq $0x0, -0x8(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x8ace
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x4920
movl %eax, -0x74(%rbp)
jmp 0x8a07
movl -0x74(%rbp), %eax
cmpl $0x0, %eax
je 0x8a85
movq 0xa5a2(%rip), %rdi      # 0x12fb8
leaq 0x5a49(%rip), %rsi      # 0xe466
callq 0x44a0
movq %rax, -0x80(%rbp)
jmp 0x8a28
movq -0x80(%rbp), %rdi
movq 0xa575(%rip), %rsi      # 0x12fa8
callq 0x4500
jmp 0x8a3a
movq -0x40(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x8a57
movq -0x88(%rbp), %rdi
callq 0x46d0
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0x8a74
movq -0x90(%rbp), %rdi
callq 0x46d0
movq $0x0, -0x8(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x8ace
movq -0x40(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x8aa2
movq -0x98(%rbp), %rdi
callq 0x46d0
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x8abf
movq -0xa0(%rbp), %rdi
callq 0x46d0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xabf0
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x4900
nopl (%rax)