本文整理汇总了C++中GETBYTE函数的典型用法代码示例。如果您正苦于以下问题:C++ GETBYTE函数的具体用法?C++ GETBYTE怎么用?C++ GETBYTE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GETBYTE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: v2_attr_rply
static int v2_attr_rply(int flags) {
int auth_cnt, i;
unsigned short errcode;
if (flags & F_SUM) {
GETSHORT(errcode);
if (errcode != OK) {
strcat(msgbuf, slpv2_error(errcode));
msglength = 0; /* skip rest of message */
return (0);
} else {
GETFIELD; /* attr list */
#ifdef VERIFYSLP
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
if (skip_v2authblock() < 0)
return (0);
#endif
}
} else if (flags & F_DTAIL) {
V2_DOERRCODE;
DOFIELD("Attribute list", FIELD_DEFAULT);
/* auth */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
V2_DOAUTH(i);
}
return (1);
}
示例2: v2_srv_reg
static int v2_srv_reg(int flags) {
int i, auth_cnt;
if (flags & F_SUM) {
SKIPBYTE; /* reserved */
SKIPSHORT; /* lifetime */
GETFIELD; /* URL */
#ifdef VERIFYSLP
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
if (skip_v2authblock() < 0)
return (0);
SKIPFIELD(FIELD_DEFAULT); /* type */
SKIPFIELD(FIELD_DEFAULT); /* scopes */
SKIPFIELD(FIELD_DEFAULT); /* attrs */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
if (skip_v2authblock() < 0)
return (0);
#endif
} if (flags & F_DTAIL) {
V2_DOURL(-1);
DOFIELD("Service type", FIELD_DEFAULT);
DOFIELD("Scopes", FIELD_DEFAULT);
DOFIELD("Attribute list", FIELD_DEFAULT);
/* auth */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
V2_DOAUTH(i);
}
return (1);
}
示例3: v2_daadvert
static int v2_daadvert(int flags) {
int auth_cnt, i;
unsigned short errcode;
unsigned int timestamp;
if (flags & F_SUM) {
SKIPSHORT; /* error code */
SKIPSHORT; SKIPSHORT; /* timestamp */
GETFIELD; /* URL */
#ifdef VERIFYSLP
SKIPFIELD(FIELD_DEFAULT); /* scopes */
SKIPFIELD(FIELD_DEFAULT); /* attrs */
SKIPFIELD(FIELD_DEFAULT); /* SPIs */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
if (skip_v2authblock() < 0)
return (0);
#endif
} else if (flags & F_DTAIL) {
V2_DOERRCODE;
V2_DOTIMESTAMP;
DOFIELD("URL", FIELD_DEFAULT);
DOFIELD("Scope list", FIELD_DEFAULT);
DOFIELD("Attribute list", FIELD_DEFAULT);
DOFIELD("Configured SPIs", FIELD_DEFAULT);
/* auth */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
V2_DOAUTH(i);
}
return (1);
}
示例4: v2_saadvert
static int v2_saadvert(int flags) {
int auth_cnt, i;
if (flags & F_SUM) {
GETFIELD; /* URL */
#ifdef VERIFYSLP
SKIPFIELD(FIELD_DEFAULT); /* scopes */
SKIPFIELD(FIELD_DEFAULT); /* attrs */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
if (skip_v2authblock() < 0)
return (0);
#endif
} else if (flags & F_DTAIL) {
DOFIELD("URL", FIELD_DEFAULT);
DOFIELD("Scopes", FIELD_DEFAULT);
DOFIELD("Attribute list", FIELD_DEFAULT);
/* auth */
GETBYTE(auth_cnt);
for (i = 0; i < auth_cnt; i++)
V2_DOAUTH(i);
}
return (1);
}
示例5: GetUserKey
void Twofish::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
{
unsigned int len = (keylen <= 16 ? 2 : (keylen <= 24 ? 3 : 4));
word32 key[8];
GetUserKey(LittleEndianOrder, key, len*2, userKey, keylen);
unsigned int i;
for (i=0; i<40; i+=2) {
word32 a = h(i, key, len);
word32 b = rotlFixed(h(i+1, key+1, len), 8);
k_[i] = a+b;
k_[i+1] = rotlFixed(a+2*b, 9);
}
word32 svec[8];
for (i=0; i<len; i++)
svec[2*(len-i-1)] = ReedSolomon(key[2*i+1], key[2*i]);
for (i=0; i<256; i++) {
word32 t = h0(i, svec, len);
s_[0][i] = mds_[0][GETBYTE(t, 0)];
s_[1][i] = mds_[1][GETBYTE(t, 1)];
s_[2][i] = mds_[2][GETBYTE(t, 2)];
s_[3][i] = mds_[3][GETBYTE(t, 3)];
}
}
示例6: pgp_s2k_read
int
pgp_s2k_read(PullFilter *src, PGP_S2K *s2k)
{
int res = 0;
GETBYTE(src, s2k->mode);
GETBYTE(src, s2k->digest_algo);
switch (s2k->mode)
{
case 0:
break;
case 1:
res = pullf_read_fixed(src, 8, s2k->salt);
break;
case 3:
res = pullf_read_fixed(src, 8, s2k->salt);
if (res < 0)
break;
GETBYTE(src, s2k->iter);
break;
default:
res = PXE_PGP_BAD_S2K_MODE;
}
return res;
}
示例7: GETBYTE
void DataOutputStream::writeUInt16(UINT16 data)
{
UINT8 buf[2];
buf[0] = GETBYTE(data, 1);
buf[1] = GETBYTE(data, 0);
writeFully((char *)buf, sizeof(buf));
}
示例8: crypt_block
// this version is only used to make pbox and sbox
void Blowfish::crypt_block(const word32 in[2], word32 out[2]) const
{
word32 left = in[0];
word32 right = in[1];
const word32 *const s=sbox;
const word32 *p=pbox;
left ^= p[0];
for (unsigned i=0; i<ROUNDS/2; i++)
{
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
^ p[2*i+2];
}
right ^= p[ROUNDS+1];
out[0] = right;
out[1] = left;
}
示例9: ProcessAndXorBlock
void Blowfish::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out)
const
{
word32 left, right;
const word32 *const s = sbox_;
const word32* p = pbox_;
gpBlock::Get(in)(left)(right);
left ^= p[0];
// roll back up and use s and p index instead of just p
for (unsigned i = 0; i < ROUNDS / 2; i++) {
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
^ p[2*i+2];
}
right ^= p[ROUNDS + 1];
gpBlock::Put(xOr, out)(right)(left);
}
示例10: BlowfishEncryptLE
void BlowfishEncryptLE (unsigned char *inBlock, unsigned char *outBlock, BF_KEY *key, int encrypt)
{
word32 left = LE32 (((word32 *) inBlock)[0]);
word32 right = LE32 (((word32 *) inBlock)[1]);
const word32 *const s = key->sbox;
const word32 * p = encrypt ? key->pbox : key->pbox_dec;
unsigned i;
left ^= p[0];
for (i=0; i<ROUNDS/2; i++)
{
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
^ p[2*i+2];
}
right ^= p[ROUNDS+1];
((word32 *) outBlock)[0] = LE32 (right);
((word32 *) outBlock)[1] = LE32 (left);
}
示例11: crypt_block
// this version is only used to make pbox and sbox
static void crypt_block(BF_KEY *key, const word32 in[2], word32 out[2])
{
word32 left = in[0];
word32 right = in[1];
const word32 *const s=key->sbox;
const word32 *p=key->pbox;
unsigned i;
left ^= p[0];
for (i=0; i<ROUNDS/2; i++)
{
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
^ p[2*i+2];
}
right ^= p[ROUNDS+1];
out[0] = right;
out[1] = left;
}
示例12: GetBlockBigEndian
void Blowfish::ProcessBlock(const byte *in, byte *out) const
{
word32 left, right;
GetBlockBigEndian(in, left, right);
const word32 *const s=sbox;
const word32 *p=pbox;
left ^= p[0];
for (unsigned i=0; i<ROUNDS/2; i++)
{
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
^ p[2*i+2];
}
right ^= p[ROUNDS+1];
PutBlockBigEndian(out, right, left);
}
示例13: return
byte LC_RNG::GenerateByte()
{
word32 hi = seed/q;
word32 lo = seed%q;
long test = a*lo - r*hi;
if (test > 0)
seed = test;
else
seed = test+ m;
return (GETBYTE(seed, 0) ^ GETBYTE(seed, 1) ^ GETBYTE(seed, 2) ^ GETBYTE(seed, 3));
}
示例14: archive_fetch_data
uint64_t archive_fetch_data(int fd, int size)
{
unsigned char data[8] = { 0 };
uint64_t val = 0;
if (read(fd, data, size) != size) {
DPRINTF("Invalid data block\n");
return (uint64_t)-1;
}
switch (size) {
case 1: val = GETBYTE(data);
break;
case 2: val = GETWORD(data);
break;
case 4: val = GETUINT32(data);
break;
case 8: val = GETUINT64(data);
break;
default:val = (uint64_t)-1;
DPRINTF("Cannot get %d bytes: Not implemented\n", size);
break;
}
return val;
}
示例15: GETDWORD
// Disconnect client from char/world server
bool CCharServer::pakLoginDSClient( CCharClient* thisclient, CPacket* P )
{
unsigned int userid = GETDWORD((*P), 1 );
CCharClient* otherclient = GetClientByUserID( userid );
BYTE action = GETBYTE((*P),0);
switch(action)
{
case 1:
{
if(otherclient==NULL)
{
Log( MSG_WARNING, "Userid '%u' is not online", userid );
return true;
}
otherclient->isLoggedIn = false;
otherclient->isActive = false;
BEGINPACKET( pak, 0x502 );
ADDBYTE ( pak, 1 );
ADDDWORD ( pak, userid );
//ADDBYTE ( pak, 0x00 );
//cryptPacket( (char*)&pak, NULL );
CChanels* thischannel = GetChannelByID( otherclient->channel );
if(thischannel!=NULL)
send( thischannel->sock, (char*)&pak, pak.Size, 0 );
}
break;
}
return true;
}