本文整理匯總了C++中BYTES函數的典型用法代碼示例。如果您正苦於以下問題:C++ BYTES函數的具體用法?C++ BYTES怎麽用?C++ BYTES使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BYTES函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: norx_aead_decrypt
int norx_aead_decrypt(
unsigned char *m, size_t *mlen,
const unsigned char *a, size_t alen,
const unsigned char *c, size_t clen,
const unsigned char *z, size_t zlen,
const unsigned char *nonce,
const unsigned char *key
)
{
const __m256i K = LOADU(key);
__m256i A, B, C, D;
if (clen < BYTES(NORX_T)) { return -1; }
*mlen = clen - BYTES(NORX_T);
INITIALISE(A, B, C, D, nonce, K);
ABSORB_DATA(A, B, C, D, a, alen, HEADER_TAG);
DECRYPT_DATA(A, B, C, D, m, c, clen - BYTES(NORX_T));
ABSORB_DATA(A, B, C, D, z, zlen, TRAILER_TAG);
FINALISE(A, B, C, D, K);
/* Verify tag */
D = _mm256_cmpeq_epi8(D, LOADU(c + clen - BYTES(NORX_T)));
return (((_mm256_movemask_epi8(D) & 0xFFFFFFFFULL) + 1) >> 32) - 1;
}
示例2: buffer_node_state
int
buffer_node_state(struct node *node, int full,
const struct sockaddr_in6 *sin6, struct interface *interface)
{
int buflen = full ? 20 + node->datalen : 20;
unsigned char buf[buflen];
int i = 0;
long long orig_delay =
(now.tv_sec - node->orig_time.tv_sec) * 1000LL +
((long long)now.tv_nsec - node->orig_time.tv_nsec + 999999) / 1000000;
BYTES(node->id, 4);
LONG(node->seqno);
LONG((unsigned)orig_delay);
BYTES(node->datahash, 8);
if(full) {
BYTES(node->data, node->datalen);
}
assert(i == buflen);
debugf("-> NODE-STATE %s%s\n",
format_32(node->id),
full && interface ? " (full, multicast)" :
full ? " (full)" :
interface ? " (multicast)" : "");
return buffer_tlv(5, buf, buflen, sin6, interface);
}
示例3: named
/********************
class scalarsettypedecl
********************/
scalarsettypedecl::scalarsettypedecl(expr * l, int lb)
:typedecl(), named(FALSE), lexname(NULL), useless(TRUE)
{
if (Error.CondError(!type_equal(l->gettype(), inttype),
"Only scalarsets of integer size allowed.") ||
Error.CondError(!l->hasvalue(), "Scalarset size must be constants.")
) {
left = lb;
right = lb;
numbits = 1;
if (!args->no_compression) {
bitsalloc = numbits;
} else {
bitsalloc = BYTES(numbits);
if (left < 0 || right > 254 || numbits > 8)
bitsalloc = 32;
}
mu_type = (left < 0 || right > 254 || numbits > 8 ?
"mu__long" : "mu__byte");
idvalues = symtab->declare(new lexid(tsprintf("scalarset_%u_v_error",
scalarset_type_int++),
0), new constdecl(lb++, this));
// it is not set as scalarset variable because it is of size 1.
// structure = typedecl::ScalarsetVariable;
scalarsetlist = NULL; // to be set when declaring ID : typeExpr
} else {
// setting size, numbits, left and right
// const 0 is used for undefined value --> 0. lb, ... . ub
int size = l->getvalue();
if (size < 1)
Error.Error("Scalarset size must be greater than zero.");
numbits = CeilLog2(l->getvalue() + 1);
left = lb;
right = left + size - 1;
if (!args->no_compression) {
bitsalloc = numbits;
} else {
if (numbits > 31)
Error.Error("Internal error, range is too large");
bitsalloc = BYTES(numbits);
if (left < 0 || right > 254 || numbits > 8)
bitsalloc = 32;
}
mu_type = (left < 0 || right > 254 || numbits > 8 ?
"mu__long" : "mu__byte");
// set id strings
// name may be changed if it is later explicitly given a type name
int value = left;
for (int i = 1; i <= size; i++) {
symtab->declare(new lexid(tsprintf("scalarset_%u_v%u",
scalarset_type_int, i), 0),
new constdecl(value++, this));
}
idvalues = symtab->getscope();
if (size > 1) // scalarset of size 1 is treated as normal enum
structure = typedecl::ScalarsetVariable;
scalarsetlist = NULL; // to be set when declaring ID : typeExpr
}
}
示例4: norx_aead_decrypt
int norx_aead_decrypt(
unsigned char *m, size_t *mlen,
const unsigned char *a, size_t alen,
const unsigned char *c, size_t clen,
const unsigned char *z, size_t zlen,
const unsigned char *nonce,
const unsigned char *key
)
{
const uint32x4_t K = LOADU(key);
uint32x4_t A, B, C, D;
if(clen < BYTES(NORX_T)) { return -1; }
*mlen = clen - BYTES(NORX_T);
INITIALISE(A, B, C, D, nonce, K);
ABSORB_DATA(A, B, C, D, a, alen, HEADER_TAG);
DECRYPT_DATA(A, B, C, D, m, c, clen - BYTES(NORX_T));
ABSORB_DATA(A, B, C, D, z, zlen, TRAILER_TAG);
FINALISE(A, B, C, D, K);
/* Verify tag */
D = vceqq_u32(D, LOADU(c + clen - BYTES(NORX_T)));
return 0xFFFFFFFF == (vgetq_lane_u32(D, 0) & vgetq_lane_u32(D, 1) & vgetq_lane_u32(D, 2) & vgetq_lane_u32(D, 3)) ? 0 : -1;
}
示例5: norx_aead_decrypt
int norx_aead_decrypt(
unsigned char *m, size_t *mlen,
const unsigned char *a, size_t alen,
const unsigned char *c, size_t clen,
const unsigned char *z, size_t zlen,
const unsigned char *nonce,
const unsigned char *key
)
{
const __m128i K = LOADU(key);
__m128i S[4];
if (clen < BYTES(NORX_T)) { return -1; }
*mlen = clen - BYTES(NORX_T);
INITIALISE(S, nonce, K);
ABSORB_DATA(S, a, alen, HEADER_TAG);
DECRYPT_DATA(S, m, c, clen - BYTES(NORX_T));
ABSORB_DATA(S, z, zlen, TRAILER_TAG);
FINALISE(S, K);
/* Verify tag */
S[3] = _mm_cmpeq_epi8(S[3], LOADU(c + clen - BYTES(NORX_T)));
return (((_mm_movemask_epi8(S[3]) & 0xFFFFU) + 1) >> 16) - 1;
}
示例6: mrs_decrypt_lastblock
static MRS_INLINE void mrs_decrypt_lastblock(mrs_state_t state, unsigned char * out, const unsigned char * in, size_t inlen)
{
size_t i;
mrs_word_t * S = state->S;
uint8_t lastblock[BYTES(MRS_R)];
mrs_permute(state);
for(i = 0; i < WORDS(MRS_R); ++i)
{
STORE(lastblock + i * BYTES(MRS_W), S[i]);
}
/* undo padding */
memcpy(lastblock, in, inlen);
/*lastblock[inlen] ^= 0x01;
lastblock[BYTES(MRS_R) - 1] ^= 0x80;*/
for (i = 0; i < WORDS(MRS_R); ++i)
{
const mrs_word_t c = LOAD(lastblock + i * BYTES(MRS_W));
STORE(lastblock + i * BYTES(MRS_W), S[i] ^ c);
S[i] = c;
}
memcpy(out, lastblock, inlen);
#if defined(MRS_DEBUG)
printf("DECRYPTING LASTBLOCK:\n");
print_bytes(lastblock, BYTES(MRS_R));
printf("STATE:\n");
print_state(state->S);
#endif
burn(lastblock, 0, sizeof lastblock);
}
示例7: mrs_absorb_lastblock
void mrs_absorb_lastblock(mrs_state_t state, const unsigned char * in, size_t inlen)
{
uint8_t lastblock[BYTES(MRS_B)];
mrs_pad(lastblock, sizeof lastblock, in, inlen);
mrs_absorb_block(state, lastblock);
burn(lastblock, 0, BYTES(MRS_B));
}
示例8: mrs_finalise
void mrs_finalise(mrs_state_t state, size_t hlen, size_t mlen, unsigned char * tag)
{
mrs_word_t * S = state->S;
uint8_t lastblock[BYTES(MRS_R)];
size_t i;
/* finalise state */
mrs_permute(state);
S[0] ^= hlen;
S[1] ^= mlen;
mrs_permute(state);
/* extract tag */
for (i = 0; i < WORDS(MRS_R); ++i)
{
STORE(lastblock + i * BYTES(MRS_W), S[i]);
}
memcpy(tag, lastblock, BYTES(MRS_T));
#if defined(MRS_DEBUG)
printf("FINALISED:\n");
print_state(state->S);
#endif
burn(lastblock, 0, BYTES(MRS_R));
}
示例9: norx_pad
static NORX_INLINE void norx_pad(uint8_t *out, const uint8_t *in, const size_t inlen)
{
memset(out, 0, BYTES(RATE));
memcpy(out, in, inlen);
out[inlen] = 0x01;
out[BYTES(RATE) - 1] |= 0x80;
}
示例10: norx_aead_decrypt
int norx_aead_decrypt(
unsigned char *m, size_t *mlen,
const unsigned char *a, size_t alen,
const unsigned char *c, size_t clen,
const unsigned char *z, size_t zlen,
const unsigned char *nonce,
const unsigned char *key
)
{
uint64x2_t S[8];
uint32x4_t T[2];
if (clen < BYTES(NORX_T)) { return -1; }
*mlen = clen - BYTES(NORX_T);
INITIALISE(S, nonce, key);
ABSORB_DATA(S, a, alen, HEADER_TAG);
DECRYPT_DATA(S, m, c, clen - BYTES(NORX_T));
ABSORB_DATA(S, z, zlen, TRAILER_TAG);
FINALISE(S);
/* Verify tag */
T[0] = vceqq_u32(U64TOU32(S[0]), U8TOU32( vld1q_u8((uint8_t *)(c + clen - BYTES(NORX_T) )) ));
T[1] = vceqq_u32(U64TOU32(S[1]), U8TOU32( vld1q_u8((uint8_t *)(c + clen - BYTES(NORX_T)/2)) ));
T[0] = vandq_u32(T[0], T[1]);
return 0xFFFFFFFFFFFFFFFFULL == (vgetq_lane_u64(U32TOU64(T[0]), 0) & vgetq_lane_u64(U32TOU64(T[0]), 1)) ? 0 : -1;
}
示例11: norx_decrypt_lastblock
static NORX_INLINE void norx_decrypt_lastblock(norx_state_t state, uint8_t *out, const uint8_t * in, size_t inlen)
{
norx_word_t * S = state->S;
uint8_t lastblock[BYTES(NORX_R)];
size_t i;
S[15] ^= PAYLOAD_TAG;
norx_permute(state);
for(i = 0; i < WORDS(NORX_R); ++i) {
STORE(lastblock + i * BYTES(NORX_W), S[i]);
}
memcpy(lastblock, in, inlen);
lastblock[inlen] ^= 0x01;
lastblock[BYTES(NORX_R) - 1] ^= 0x80;
for (i = 0; i < WORDS(NORX_R); ++i) {
const norx_word_t c = LOAD(lastblock + i * BYTES(NORX_W));
STORE(lastblock + i * BYTES(NORX_W), S[i] ^ c);
S[i] = c;
}
memcpy(out, lastblock, inlen);
burn(lastblock, 0, sizeof lastblock);
}
示例12: mrs_encrypt_lastblock
static MRS_INLINE void mrs_encrypt_lastblock(mrs_state_t state, unsigned char * out, const unsigned char * in, size_t inlen)
{
uint8_t lastblock[BYTES(MRS_R)];
mrs_pad(lastblock, sizeof lastblock, in, inlen);
mrs_encrypt_block(state, lastblock, lastblock);
memcpy(out, lastblock, inlen);
burn(lastblock, 0, BYTES(MRS_R));
}
示例13: norx_decrypt_lastblock
static NORX_INLINE void norx_decrypt_lastblock(norx_state_t state, uint8_t *out, const uint8_t * in, size_t inlen)
{
norx_word_t * S = state->S;
uint8_t b[BYTES(NORX_W)];
size_t i, j;
norx_inject_tag(state, PAYLOAD_TAG);
norx_permutation(state);
/* Undo padding */
S[inlen / BYTES(NORX_W)] ^= 0x01ULL << ((inlen % BYTES(NORX_W)) * 8);
S[WORDS(RATE) - 1] ^= 0x80ULL << (((BYTES(RATE) - 1) % BYTES(NORX_W)) * 8);
for(i = 0; inlen >= BYTES(NORX_W); ++i)
{
norx_word_t c = LOAD(in);
STORE(out, S[i] ^ c);
S[i] = c;
inlen -= BYTES(NORX_W);
in += BYTES(NORX_W);
out += BYTES(NORX_W);
}
STORE(b, S[i]);
for(j = 0; j < inlen; ++j)
{
uint8_t c = in[j];
out[j] = b[j] ^ c;
b[j] = c;
}
S[i] = LOAD(b);
}
示例14: format_my_state
int
format_my_state(unsigned char *buf, int buflen)
{
int i = 0, j, k;
for(j = 0; j < numneighs; j++) {
CHECK(12);
SHORT(8);
SHORT(12);
BYTES(neighs[j].id, 4);
LONG(neighs[j].eid);
LONG(neighs[j].interface->ifindex);
PAD();
}
CHECK(11);
SHORT(32);
SHORT(12);
SHORT(0x100);
SHORT(0);
BYTES("SHNCPD/0", 8);
PAD();
for(j = 0; j < numinterfaces; j++) {
for(k = 0; k < interfaces[j].numassigned; k++) {
const struct assigned_prefix *aa = &interfaces[j].assigned[k];
int pbytes = (aa->assigned.plen + 7) / 8;
if(aa->published) {
assert(aa->assigned.plen > 0);
CHECK(10 + pbytes);
SHORT(35);
SHORT(6 + pbytes);
LONG(interfaces[j].ifindex);
BYTE((aa->assigned.prio & 0x0F));
BYTE(aa->assigned.plen);
BYTES(&aa->assigned.p, pbytes);
PAD();
}
if(!IN6_IS_ADDR_UNSPECIFIED(&aa->assigned_address)) {
CHECK(24);
SHORT(36);
SHORT(20);
LONG(interfaces[j].ifindex);
BYTES(&aa->assigned_address, 16);
PAD();
}
}
}
return i;
fail:
return -1;
}
示例15: mrs_absorb_data
void mrs_absorb_data(mrs_state_t state, const unsigned char * in, size_t inlen)
{
while (inlen >= BYTES(MRS_B))
{
mrs_absorb_block(state, in);
inlen -= BYTES(MRS_B);
in += BYTES(MRS_B);
}
if(inlen > 0) {
mrs_absorb_lastblock(state, in, inlen);
}
}