• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ BYTES函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BYTES函数的典型用法代码示例。如果您正苦于以下问题:C++ BYTES函数的具体用法?C++ BYTES怎么用?C++ BYTES使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BYTES函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:0x64616E69656C,项目名称:norx,代码行数:26,代码来源:norx.c


示例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);
}
开发者ID:gvsurenderreddy,项目名称:shncpd,代码行数:26,代码来源:send.c


示例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
  }
}
开发者ID:miquelramirez,项目名称:UPMurphi,代码行数:63,代码来源:decl.cpp


示例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;
}
开发者ID:0x64616E69656C,项目名称:norx,代码行数:25,代码来源:norx.c


示例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;
}
开发者ID:0x64616E69656C,项目名称:norx,代码行数:26,代码来源:norx.c


示例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);
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:33,代码来源:mrs.c


示例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));
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:7,代码来源:mrs.c


示例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));
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:28,代码来源:mrs.c


示例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;
}
开发者ID:Vieteg,项目名称:EACirc,代码行数:7,代码来源:norx3261v1_norx.cpp


示例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;
}
开发者ID:0x64616E69656C,项目名称:supercop,代码行数:28,代码来源:norx.c


示例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);
}
开发者ID:0x64616E69656C,项目名称:supercop,代码行数:26,代码来源:norx.c


示例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));
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:8,代码来源:mrs.c


示例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);
}
开发者ID:Vieteg,项目名称:EACirc,代码行数:33,代码来源:norx3261v1_norx.cpp


示例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;
}
开发者ID:eqvinox,项目名称:shncpd,代码行数:54,代码来源:send.c


示例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);
    }
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:12,代码来源:mrs.c


示例16: mrs_decrypt_data

void mrs_decrypt_data(mrs_state_t state, unsigned char * out, const unsigned char * in, size_t inlen)
{
    while (inlen >= BYTES(MRS_R))
    {
        mrs_decrypt_block(state, out, in);
        inlen -= BYTES(MRS_R);
        in    += BYTES(MRS_R);
        out   += BYTES(MRS_R);
    }
    if(inlen > 0) {
        mrs_decrypt_lastblock(state, out, in, inlen);
    }
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:13,代码来源:mrs.c


示例17: norx_encrypt_block

static NORX_INLINE void norx_encrypt_block(norx_state_t state, uint8_t *out, const uint8_t * in)
{
    size_t i;
    norx_word_t * S = state->S;

    S[15] ^= PAYLOAD_TAG;
    norx_permute(state);

    for (i = 0; i < WORDS(NORX_R); ++i) {
        S[i] ^= LOAD(in + i * BYTES(NORX_W));
        STORE(out + i * BYTES(NORX_W), S[i]);
    }
}
开发者ID:0x64616E69656C,项目名称:supercop,代码行数:13,代码来源:norx.c


示例18: init_set

status init_set(set *p_S, int size)
{
  int numbytes, i;

  numbytes = (size + BYTESIZE - 1) / BYTESIZE;
  BYTES(p_S) = (char *) malloc(numbytes);
  if (BYTES(p_S) == NULL)
	return ERROR;

  SIZE(p_S) = numbytes * BYTESIZE;
  for (i=0; i<numbytes; i++)
	BYTES(p_S)[i] = 0;
  return OK;
}
开发者ID:cosyverif,项目名称:deb-greatspn,代码行数:14,代码来源:set-adt.c


示例19: norx_encrypt_msg

void norx_encrypt_msg(norx_state_t state, unsigned char *out, const unsigned char * in, size_t inlen)
{
    if(inlen > 0)
    {
        norx_state_t lane[NORX_D];
        uint8_t emptyblock[BYTES(RATE)];
        size_t i, j;

        /* Initialize states + branch */
        for(i = 0; i < NORX_D; ++i)
        {
            memcpy(lane[i], state, sizeof lane[i]);
            norx_branch(lane[i], i);
        }

        /* parallel payload processing */
        for(i = 0; inlen >= BYTES(RATE); ++i)
        {
            norx_encrypt_block(lane[i%NORX_D], out, in);
            inlen -= BYTES(RATE);
            out   += BYTES(RATE);
            in    += BYTES(RATE);
        }
        norx_encrypt_lastblock(lane[i++%NORX_D], out, in, inlen);

        /* Pad remaining blocks */
        norx_pad(emptyblock, emptyblock, 0);
        for(j = 0; j < (NORX_D-1); ++j, ++i)
        {
            norx_absorb(lane[i%NORX_D], emptyblock, PAYLOAD_TAG);
        }

        /* Merge */
        memset(state, 0, sizeof(norx_state_t));
        for(i = 0; i < NORX_D; ++i)
        {
#if defined(NORX_DEBUG)
            printf("End of payload processing (lane %lu) \n", i);
            norx_print_state(lane[i]);
#endif
            norx_merge(state, lane[i]);
            burn(lane[i], 0, sizeof(norx_state_t));
        }

#if defined(NORX_DEBUG)
        printf("End of merging:\n");
        norx_print_state(state);
#endif
    }
}
开发者ID:Vieteg,项目名称:EACirc,代码行数:50,代码来源:norx3261v1_norx.cpp


示例20: bufgrow

static void bufgrow (Buffer * b, int len)
{
    if (len > b->size)
    {
        b->mem = realloc (b->mem, BYTES (len));
        b->size = len;
    }

    if (len > b->len)
    {
        memset (OFFSET (b->mem, b->len), 0, BYTES (len - b->len));
        b->len = len;
    }
}
开发者ID:CBke,项目名称:audacious-plugins,代码行数:14,代码来源:speed-pitch.c



注:本文中的BYTES函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BYTE_TO_ASCII函数代码示例发布时间:2022-05-30
下一篇:
C++ BYTEARRAY函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap