]> andersk Git - openssh.git/blame - mpaux.c
- Big OpenBSD CVS update (mainly beginnings of SSH2 infrastructure)
[openssh.git] / mpaux.c
CommitLineData
8efc0c15 1/*
5260325f 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 *
8efc0c15 15*/
16
17#include "includes.h"
18RCSID("$Id$");
19
5260325f 20#include "getput.h"
21#include "xmalloc.h"
22
5881cd60 23#ifdef HAVE_OPENSSL
8efc0c15 24#include <openssl/bn.h>
5881cd60 25#include <openssl/md5.h>
26#endif
27#ifdef HAVE_SSL
28#include <ssl/bn.h>
29#include <ssl/md5.h>
30#endif
31
8efc0c15 32void
33compute_session_id(unsigned char session_id[16],
7368a6c8 34 unsigned char cookie[8],
35 BIGNUM* host_key_n,
36 BIGNUM* session_key_n)
8efc0c15 37{
95f1eccc 38 unsigned int host_key_bytes = BN_num_bytes(host_key_n);
39 unsigned int session_key_bytes = BN_num_bytes(session_key_n);
40 unsigned int bytes = host_key_bytes + session_key_bytes;
5260325f 41 unsigned char *buf = xmalloc(bytes);
42 MD5_CTX md;
43
44 BN_bn2bin(host_key_n, buf);
95f1eccc 45 BN_bn2bin(session_key_n, buf + host_key_bytes);
5260325f 46 MD5_Init(&md);
47 MD5_Update(&md, buf, bytes);
95f1eccc 48 MD5_Update(&md, cookie, 8);
5260325f 49 MD5_Final(session_id, &md);
50 memset(buf, 0, bytes);
51 xfree(buf);
8efc0c15 52}
This page took 0.106073 seconds and 5 git commands to generate.