- key = alloca(2 * from->keylength + 1);
- bin2hex(from->key, key, from->keylength);
- key[from->keylength * 2] = '\0';
+ if(!to->inkey) {
+ to->incipher = myself->incipher;
+ to->inkeylength = myself->inkeylength;
+ to->indigest = myself->indigest;
+ to->incompression = myself->incompression;
+ to->inkey = xmalloc(to->inkeylength);
+
+ RAND_pseudo_bytes((unsigned char *)to->inkey, to->inkeylength);
+ if(to->incipher)
+ EVP_DecryptInit_ex(&packet_ctx, to->incipher, NULL, (unsigned char *)to->inkey, (unsigned char *)to->inkey + to->incipher->key_len);
+ }
+
+ key = alloca(2 * to->inkeylength + 1);
+ bin2hex(to->inkey, key, to->inkeylength);
+ key[to->outkeylength * 2] = '\0';