]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/mpaux.c
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.git] / crypto / openssh / mpaux.c
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  * $FreeBSD$
16 */
17
18 #include "includes.h"
19 RCSID("$Id: mpaux.c,v 1.9 1999/12/08 22:37:42 markus Exp $");
20
21 #include <openssl/bn.h>
22 #include "getput.h"
23 #include "xmalloc.h"
24
25 #include <openssl/md5.h>
26
27 void
28 compute_session_id(unsigned char session_id[16],
29                    unsigned char cookie[8],
30                    BIGNUM* host_key_n,
31                    BIGNUM* session_key_n)
32 {
33         unsigned int host_key_bytes = BN_num_bytes(host_key_n);
34         unsigned int session_key_bytes = BN_num_bytes(session_key_n);
35         unsigned int bytes = host_key_bytes + session_key_bytes;
36         unsigned char *buf = xmalloc(bytes);
37         MD5_CTX md;
38
39         BN_bn2bin(host_key_n, buf);
40         BN_bn2bin(session_key_n, buf + host_key_bytes);
41         MD5_Init(&md);
42         MD5_Update(&md, buf, bytes);
43         MD5_Update(&md, cookie, 8);
44         MD5_Final(session_id, &md);
45         memset(buf, 0, bytes);
46         xfree(buf);
47 }