Hello,
this situation is easy to reproduce, let's assume you setup proto = PROTOCOL_SSL only connection without providing pass (also proto = PROTOCOL_HYBRID disabled therefore pass can be typed in the session)
In such case packets are sent via established SSL connection without RDP packet encryption and therefore the g_client_random is not created, and when processing reconnection cookie after reconnection it seems rdssl_hmac_md5 function produces wrong sum and auto reconnection fails.
I assume, same would happen with proto = PROTOCOL_HYBRID, but because on my cygwin I was unable to compile with cssp support, can not say to much here, but expect to 99.9% same behaviour, because password gets emptied after succeed logon and can not be reused for auto reconnection.
Got what was wrong, had to fill it with zeros 32 bytes long. Just took a look into frerdp and possibly there is some bug, they create it with 16 bytes length (not 32 as I did to make it working because 16bytes failed) filled with zeros when protocol == rdp, not ssl and not nla.
But in my assumption, that is security risk to fill clients random key with zeros, than it is not random.
Pretty sure we should extract exponent and modulus from public key and encrypt own random key. I assume, Microsoft RDP server always uses RSA keys.
https://msdn.microsoft.com/en-us/library/cc240810.aspx
Well, will continue the tests...