Qt 4.8
Macros | Functions | Variables
qtransportauth_qws.cpp File Reference
#include "qtransportauth_qws.h"
#include "qtransportauth_qws_p.h"
#include "../../3rdparty/md5/md5.h"
#include "../../3rdparty/md5/md5.cpp"
#include "qwsutils_qws.h"
#include "qwssocket_qws.h"
#include "qwscommand_qws_p.h"
#include "qwindowsystem_qws.h"
#include "qbuffer.h"
#include "qthread.h"
#include "qabstractsocket.h"
#include "qlibraryinfo.h"
#include "qfile.h"
#include "qdebug.h"
#include <private/qcore_unix_p.h>
#include <syslog.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <QtCore/qcache.h>
#include "moc_qtransportauth_qws_p.cpp"

Go to the source code of this file.

Macros

#define BUF_SIZE   512
 
#define KEY_CACHE_SIZE   30
 

Functions

bool __fileOpen (QFile *f)
 
Q_GUI_EXPORT void * guaranteed_memset (void *v, int c, size_t n)
 
static int hmac_md5 (unsigned char *text, int text_length, const unsigned char *key, int key_length, unsigned char *digest)
 

Variables

const char *const errorStrings []
 

Macro Definition Documentation

◆ BUF_SIZE

#define BUF_SIZE   512

◆ KEY_CACHE_SIZE

#define KEY_CACHE_SIZE   30

Definition at line 145 of file qtransportauth_qws.cpp.

Function Documentation

◆ __fileOpen()

bool __fileOpen ( QFile f)
inline

Definition at line 607 of file qtransportauth_qws.cpp.

Referenced by QTransportAuthPrivate::getClientKey().

608 {
609 #ifdef QTRANSPORTAUTH_DEBUG
610  if ( f->open( QIODevice::ReadOnly ))
611  {
612  qDebug( "Opened file: %s\n", qPrintable( f->fileName() ));
613  return true;
614  }
615  else
616  {
617  qWarning( "Could not open file: %s\n", qPrintable( f->fileName() ));
618  return false;
619  }
620 #else
621  return ( f->open( QIODevice::ReadOnly ));
622 #endif
623 }
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
Definition: qfile.cpp:470
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
#define qPrintable(string)
Definition: qglobal.h:1750

◆ guaranteed_memset()

Q_GUI_EXPORT void* guaranteed_memset ( void *  v,
int  c,
size_t  n 
)
Warning
This function is not part of the public interface. memset for security purposes, guaranteed not to be optimized away http://www.faqs.org/docs/Linux-HOWTO/Secure-Programs-HOWTO.html

Definition at line 84 of file qtransportauth_qws.cpp.

85 {
86  volatile char *p = (char *)v; while (n--) *p++=c; return v;
87 }
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ hmac_md5()

static int hmac_md5 ( unsigned char *  text,
int  text_length,
const unsigned char *  key,
int  key_length,
unsigned char *  digest 
)
static

Definition at line 1466 of file qtransportauth_qws.cpp.

Referenced by QTransportAuth::authFromMessage(), QTransportAuth::authToMessage(), and guaranteed_memset().

1473 {
1474  MD5Context context;
1475  unsigned char k_ipad[65]; /* inner padding - * key XORd with ipad */
1476  unsigned char k_opad[65]; /* outer padding - * key XORd with opad */
1477  int i;
1478 
1479  /* in this implementation key_length == 16 */
1480  if ( key_length != 16 )
1481  {
1482  fprintf( stderr, "Key length was %d - must be 16 bytes", key_length );
1483  return 0;
1484  }
1485 
1486  /* start out by storing key in pads */
1487  memset( k_ipad, 0, sizeof k_ipad );
1488  memset( k_opad, 0, sizeof k_opad );
1489  memcpy( k_ipad, key, key_length );
1490  memcpy( k_opad, key, key_length );
1491 
1492  /* XOR key with ipad and opad values */
1493  for (i=0; i<64; i++) {
1494  k_ipad[i] ^= 0x36;
1495  k_opad[i] ^= 0x5c;
1496  }
1497 
1498  /* perform inner MD5 */
1499  MD5Init(&context); /* init context for 1st pass */
1500  MD5Update(&context, k_ipad, 64); /* start with inner pad */
1501  MD5Update(&context, text, text_length); /* then text of datagram */
1502  MD5Final(&context, digest); /* finish up 1st pass */
1503 
1504  /* perform outer MD5 */
1505  MD5Init(&context); /* init context for 2nd pass */
1506  MD5Update(&context, k_opad, 64); /* start with outer pad */
1507  MD5Update(&context, digest, 16); /* then results of 1st * hash */
1508  MD5Final(&context, digest); /* finish up 2nd pass */
1509  return 1;
1510 }
int key
#define text
Definition: qobjectdefs.h:80

Variable Documentation

◆ errorStrings

const char* const errorStrings[]
Initial value:
= {
"pending identity verification",
"message too small to carry auth data",
"cache miss on connection oriented transport",
"no magic bytes on message",
"key not found for prog id",
"authorization key match failed",
"key out of date"
}

Definition at line 147 of file qtransportauth_qws.cpp.

Referenced by QTransportAuth::errorString().