| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QTRANSPORTAUTHDEFS_QWS_H
|
|---|
| 43 | #define QTRANSPORTAUTHDEFS_QWS_H
|
|---|
| 44 |
|
|---|
| 45 | #include <sys/types.h>
|
|---|
| 46 | #include <string.h>
|
|---|
| 47 |
|
|---|
| 48 | #include <QtCore/qglobal.h>
|
|---|
| 49 |
|
|---|
| 50 | QT_BEGIN_HEADER
|
|---|
| 51 |
|
|---|
| 52 | QT_BEGIN_NAMESPACE
|
|---|
| 53 |
|
|---|
| 54 | QT_MODULE(Gui)
|
|---|
| 55 |
|
|---|
| 56 | #define QSXE_KEY_LEN 16
|
|---|
| 57 | #define QSXE_MAGIC_BYTES 4
|
|---|
| 58 |
|
|---|
| 59 | // Number of bytes of each message to authenticate. Just need to ensure
|
|---|
| 60 | // that the command at the beginning hasn't been tampered with. This value
|
|---|
| 61 | // does not matter for trusted transports.
|
|---|
| 62 | #define AMOUNT_TO_AUTHENTICATE 200
|
|---|
| 63 |
|
|---|
| 64 | #define AUTH_ID(k) ((unsigned char)(k[QSXE_KEY_LEN]))
|
|---|
| 65 | #define AUTH_KEY(k) ((unsigned char *)(k))
|
|---|
| 66 |
|
|---|
| 67 | // must be a largish -ve number under any endianess when cast as an int
|
|---|
| 68 | const unsigned char magic[QSXE_MAGIC_BYTES] = { 0xBA, 0xD4, 0xD4, 0xBA };
|
|---|
| 69 | const int magicInt = 0xBAD4D4BA;
|
|---|
| 70 |
|
|---|
| 71 | #define QSXE_KEYFILE "keyfile"
|
|---|
| 72 |
|
|---|
| 73 | /*
|
|---|
| 74 | Header in above format, less the magic bytes.
|
|---|
| 75 | Useful for reading off the socket
|
|---|
| 76 | */
|
|---|
| 77 | struct AuthHeader
|
|---|
| 78 | {
|
|---|
| 79 | unsigned char len;
|
|---|
| 80 | unsigned char pad;
|
|---|
| 81 | unsigned char digest[QSXE_KEY_LEN];
|
|---|
| 82 | unsigned char id;
|
|---|
| 83 | unsigned char seq;
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | /*
|
|---|
| 87 | Header in a form suitable for authentication routines
|
|---|
| 88 | */
|
|---|
| 89 | struct AuthMessage
|
|---|
| 90 | {
|
|---|
| 91 | AuthMessage()
|
|---|
| 92 | {
|
|---|
| 93 | ::memset( authData, 0, sizeof(authData) );
|
|---|
| 94 | ::memcpy( pad_magic, magic, QSXE_MAGIC_BYTES );
|
|---|
| 95 | }
|
|---|
| 96 | unsigned char pad_magic[QSXE_MAGIC_BYTES];
|
|---|
| 97 | union {
|
|---|
| 98 | AuthHeader hdr;
|
|---|
| 99 | char authData[sizeof(AuthHeader)];
|
|---|
| 100 | };
|
|---|
| 101 | char payLoad[AMOUNT_TO_AUTHENTICATE];
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | /**
|
|---|
| 105 | Auth data as stored in _key
|
|---|
| 106 | */
|
|---|
| 107 | struct AuthCookie
|
|---|
| 108 | {
|
|---|
| 109 | unsigned char key[QSXE_KEY_LEN];
|
|---|
| 110 | unsigned char pad;
|
|---|
| 111 | unsigned char progId;
|
|---|
| 112 | };
|
|---|
| 113 |
|
|---|
| 114 | /*
|
|---|
| 115 | Auth data as written to the key file - SUPERSEDED by usr_key_entry
|
|---|
| 116 |
|
|---|
| 117 | This is still used internally for some functions, ie the socket
|
|---|
| 118 | related calls.
|
|---|
| 119 | */
|
|---|
| 120 | struct AuthRecord
|
|---|
| 121 | {
|
|---|
| 122 | union {
|
|---|
|
|---|