blob: b23b23dd51e3b153e3837e792ef4caeeb1a57a53 [file] [log] [blame]
Alexandre Lision51140e12013-12-02 10:54:09 -05001/*
Alexandre Lisione24852d2014-02-04 13:13:02 -05002 Copyright (C) 2006-2007 Werner Dittmann
Alexandre Lision51140e12013-12-02 10:54:09 -05003
4 This program is free software: you can redistribute it and/or modify
Alexandre Lisione24852d2014-02-04 13:13:02 -05005 it under the terms of the GNU General Public License as published by
Alexandre Lision51140e12013-12-02 10:54:09 -05006 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * Authors: Werner Dittmann <Werner.Dittmann@t-online.de>
20 */
21#ifndef _ZRTPPACKETCOMMIT_H_
22#define _ZRTPPACKETCOMMIT_H_
23
24/**
25 * @file ZrtpPacketCommit.h
26 * @brief The ZRTP Commit message
27 *
28 * @ingroup GNU_ZRTP
29 * @{
30 */
31
32#include <libzrtpcpp/ZrtpPacketBase.h>
33
34/**
35 * Implement the Commit packet.
36 *
37 * The ZRTP message Commit. The ZRTP implementation sends or receives
38 * this message to commit the crypto parameters offered during a Hello
39 * message.
40 *
41 *
42 * @author Werner Dittmann <Werner.Dittmann@t-online.de>
43 */
44
45class __EXPORT ZrtpPacketCommit : public ZrtpPacketBase {
46
47 protected:
48 Commit_t* commitHeader; ///< Points to Commit message part
49
50 public:
51 /// Creates a Commit packet with default data
52 ZrtpPacketCommit();
53
54 /// Creates a Commit packet from received data
55 ZrtpPacketCommit(uint8_t* data);
56
57 /// Normal destructor
58 virtual ~ZrtpPacketCommit();
59
60 /// Get pointer to hash algorithm type field, a fixed length character array
61 uint8_t* getHashType() { return commitHeader->hash; };
62
63 /// Get pointer to cipher algorithm type field, a fixed length character array
64 uint8_t* getCipherType() { return commitHeader->cipher; };
65
66 /// Get pointer to SRTP authentication algorithm type field, a fixed length character array
67 uint8_t* getAuthLen() { return commitHeader->authlengths; };
68
69 /// Get pointer to key agreement algorithm type field, a fixed length character array
70 uint8_t* getPubKeysType() { return commitHeader->pubkey; };
71
72 /// Get pointer to SAS algorithm type field, a fixed length character array
73 uint8_t* getSasType() { return commitHeader->sas; };
74
75 /// Get pointer to ZID field, a fixed length byte array
76 uint8_t* getZid() { return commitHeader->zid; };
77
78 /// Get pointer to HVI field, a fixed length byte array
79 uint8_t* getHvi() { return commitHeader->hvi; };
80
81 /// Get pointer to NONCE field, a fixed length byte array, overlaps HVI field
82 uint8_t* getNonce() { return commitHeader->hvi; };
83
84 /// Get pointer to hashH2 field, a fixed length byte array
85 uint8_t* getH2() { return commitHeader->hashH2; };
86
87 /// Get pointer to MAC field, a fixed length byte array
88 uint8_t* getHMAC() { return commitHeader->hmac; };
89
90 /// Get pointer to MAC field during multi-stream mode, a fixed length byte array
91 uint8_t* getHMACMulti() { return commitHeader->hmac-4*ZRTP_WORD_SIZE; };
92
Alexandre Lision51140e12013-12-02 10:54:09 -050093 /// Set hash algorithm type field, fixed length character field
94 void setHashType(uint8_t* text) { memcpy(commitHeader->hash, text, ZRTP_WORD_SIZE); };
95
96 /// Set cipher algorithm type field, fixed length character field
97 void setCipherType(uint8_t* text) { memcpy(commitHeader->cipher, text, ZRTP_WORD_SIZE); };
98
99 /// Set SRTP authentication algorithm algorithm type field, fixed length character field
100 void setAuthLen(uint8_t* text) { memcpy(commitHeader->authlengths, text, ZRTP_WORD_SIZE); };
101
102 /// Set key agreement algorithm type field, fixed length character field
103 void setPubKeyType(uint8_t* text) { memcpy(commitHeader->pubkey, text, ZRTP_WORD_SIZE); };
104
105 /// Set SAS algorithm type field, fixed length character field
106 void setSasType(uint8_t* text) { memcpy(commitHeader->sas, text, ZRTP_WORD_SIZE); };
107
108 /// Set ZID field, a fixed length byte array
109 void setZid(uint8_t* text) { memcpy(commitHeader->zid, text, sizeof(commitHeader->zid)); };
110
111 /// Set HVI field, a fixed length byte array
112 void setHvi(uint8_t* text) { memcpy(commitHeader->hvi, text, sizeof(commitHeader->hvi)); };
113
114 /// Set conce field, a fixed length byte array, overlapping HVI field
115 void setNonce(uint8_t* text);
116
117 /// Set hashH2 field, a fixed length byte array
118 void setH2(uint8_t* hash) { memcpy(commitHeader->hashH2, hash, sizeof(commitHeader->hashH2)); };
119
120 /// Set MAC field, a fixed length byte array
121 void setHMAC(uint8_t* hash) { memcpy(commitHeader->hmac, hash, sizeof(commitHeader->hmac)); };
122
123 /// Set MAC field during multi-stream mode, a fixed length byte array
124 void setHMACMulti(uint8_t* hash) { memcpy(commitHeader->hmac-4*ZRTP_WORD_SIZE, hash, sizeof(commitHeader->hmac)); };
125
126 private:
127 CommitPacket_t data;
128};
129
130/**
131 * @}
132 */
133#endif // ZRTPPACKETCOMMIT
134