WvStreams
wvdiffiehellman.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  * Copyright (C) 2003 Net Integration Technologies, Inc.
00004  *
00005  * Diffie-Hellman shared secret creation.
00006  */
00007 
00008 #ifndef __WVDIFFIEHELLMAN_H
00009 #define __WVDIFFIEHELLMAN_H
00010 
00011 #include <openssl/dh.h>
00012 
00013 #include "wvstream.h"
00014 #include "wvlog.h"
00015 
00016 class WvDiffieHellman
00017 {
00018 public:
00019     WvDiffieHellman(const unsigned char *_key, int _keylen, 
00020                     BN_ULONG _generator);
00021     ~WvDiffieHellman() { DH_free(info); }
00022 
00023     void get_created_secret(WvBuf &outbuf, size_t len);
00024     int get_public_value(WvBuf &outbuf, int len);
00025 
00026     int pub_key_len();
00027     bool create_secret(WvBuf &inbuf, size_t in_len, WvBuf& outbuf);
00028 
00029 protected:
00030     struct dh_st *info;
00031     BN_ULONG generator;
00032 
00033 private:
00034 
00035     WvLog log;
00036 };
00037 
00038 #endif /* __WVDIFFIEHELLMAN_H */