5 Author: Tatu Ylonen <ylo@cs.hut.fi>
7 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
10 Created: Sun Jul 16 04:29:30 1995 ylo
12 This file contains various auxiliary functions related to multiple
20 #include <openssl/bn.h>
24 #include <openssl/md5.h>
27 compute_session_id(unsigned char session_id[16],
28 unsigned char cookie[8],
29 unsigned int host_key_bits,
31 unsigned int session_key_bits,
32 BIGNUM *session_key_n)
34 unsigned int bytes = (host_key_bits + 7) / 8 + (session_key_bits + 7) / 8 + 8;
35 unsigned char *buf = xmalloc(bytes);
38 BN_bn2bin(host_key_n, buf);
39 BN_bn2bin(session_key_n, buf + (host_key_bits + 7 ) / 8);
40 memcpy(buf + (host_key_bits + 7) / 8 + (session_key_bits + 7) / 8,
43 MD5_Update(&md, buf, bytes);
44 MD5_Final(session_id, &md);