+ {
+ char realauthdata[64];
+ int realauthlen = 0;
+ int authstrlen = strlen(x11_authnames[pr->auth->realproto]);
+ unsigned long ip;
+ int port;
+ static const char zeroes[4] = { 0,0,0,0 };
+
+ if (pr->auth->realproto == X11_MIT) {
+ assert(pr->auth->reallen <= lenof(realauthdata));
+ realauthlen = pr->auth->reallen;
+ memcpy(realauthdata, pr->auth->realdata, realauthlen);
+ } else if (pr->auth->realproto == X11_XDM &&
+ pr->auth->reallen == 16 &&
+ sk_getxdmdata(s, &ip, &port)) {
+ time_t t;
+ realauthlen = 24;
+ memset(realauthdata, 0, 24);
+ memcpy(realauthdata, pr->auth->realdata, 8);
+ PUT_32BIT_MSB_FIRST(realauthdata+8, ip);
+ PUT_16BIT_MSB_FIRST(realauthdata+12, port);
+ t = time(NULL);
+ PUT_32BIT_MSB_FIRST(realauthdata+14, t);
+ des_encrypt_xdmauth(pr->auth->realdata+9,
+ (unsigned char *)realauthdata, 24);
+ }
+ /* implement other auth methods here if required */
+
+ PUT_16BIT(pr->firstpkt[0], pr->firstpkt + 6, authstrlen);
+ PUT_16BIT(pr->firstpkt[0], pr->firstpkt + 8, realauthlen);
+
+ sk_write(s, (char *)pr->firstpkt, 12);
+
+ if (authstrlen) {
+ sk_write(s, x11_authnames[pr->auth->realproto], authstrlen);
+ sk_write(s, zeroes, 3 & (-authstrlen));
+ }
+ if (realauthlen) {
+ sk_write(s, realauthdata, realauthlen);
+ sk_write(s, zeroes, 3 & (-realauthlen));
+ }
+ }