File: structs.h

package info (click to toggle)
yapet 0.6-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,012 kB
  • ctags: 2,913
  • sloc: ansic: 13,661; cpp: 11,384; sh: 4,814; makefile: 847; yacc: 291; sed: 16
file content (233 lines) | stat: -rw-r--r-- 6,802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// -*- c++ -*-
//
// $Id: structs.h 2827 2009-08-31 18:01:41Z rafi $
//
// Copyright (C) 2008, 2009  Rafael Ostertag
//
// This file is part of YAPET.
//
// YAPET is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// YAPET is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// YAPET.  If not, see <http://www.gnu.org/licenses/>.
//
// Additional permission under GNU GPL version 3 section 7
//
// If you modify this program, or any covered work, by linking or combining it
// with the OpenSSL project's OpenSSL library (or a modified version of that
// library), containing parts covered by the terms of the OpenSSL or SSLeay
// licenses, Rafael Ostertag grants you additional permission to convey the
// resulting work.  Corresponding Source for a non-source form of such a
// combination shall include the source code for the parts of OpenSSL used as
// well as that of the covered work.
//

#ifndef _STRUCTS_H
#define _STRUCTS_H

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif

#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif

#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

namespace YAPET {

    /**
     * New in version 0.6
     * 
     * As of version 0.6, there may be different file versions. This holds the
     * known file versions so far.
     */
    enum FILE_VERSION {
        /**
         * The header version for pre version 0.6.
         */
        VERSION_1 = 1,
        /**
         * The header version for version 0.6.
         */
        VERSION_2 = 2
    };
    enum {
        /**
         * The length of the control string used to check whether
         * decryption was successful
         */
        HEADER_CONTROL_SIZE = 20,
        /**
         * The maximum length of the name string of a password record.
         */
        NAME_SIZE = 128,
        /**
         * The maximum length of the host string of a password
         * records.
         */
        HOST_SIZE = 256,
        /**
         * The maximum length of the user name string of a password
         * record.
         */
        USERNAME_SIZE = 256,
        /**
         * The maximum length of the password string of a password
         * record.
         */
        PASSWORD_SIZE = 256,
        /**
         * The maximum length of the comment string of a password
         * record.
         */
        COMMENT_SIZE = 512,
        /**
	 * New in version 0.6.
	 *
         * The header size of pre v. 0.6 on 32 bit arch in bytes.
         */
        HEADER_SIZE_32_B_PRE_0_6 = 25,
        /**
	 * New in version 0.6.
	 *
         * The header size of pre v. 0.6 on 64 bit arch in bytes.
         */
        HEADER_SIZE_64_B_PRE_0_6 = 29,
        /**
	 * New in version 0.6.
	 *
         * The header size of 0.6 in bytes. Please note that the header size
         * remains the same, regardless of the architecture (32/64bit)
         */
        HEADER_SIZE_0_6 = 29
    };

    /**
     * @brief The file header for 32 bit pre version 0.6.
     *
     * New in version 0.6.
     *
     * This is the file header structure 32 bit pre version 0.6. It uses
     * uint32_t for storing the time when the password was saved.
     */
    struct FileHeader_32 {
        /**
         * @brief Version
         *
         * Holds the version of the file structure.
         */
        uint8_t version;
        /**
         * @brief Control string
         *
         * Holds the control string used to verify the decryption
         * of the file. It is filled with a known sequence of
         * characters before encryption. After decryption the
         * sequence of characters stored in this field and the
         * predefined are compared. If they are identical, the
         * decryption is assumed to be successful.
         */
        uint8_t control[HEADER_CONTROL_SIZE];
        /**
         * @brief The date the key has first been used.
         *
         * Holds the date the key has first been used to encrypt
         * the file. Has to be stored in big-endian order.
         */
        int32_t pwset;
    };

    /**
     * @brief The file header for 64 bit pre version 0.6 and version 0.6.
     *
     * New in version 0.6.
     *
     * This is the file header structure 64 bit pre version 0.6 and 32/64 bit
     * version 0.6. It uses uint64_t for storing the time when the password was
     * saved.
     */
    struct FileHeader_64 {
        /**
         * @brief Version
         *
         * Holds the version of the file structure.
         */
        uint8_t version;
        /**
         * @brief Control string
         *
         * Holds the control string used to verify the decryption
         * of the file. It is filled with a known sequence of
         * characters before encryption. After decryption the
         * sequence of characters stored in this field and the
         * predefined are compared. If they are identical, the
         * decryption is assumed to be successful.
         */
        uint8_t control[HEADER_CONTROL_SIZE];
        /**
         * @brief The date the key has first been used.
         *
         * Holds the date the key has first been used to encrypt
         * the file. Has to be stored in big-endian order.
         */
        int64_t pwset;
    };

    /**
     * @brief Structure of the password record.
     *
     * The structure of a password records.
     */
    struct PasswordRecord {
        /**
         * @brief Name of the record.
         *
         * Name of the password records. \c PartDec decrypts the
         * record to get this field. It is used to give the user
         * an idea about the content of the record.
         */
        uint8_t name[NAME_SIZE];
        /**
         * @brief The host for which the password is used
         *
         * Holds the host name for which the password is used.
         */
        uint8_t host[HOST_SIZE];
        /**
         * @brief The user name
         *
         * The user name for the password.
         */
        uint8_t username[USERNAME_SIZE];
        /**
         * @brief The password.
         *
         * The password.
         */
        uint8_t password[PASSWORD_SIZE];
        /**
         * @brief A comment.
         *
         * An additional comment.
         */
        uint8_t comment[COMMENT_SIZE];
    };
}

#endif // _STRUCTS_H