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 _ZRTPPACKETCONFIRM_H_ 00019 #define _ZRTPPACKETCONFIRM_H_ 00020 00021 #include <libzrtpcpp/ZrtpPacketBase.h> 00022 00034 class ZrtpPacketConfirm : public ZrtpPacketBase { 00035 00036 private: 00037 Confirm_t* confirmHeader; 00038 00039 public: 00040 ZrtpPacketConfirm(uint8_t sl); /* Creates a Confirm packet with default data */ 00041 ZrtpPacketConfirm(uint8_t* d); /* Creates a Confirm packet from received data */ 00042 virtual ~ZrtpPacketConfirm(); 00043 00044 const bool isSASFlag() { return confirmHeader->flags & 0x4; } 00045 const uint8_t* getFiller() { return confirmHeader->filler; }; 00046 const uint8_t* getIv() { return confirmHeader->iv; }; 00047 const uint8_t* getHmac() { return confirmHeader->hmac; }; 00048 const uint32_t getExpTime() { return ntohl(confirmHeader->expTime); }; 00049 00050 void setSASFlag() { confirmHeader->flags |= 0x4; }; 00051 void setHmac(uint8_t* text) { memcpy(confirmHeader->hmac, text, sizeof(confirmHeader->hmac)); }; 00052 void setIv(uint8_t* text) { memcpy(confirmHeader->iv, text, sizeof(confirmHeader->iv)); }; 00053 void setExpTime(uint32_t t) { confirmHeader->expTime = htonl(t); }; 00054 00055 private: 00056 // Confirm packet is of variable length. It maximum size is 268 words: 00057 // - 11 words fixed size 00058 // - up to 257 words variable part, depending if signature is present ant its length 00059 // leads to a maximum of 4*268=1072 bytes. 00060 uint8_t data[1280]; // large enough to hold a full blown Confirm packet 00061 00062 }; 00063 00064 #endif // ZRTPPACKETCONFIRM 00065