Annotation of src/usr.bin/ssh/mpaux.c, Revision 1.2
1.1 deraadt 1: /*
2:
3: mpaux.c
4:
5: Author: Tatu Ylonen <ylo@cs.hut.fi>
6:
7: Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8: All rights reserved
9:
10: Created: Sun Jul 16 04:29:30 1995 ylo
11:
12: This file contains various auxiliary functions related to multiple
13: precision integers.
14:
15: */
16:
17: #include "includes.h"
18: RCSID("$Id: mpaux.c,v 1.3 1999/05/04 11:58:51 bg Exp $");
19:
1.2 ! provos 20: #include <ssl/bn.h>
1.1 deraadt 21: #include "getput.h"
22: #include "xmalloc.h"
23: #include "ssh_md5.h"
24:
1.2 ! provos 25: void
! 26: compute_session_id(unsigned char session_id[16],
! 27: unsigned char cookie[8],
! 28: unsigned int host_key_bits,
! 29: BIGNUM *host_key_n,
! 30: unsigned int session_key_bits,
! 31: BIGNUM *session_key_n)
1.1 deraadt 32: {
33: unsigned int bytes = (host_key_bits + 7) / 8 + (session_key_bits + 7) / 8 + 8;
34: unsigned char *buf = xmalloc(bytes);
35: struct MD5Context md;
36:
1.2 ! provos 37: BN_bn2bin(host_key_n, buf);
! 38: BN_bn2bin(session_key_n, buf + (host_key_bits + 7 ) / 8);
1.1 deraadt 39: memcpy(buf + (host_key_bits + 7) / 8 + (session_key_bits + 7) / 8,
40: cookie, 8);
41: MD5Init(&md);
42: MD5Update(&md, buf, bytes);
43: MD5Final(session_id, &md);
44: xfree(buf);
45: }