// File: DiplIngFrankGerlach[P]MST/./Protocol.h
// Function: MST_Hash::createAuthPlaintext(unsigned char*, unsigned int, unsigned char**, unsigned int*)
bool createAuthPlaintext(uint8_t* sourcePlaintext,//the plaintext
                            uint32_t length,         //length of plaintext
                            uint8_t** outputBuffer,  //typically a reference to a pointer
                            uint32_t* outputSize)    //typically a reference to a uint32_t 
   {
        if( (length == 0) || (length > (UINT_MAX-32) ) )
        {
          return false;
        }
        if( _outputBufferSize < (length+32) )
        {
           memset(_outputBuffer,0,_outputBufferSize);
           delete[] _outputBuffer;
           
           _outputBufferSize = length + 4 + 32;
           _outputBuffer = new uint8_t[_outputBufferSize];
           if( _outputBuffer == NULL )
           {
              return false;
           }
        }
        Util::int2Octets(length,_outputBuffer);
        memcpy(_outputBuffer+4,sourcePlaintext,length);
        uint32_t pos;
        for( pos = length+4; (pos & 0xF) != 0; pos++)
        {
           _outputBuffer[pos]=0;
        }
         
        if( DM_Hash::hash(_outputBuffer,pos,_outputBuffer+pos) == false)
        {
           return false;
        }
        *outputBuffer = _outputBuffer;
        *outputSize = pos + 16;
        return true;
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x5adf
cmpl $-0x21, -0x1c(%rbp)
jbe 0x5ae8
movb $0x0, -0x1(%rbp)
jmp 0x5bf6
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x1c(%rbp), %ecx
addl $0x20, %ecx
cmpl %ecx, %eax
jae 0x5b5b
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x20c0
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x5b26
movq -0x48(%rbp), %rdi
callq 0x2220
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x4, %ecx
addl $0x20, %ecx
movl %ecx, 0x8(%rax)
movl 0x8(%rax), %eax
movl %eax, %edi
callq 0x2030
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, (%rax)
jne 0x5b59
movb $0x0, -0x1(%rbp)
jmp 0x5bf6
jmp 0x5b5b
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %edi
movq (%rax), %rsi
callq 0x5d90
movq -0x40(%rbp), %rax
movq (%rax), %rdi
addq $0x4, %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0x2130
movl -0x1c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x5bb0
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5b8c
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %esi
movq (%rax), %rdx
movl -0x34(%rbp), %eax
addq %rax, %rdx
callq 0x58f0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5bd8
movb $0x0, -0x1(%rbp)
jmp 0x5bf6
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x34(%rbp), %ecx
addl $0x10, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)