securecomm.h

00001 // -*- C++ -*- 00002 /* 00003 $Id: securecomm_8h-source.html,v 1.1 2004/10/05 21:12:03 mentat Exp $ 00004 00005 GNU Messenger - The secure instant messenger 00006 00007 Copyright (C) 1999-2002 Henrik Abelsson <henrik@abelsson.com> 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 #ifndef GM_SECURECOMM_H 00024 #define GM_SECURECOMM_H 00025 00026 namespace GNUMessenger { 00027 00033 class CryptoSession 00034 { 00035 public: 00036 CryptoSession(); 00037 virtual ~CryptoSession(); 00038 enum Status { None,Negotiation1,Reply1,Negoatiation2,Reply2,Connected}; 00039 00040 // virtual string requestCertificate(); 00041 /* alice sends bob her certificate and a msg with a session key */ 00042 string authenticate(); 00043 // string encryptMsg(const string &msg); 00044 00045 // void parseRequest(const string &request); 00046 00047 void setPeer(const Certificate & peer) { this->peer = peer;}; 00048 void setPrivkey(const string &key) { this->privKey = key; }; 00049 void setCert(const Certificate& mycert) { this->mycert = mycert;}; 00050 // private: 00051 /* bob parses alices certificate and her packet */ 00052 void parseAuthenticateReply(const string &msg); 00053 /* bob makes a reply to alice */ 00054 string authenticate2(); 00055 /* alice parses bobs reply */ 00056 void parseAuthenticate2Reply(const string &msg); 00057 /* and sends another packet */ 00058 string authenticate3(); 00059 /* which bob parses */ 00060 void parseAuthenticate3Reply(const string &msg); 00061 //private: 00062 enum { 00063 IDENTITY, 00064 SESSIONKEY, 00065 RANDOMDATA, 00066 RANDOMDATA2, 00067 SESSIONKEY2, 00068 00069 CERTIFICATE, 00070 MSG, 00071 SIGNATURE, 00072 }; 00073 00074 byte random[16]; 00075 byte random2[16]; 00076 00077 string privKey; 00078 byte *sessionKey; 00079 int sessionKeyLen; 00080 byte *sessionKey2; 00081 int sessionKey2Len; 00082 byte *finalKey; 00083 int finalKeyLen; 00084 Status status; 00085 Certificate peer,mycert; 00086 }; 00087 00088 } 00089 00090 #endif

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8