]> andersk Git - openssh.git/blame - mpaux.c
- OpenBSD CVS Updates:
[openssh.git] / mpaux.c
CommitLineData
8efc0c15 1/*
6ae2364d 2 *
5260325f 3 * mpaux.c
6ae2364d 4 *
5260325f 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6ae2364d 6 *
5260325f 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
6ae2364d 9 *
5260325f 10 * Created: Sun Jul 16 04:29:30 1995 ylo
6ae2364d 11 *
5260325f 12 * This file contains various auxiliary functions related to multiple
13 * precision integers.
6ae2364d 14 *
8efc0c15 15*/
16
17#include "includes.h"
74fc9186 18RCSID("$OpenBSD: mpaux.c,v 1.13 2000/06/20 01:39:42 markus Exp $");
8efc0c15 19
35484284 20#include <openssl/bn.h>
5260325f 21#include "getput.h"
22#include "xmalloc.h"
23
5881cd60 24#include <openssl/md5.h>
5881cd60 25
8efc0c15 26void
27compute_session_id(unsigned char session_id[16],
7368a6c8 28 unsigned char cookie[8],
29 BIGNUM* host_key_n,
30 BIGNUM* session_key_n)
8efc0c15 31{
95f1eccc 32 unsigned int host_key_bytes = BN_num_bytes(host_key_n);
33 unsigned int session_key_bytes = BN_num_bytes(session_key_n);
34 unsigned int bytes = host_key_bytes + session_key_bytes;
5260325f 35 unsigned char *buf = xmalloc(bytes);
36 MD5_CTX md;
37
38 BN_bn2bin(host_key_n, buf);
95f1eccc 39 BN_bn2bin(session_key_n, buf + host_key_bytes);
5260325f 40 MD5_Init(&md);
41 MD5_Update(&md, buf, bytes);
95f1eccc 42 MD5_Update(&md, cookie, 8);
5260325f 43 MD5_Final(session_id, &md);
44 memset(buf, 0, bytes);
45 xfree(buf);
8efc0c15 46}
This page took 0.073045 seconds and 5 git commands to generate.