2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * This file contains various auxiliary functions related to multiple
8 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this
10 * software must be clearly marked as such, and if the derived work is
11 * incompatible with the protocol description in the RFC file, it must be
12 * called by a name other than "ssh" or "Secure Shell".
16 RCSID("$OpenBSD: mpaux.c,v 1.15 2000/12/19 23:17:57 markus Exp $");
18 #include <openssl/bn.h>
22 #include <openssl/md5.h>
25 compute_session_id(u_char session_id[16],
28 BIGNUM* session_key_n)
30 u_int host_key_bytes = BN_num_bytes(host_key_n);
31 u_int session_key_bytes = BN_num_bytes(session_key_n);
32 u_int bytes = host_key_bytes + session_key_bytes;
33 u_char *buf = xmalloc(bytes);
36 BN_bn2bin(host_key_n, buf);
37 BN_bn2bin(session_key_n, buf + host_key_bytes);
39 MD5_Update(&md, buf, bytes);
40 MD5_Update(&md, cookie, 8);
41 MD5_Final(session_id, &md);
42 memset(buf, 0, bytes);