Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

ZrtpPacketDHPart.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2006-2007 Werner Dittmann
00003 
00004   This program is free software: you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation, either version 3 of the License, or
00007   (at your option) any later version.
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00018 #ifndef _ZRTPPACKETDHPART_H_
00019 #define _ZRTPPACKETDHPART_H_
00020 
00021 #include <libzrtpcpp/ZrtpPacketBase.h>
00022 
00033 class ZrtpPacketDHPart : public ZrtpPacketBase {
00034 
00035  protected:
00036     uint8_t *pv;
00037     DHPart_t* DHPartHeader;
00038 
00039  public:
00040     ZrtpPacketDHPart(SupportedPubKeys pkt);     /* Creates a DHPart packet with default data */
00041     ZrtpPacketDHPart(uint8_t* data);            /* Creates a DHPart packet from received data */
00042     virtual ~ZrtpPacketDHPart();
00043 
00044     uint8_t* getPv()             { return pv; }
00045     uint8_t* getRs1Id()          { return DHPartHeader->rs1Id; };
00046     uint8_t* getRs2Id()          { return DHPartHeader->rs2Id; };
00047     uint8_t* getSigsId()         { return DHPartHeader->sigsId; };
00048     uint8_t* getSrtpsId()        { return DHPartHeader->srtpsId; };
00049     uint8_t* getOtherSecretId()  { return DHPartHeader->otherSecretId; };
00050 
00051     void setPv(uint8_t* text)         { memcpy(pv, text, ((pktype == Dh3072) ? 384 :512)); };
00052     void setRs1Id(uint8_t* text)      { memcpy(DHPartHeader->rs1Id, text, sizeof(DHPartHeader->rs1Id)); };
00053     void setRs2Id(uint8_t* text)      { memcpy(DHPartHeader->rs2Id, text, sizeof(DHPartHeader->rs2Id)); };
00054     void setSigsId(uint8_t* text)     { memcpy(DHPartHeader->sigsId, text, sizeof(DHPartHeader->sigsId)); };
00055     void setSrtpsId(uint8_t* t)       { memcpy(DHPartHeader->srtpsId, t, sizeof(DHPartHeader->srtpsId)); };
00056     void setOtherSecretId(uint8_t* t) { memcpy(DHPartHeader->otherSecretId,t, sizeof(DHPartHeader->otherSecretId)); };
00057 
00058  private:
00059     SupportedPubKeys pktype;
00060      // DHPart packet is of variable length. It maximum size is 141 words:
00061      // - 13 words fixed sizze 
00062      // - up to 128 words variable part, depending on DH algorithm 
00063      // leads to a maximum of 4*141=5644 bytes.
00064      uint8_t data[768];       // large enough to hold a full blown DHPart packet
00065 
00066 };
00067 
00068 #endif // ZRTPPACKETDHPART
00069 

© sourcejam.com 2005-2008