code stringlengths 31 2.05k | label_name stringclasses 5
values | label int64 0 4 |
|---|---|---|
void fp8_read_bin(fp8_t a, const uint8_t *bin, int len) {
if (len != 8 * RLC_FP_BYTES) {
RLC_THROW(ERR_NO_BUFFER);
return;
}
fp4_read_bin(a[0], bin, 4 * RLC_FP_BYTES);
fp4_read_bin(a[1], bin + 4 * RLC_FP_BYTES, 4 * RLC_FP_BYTES);
} | Base | 1 |
void fp18_read_bin(fp18_t a, const uint8_t *bin, int len) {
if (len != 18 * RLC_FP_BYTES) {
RLC_THROW(ERR_NO_BUFFER);
return;
}
fp9_read_bin(a[0], bin, 9 * RLC_FP_BYTES);
fp9_read_bin(a[1], bin + 9 * RLC_FP_BYTES, 9 * RLC_FP_BYTES);
} | Base | 1 |
void fp48_read_bin(fp48_t a, const uint8_t *bin, int len) {
if (len != 32 * RLC_FP_BYTES && len != 48 * RLC_FP_BYTES) {
RLC_THROW(ERR_NO_BUFFER);
return;
}
if (len == 32 * RLC_FP_BYTES) {
fp8_zero(a[0][0]);
fp8_read_bin(a[0][1], bin, 8 * RLC_FP_BYTES);
fp8_read_bin(a[0][2], bin + 8 * RLC_FP_BYTES, 8 * RLC_... | Base | 1 |
void fp54_write_bin(uint8_t *bin, int len, const fp54_t a, int pack) {
fp54_t t;
fp54_null(t);
RLC_TRY {
fp54_new(t);
if (pack) {
if (len != 36 * RLC_FP_BYTES) {
RLC_THROW(ERR_NO_BUFFER);
}
fp54_pck(t, a);
fp9_write_bin(bin, 9 * RLC_FP_BYTES, a[1][0]);
fp9_write_bin(bin + 9 * RLC_FP_BYTES, ... | Base | 1 |
void fp3_read_bin(fp3_t a, const uint8_t *bin, int len) {
if (len != 3 * RLC_FP_BYTES) {
RLC_THROW(ERR_NO_BUFFER);
return;
}
fp_read_bin(a[0], bin, RLC_FP_BYTES);
fp_read_bin(a[1], bin + RLC_FP_BYTES, RLC_FP_BYTES);
fp_read_bin(a[2], bin + 2 * RLC_FP_BYTES, RLC_FP_BYTES);
} | Base | 1 |
void fp3_write_bin(uint8_t *bin, int len, const fp3_t a) {
if (len != 3 * RLC_FP_BYTES) {
RLC_THROW(ERR_NO_BUFFER);
return;
}
fp_write_bin(bin, RLC_FP_BYTES, a[0]);
fp_write_bin(bin + RLC_FP_BYTES, RLC_FP_BYTES, a[1]);
fp_write_bin(bin + 2 * RLC_FP_BYTES, RLC_FP_BYTES, a[2]);
} | Base | 1 |
void md_map_b2s256(uint8_t *hash, const uint8_t *msg, int len) {
memset(hash, 0, RLC_MD_LEN_B2S256);
blake2s(hash, RLC_MD_LEN_B2S256, msg, len, NULL, 0);
} | Base | 1 |
void md_map_b2s160(uint8_t *hash, const uint8_t *msg, int len) {
memset(hash, 0, RLC_MD_LEN_B2S160);
blake2s(hash, RLC_MD_LEN_B2S160, msg, len, NULL, 0);
} | Base | 1 |
void md_hmac(uint8_t *mac, const uint8_t *in, int in_len, const uint8_t *key,
int key_len) {
#if MD_MAP == SH224 || MD_MAP == SH256 || MD_MAP == B2S160 || MD_MAP == B2S256
#define block_size 64
#elif MD_MAP == SH384 || MD_MAP == SH512
#define block_size 128
#endif
uint8_t opad[block_size + RLC_MD_LEN];
... | Base | 1 |
void md_kdf(uint8_t *key, int key_len, const uint8_t *in,
int in_len) {
uint32_t i, j, d;
uint8_t* buffer = RLC_ALLOCA(uint8_t, in_len + sizeof(uint32_t));
uint8_t* t = RLC_ALLOCA(uint8_t, key_len + RLC_MD_LEN);
if (buffer == NULL || t == NULL) {
RLC_FREE(buffer);
RLC_FREE(t);
RLC_THROW(ERR_NO_MEMORY);
re... | Base | 1 |
void md_mgf(uint8_t *key, int key_len, const uint8_t *in,
int in_len) {
uint32_t i, j, d;
uint8_t *buffer = RLC_ALLOCA(uint8_t, in_len + sizeof(uint32_t));
uint8_t *t = RLC_ALLOCA(uint8_t, key_len + RLC_MD_LEN);
if (buffer == NULL || t == NULL) {
RLC_FREE(buffer);
RLC_FREE(t);
RLC_THROW(ERR_NO_MEMORY);
r... | Base | 1 |
void md_map_sh224(uint8_t *hash, const uint8_t *msg, int len) {
SHA224Context ctx;
if (SHA224Reset(&ctx) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA224Input(&ctx, msg, len) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA224Result(&ctx, hash) != shaSuccess) {
RLC_THROW(ERR_NO... | Base | 1 |
void md_map_sh256(uint8_t *hash, const uint8_t *msg, int len) {
SHA256Context ctx;
if (SHA256Reset(&ctx) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA256Input(&ctx, msg, len) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA256Result(&ctx, hash) != shaSuccess) {
RLC_THROW(ERR_NO... | Base | 1 |
void md_map_sh384(uint8_t *hash, const uint8_t *msg, int len) {
SHA384Context ctx;
if (SHA384Reset(&ctx) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA384Input(&ctx, msg, len) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA384Result(&ctx, hash) != shaSuccess) {
RLC_THROW(ERR_NO... | Base | 1 |
void md_map_sh512(uint8_t *hash, const uint8_t *msg, int len) {
SHA512Context ctx;
if (SHA512Reset(&ctx) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA512Input(&ctx, msg, len) != shaSuccess) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (SHA512Result(&ctx, hash) != shaSuccess) {
RLC_THROW(ERR_NO... | Base | 1 |
static void pp_mil_k12(fp12_t r, ep2_t *t, ep2_t *q, ep_t *p, int m, bn_t a) {
fp12_t l;
ep_t *_p = RLC_ALLOCA(ep_t, m);
ep2_t *_q = RLC_ALLOCA(ep2_t, m);
int i, j, len = bn_bits(a) + 1;
int8_t s[RLC_FP_BITS + 1];
if (m == 0) {
return;
}
fp12_null(l);
RLC_TRY {
fp12_new(l);
if (_p == NULL || _q == NUL... | Base | 1 |
static void pp_mil_k24(fp24_t r, ep4_t *t, ep4_t *q, ep_t *p, int m, bn_t a) {
fp24_t l;
ep_t *_p = RLC_ALLOCA(ep_t, m);
ep4_t *_q = RLC_ALLOCA(ep4_t, m);
int i, j, len = bn_bits(a) + 1;
int8_t s[RLC_FP_BITS + 1];
if (m == 0) {
return;
}
fp24_null(l);
RLC_TRY {
fp24_new(l);
if (_p == NULL || _q == NUL... | Base | 1 |
static void pp_mil_k48(fp48_t r, const fp8_t qx, const fp8_t qy, const ep_t p,
const bn_t a) {
fp48_t l;
ep_t _p;
fp8_t rx, ry, rz, qn;
int i, len = bn_bits(a) + 1;
int8_t s[RLC_FP_BITS + 1];
fp48_null(l);
ep_null(_p);
fp8_null(rx);
fp8_null(ry);
fp8_null(rz);
fp8_null(qn);
RLC_TRY {
fp48_new(l);
ep... | Base | 1 |
static void pp_mil_k8(fp8_t r, ep2_t *t, ep2_t *q, ep_t *p, int m, bn_t a) {
fp8_t l;
ep_t *_p = RLC_ALLOCA(ep_t, m);
ep2_t *_q = RLC_ALLOCA(ep2_t, m);
int i, j, len = bn_bits(a) + 1;
int8_t s[RLC_FP_BITS + 1];
if (m == 0) {
return;
}
fp8_null(l);
RLC_TRY {
fp8_new(l);
if (_p == NULL || _q == NULL) {
... | Base | 1 |
int rand_check(uint8_t *buf, int size) {
int count = 0;
for (int i = 1; i < size; i++) {
if (buf[i] == buf[i - 1]) {
count++;
} else {
count = 0;
}
}
if (count > RAND_REP) {
return RLC_ERR;
}
return RLC_OK;
} | Base | 1 |
static int rand_inc(uint8_t *data, int size, int digit) {
int carry = digit;
for (int i = size - 1; i >= 0; i--) {
int16_t s;
s = (data[i] + carry);
data[i] = s & 0xFF;
carry = s >> 8;
}
return carry;
} | Base | 1 |
static void rand_gen(uint8_t *out, int out_len) {
int m = RLC_CEIL(out_len, RLC_MD_LEN);
uint8_t hash[RLC_MD_LEN], data[(RLC_RAND_SIZE - 1)/2];
ctx_t *ctx = core_get();
/* data = V */
memcpy(data, ctx->rand + 1, (RLC_RAND_SIZE - 1)/2);
for (int i = 0; i < m; i++) {
/* w_i = Hash(data) */
md_map(hash, data, s... | Base | 1 |
void rand_bytes(uint8_t *buf, int size) {
uint8_t hash[RLC_MD_LEN];
int carry, len = (RLC_RAND_SIZE - 1)/2;
ctx_t *ctx = core_get();
if (sizeof(int) > 2 && size > (1 << 16)) {
RLC_THROW(ERR_NO_VALID);
return;
}
/* buf = hash_gen(size) */
rand_gen(buf, size);
/* H = hash(03 || V) */
ctx->rand[0] = 0x3;
... | Base | 1 |
static int rand_add(uint8_t *state, uint8_t *hash, int size) {
int carry = 0;
for (int i = size - 1; i >= 0; i--) {
/* Make sure carries are detected. */
int16_t s;
s = (state[i] + hash[i] + carry);
state[i] = s & 0xFF;
carry = s >> 8;
}
return carry;
} | Base | 1 |
static void rand_hash(uint8_t *out, int out_len, uint8_t *in, int in_len) {
uint32_t j = util_conv_big(8 * out_len);
int len = RLC_CEIL(out_len, RLC_MD_LEN);
uint8_t* buf = RLC_ALLOCA(uint8_t, 1 + sizeof(uint32_t) + in_len);
uint8_t hash[RLC_MD_LEN];
if (buf == NULL) {
RLC_THROW(ERR_NO_MEMORY);
return;
}
b... | Base | 1 |
void rand_seed(uint8_t *buf, int size) {
ctx_t *ctx = core_get();
int len = (RLC_RAND_SIZE - 1) / 2;
if (size <= 0) {
RLC_THROW(ERR_NO_VALID);
return;
}
if (sizeof(int) > 4 && size > (1 << 32)) {
RLC_THROW(ERR_NO_VALID);
return;
}
ctx->rand[0] = 0x0;
if (ctx->seeded == 0) {
/* V = hash_df(seed). */... | Base | 1 |
int util_bits_dig(dig_t a) {
return RLC_DIG - arch_lzcnt(a);
} | Base | 1 |
static int square_root(void) {
int bits, code = RLC_ERR;
bn_t a, b, c;
bn_null(a);
bn_null(b);
bn_null(c);
RLC_TRY {
bn_new(a);
bn_new(b);
bn_new(c);
TEST_ONCE("square root extraction is correct") {
for (bits = 0; bits < RLC_BN_BITS / 2; bits++) {
bn_rand(a, RLC_POS, bits);
bn_sqr(c, a);
... | Base | 1 |
int util(void) {
int l, code = RLC_ERR;
gt_t a, b, c;
uint8_t bin[24 * RLC_PC_BYTES];
gt_null(a);
gt_null(b);
gt_null(c);
RLC_TRY {
gt_new(a);
gt_new(b);
gt_new(c);
TEST_CASE("comparison is consistent") {
gt_rand(a);
gt_rand(b);
TEST_ASSERT(gt_cmp(a, b) != RLC_EQ, end);
}
TEST_END;
TES... | Base | 1 |
static int test(void) {
uint8_t out[64];
int len = sizeof(out) / 2, code = RLC_ERR;
TEST_ONCE("rdrand hardware generator is non-trivial") {
memset(out, 0, 2 * len);
rand_bytes(out, len);
/* This fails with negligible probability. */
TEST_ASSERT(memcmp(out, out + len, len) != 0, end);
}
TEST_END;
code = ... | Base | 1 |
static int action_getconfig(struct mansession *s, const struct message *m)
{
struct ast_config *cfg;
const char *fn = astman_get_header(m, "Filename");
const char *category = astman_get_header(m, "Category");
const char *filter = astman_get_header(m, "Filter");
const char *category_name;
int catcount = 0;
int li... | Base | 1 |
static int restrictedFile(const char *filename)
{
if (!live_dangerously && !strncasecmp(filename, "/", 1) &&
strncasecmp(filename, ast_config_AST_CONFIG_DIR, strlen(ast_config_AST_CONFIG_DIR))) {
return 1;
}
return 0;
} | Base | 1 |
OE_INLINE void _handle_oret(
oe_sgx_td_t* td,
uint16_t func,
uint16_t result,
uint64_t arg)
{
oe_callsite_t* callsite = td->callsites;
if (!callsite)
return;
td->oret_func = func;
td->oret_result = result;
td->oret_arg = arg;
/* Restore the FXSTATE and flags */
asm... | Class | 2 |
void _reset_fxsave_state()
{
/* Initialize the FXSAVE state values to Linux x86-64 ABI defined values:
* FCW = 0x037F, MXCSR = 0x1F80, MXCSR mask = 0xFFFF */
static OE_ALIGNED(OE_FXSAVE_ALIGNMENT) const uint64_t
_initial_fxstate[OE_FXSAVE_AREA_SIZE / sizeof(uint64_t)] = {
0x037F, 0, 0, ... | Class | 2 |
JSON_read(int fd)
{
uint32_t hsize, nsize;
char *str;
cJSON *json = NULL;
int rc;
/*
* Read a four-byte integer, which is the length of the JSON to follow.
* Then read the JSON into a buffer and parse it. Return a parsed JSON
* structure, NULL if there was an error.
*/
if (... | Base | 1 |
static BOOL nsc_rle_decode(BYTE* in, BYTE* out, UINT32 outSize, UINT32 originalSize)
{
UINT32 left = originalSize;
while (left > 4)
{
const BYTE value = *in++;
UINT32 len = 0;
if (left == 5)
{
if (outSize < 1)
return FALSE;
outSize--;
*out++ = value;
left--;
}
else if (value == *in)
... | Base | 1 |
static BOOL nsc_rle_decompress_data(NSC_CONTEXT* context)
{
if (!context)
return FALSE;
BYTE* rle = context->Planes;
WINPR_ASSERT(rle);
for (size_t i = 0; i < 4; i++)
{
const UINT32 originalSize = context->OrgByteCount[i];
const UINT32 planeSize = context->PlaneByteCount[i];
if (planeSize == 0)
{
i... | Base | 1 |
_blackbox_vlogger(int32_t target,
struct qb_log_callsite *cs, struct timespec *timestamp, va_list ap)
{
size_t max_size;
size_t actual_size;
uint32_t fn_size;
char *chunk;
char *msg_len_pt;
uint32_t msg_len;
struct qb_log_target *t = qb_log_target_get(target);
if (t->instance == NULL) {
return;
}
fn_s... | Base | 1 |
START_TEST(test_log_long_msg)
{
int lpc;
int rc;
int i, max = 1000;
char *buffer = calloc(1, max);
qb_log_init("test", LOG_USER, LOG_DEBUG);
rc = qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE);
ck_assert_int_eq(rc, 0);
rc = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_SIZE, 1024);
ck_assert_int_eq(rc, 0)... | Base | 1 |
consume_count(type)
const char **type;
{
int count = 0;
if (!isdigit((unsigned char)**type))
return -1;
while (isdigit((unsigned char)**type)) {
count *= 10;
/* Check for overflow.
We assume that count is represented using two's-complement;
no power of two is divisible by ten, so if an overflow... | Base | 1 |
int h1_parse_cont_len_header(struct h1m *h1m, struct ist *value)
{
char *e, *n;
long long cl;
int not_first = !!(h1m->flags & H1_MF_CLEN);
struct ist word;
word.ptr = value->ptr - 1; // -1 for next loop's pre-increment
e = value->ptr + value->len;
while (++word.ptr < e) {
/* skip leading delimiter and blanks... | Base | 1 |
void client_reset(t_client *client)
{
char *hash;
char *msg;
char *cidinfo;
debug(LOG_DEBUG, "Resetting client [%s]", client->mac);
// Reset traffic counters
client->counters.incoming = 0;
client->counters.outgoing = 0;
client->counters.last_updated = time(NULL);
// Reset session time
client->session_start ... | Variant | 0 |
static int redirect_to_splashpage(struct MHD_Connection *connection, t_client *client, const char *host, const char *url)
{
char *originurl_raw;
char *originurl;
char *query;
int ret = 0;
const char *separator = "&";
char *querystr;
query = safe_calloc(QUERYMAXLEN);
if (!query) {
ret = send_error(connection... | Variant | 0 |
void crypto_bignum_free(struct bignum *a)
{
if (a)
panic();
} | Variant | 0 |
static TEE_Result do_allocate_keypair(struct dh_keypair *key, size_t size_bits)
{
DH_TRACE("Allocate Keypair of %zu bits", size_bits);
/* Initialize the key fields to NULL */
memset(key, 0, sizeof(*key));
/* Allocate Generator Scalar */
key->g = crypto_bignum_allocate(size_bits);
if (!key->g)
goto err;
/* A... | Variant | 0 |
static TEE_Result do_allocate_publickey(struct dsa_public_key *key,
size_t l_bits, size_t n_bits)
{
DSA_TRACE("DSA Allocate Public of L=%zu bits and N=%zu bits", l_bits,
n_bits);
/* Initialize the key fields to NULL */
memset(key, 0, sizeof(*key));
/* Allocate Generator Scalar */
key->g = crypto_bignum_... | Variant | 0 |
static TEE_Result do_allocate_keypair(struct dsa_keypair *key, size_t l_bits,
size_t n_bits)
{
DSA_TRACE("DSA allocate Keypair of L=%zu bits and N=%zu bits", l_bits,
n_bits);
/* Initialize the key fields to NULL */
memset(key, 0, sizeof(*key));
/* Allocate Generator Scalar */
key->g = crypto_bignum... | Variant | 0 |
static TEE_Result do_allocate_publickey(struct ecc_public_key *key,
uint32_t type __unused,
size_t size_bits)
{
ECC_TRACE("Allocate Public Key of %zu bits", size_bits);
/* Initialize the key fields to NULL */
memset(key, 0, sizeof(*key));
/* Allocate Public coordinate X */
key->x = crypto_bignum_alloca... | Variant | 0 |
static void do_free_publickey(struct ecc_public_key *key)
{
crypto_bignum_free(key->x);
crypto_bignum_free(key->y);
} | Variant | 0 |
static TEE_Result do_allocate_keypair(struct ecc_keypair *key,
uint32_t type __unused,
size_t size_bits)
{
ECC_TRACE("Allocate Keypair of %zu bits", size_bits);
/* Initialize the key fields to NULL */
memset(key, 0, sizeof(*key));
/* Allocate Secure Scalar */
key->d = crypto_bignum_allocate(s... | Variant | 0 |
static void do_free_keypair(struct rsa_keypair *key)
{
crypto_bignum_free(key->e);
crypto_bignum_free(key->d);
crypto_bignum_free(key->n);
crypto_bignum_free(key->p);
crypto_bignum_free(key->q);
crypto_bignum_free(key->qp);
crypto_bignum_free(key->dp);
crypto_bignum_free(key->dq);
} | Variant | 0 |
static void do_free_publickey(struct rsa_public_key *key)
{
crypto_bignum_free(key->e);
crypto_bignum_free(key->n);
} | Variant | 0 |
static TEE_Result do_allocate_publickey(struct rsa_public_key *key,
size_t size_bits)
{
RSA_TRACE("Allocate Public Key of %zu bits", size_bits);
/* Initialize all input key fields to 0 */
memset(key, 0, sizeof(*key));
/* Allocate the Public Exponent to maximum size */
key->e = crypto_bignum_allocate(MAX_BIT... | Variant | 0 |
static void do_free_publickey(struct ecc_public_key *s)
{
if (!s)
return;
crypto_bignum_free(s->x);
crypto_bignum_free(s->y);
} | Variant | 0 |
static TEE_Result do_alloc_publickey(struct ecc_public_key *s, uint32_t type,
size_t size_bits __unused)
{
/* This driver only supports ECDH/ECDSA */
if (type != TEE_TYPE_ECDSA_PUBLIC_KEY &&
type != TEE_TYPE_ECDH_PUBLIC_KEY)
return TEE_ERROR_NOT_IMPLEMENTED;
memset(s, 0, sizeof(*s));
if (!bn_alloc_... | Variant | 0 |
static TEE_Result do_alloc_keypair(struct ecc_keypair *s, uint32_t type,
size_t size_bits __unused)
{
/* This driver only supports ECDH/ECDSA */
if (type != TEE_TYPE_ECDSA_KEYPAIR &&
type != TEE_TYPE_ECDH_KEYPAIR)
return TEE_ERROR_NOT_IMPLEMENTED;
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->d))
... | Variant | 0 |
static TEE_Result do_alloc_keypair(struct rsa_keypair *s,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->e))
return TEE_ERROR_OUT_OF_MEMORY;
if (!bn_alloc_max(&s->d))
goto err;
if (!bn_alloc_max(&s->n))
goto err;
if (!bn_alloc_max(&s->p))
goto err;
if (!bn_alloc_ma... | Variant | 0 |
static void do_free_publickey(struct rsa_public_key *s)
{
if (s) {
crypto_bignum_free(s->n);
crypto_bignum_free(s->e);
}
} | Variant | 0 |
static void do_free_keypair(struct rsa_keypair *s)
{
sss_status_t st = kStatus_SSS_Fail;
sss_se05x_object_t k_object = { };
uint32_t key_id = 0;
if (!s)
return;
key_id = se050_rsa_keypair_from_nvm(s);
if (key_id) {
st = sss_se05x_key_object_get_handle(&k_object, key_id);
if (st == kStatus_SSS_Success)
... | Variant | 0 |
static TEE_Result do_alloc_publickey(struct rsa_public_key *s,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->e))
return TEE_ERROR_OUT_OF_MEMORY;
if (!bn_alloc_max(&s->n)) {
crypto_bignum_free(s->e);
return TEE_ERROR_OUT_OF_MEMORY;
}
return TEE_SUCCESS;
} | Variant | 0 |
TEE_Result crypto_acipher_alloc_dh_keypair(struct dh_keypair *s,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->g))
return TEE_ERROR_OUT_OF_MEMORY;
if (!bn_alloc_max(&s->p))
goto err;
if (!bn_alloc_max(&s->y))
goto err;
if (!bn_alloc_max(&s->x))
goto err;
if (!bn_... | Variant | 0 |
TEE_Result crypto_acipher_alloc_dsa_public_key(struct dsa_public_key *s,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->g))
return TEE_ERROR_OUT_OF_MEMORY;
if (!bn_alloc_max(&s->p))
goto err;
if (!bn_alloc_max(&s->q))
goto err;
if (!bn_alloc_max(&s->y))
goto e... | Variant | 0 |
TEE_Result crypto_acipher_alloc_dsa_keypair(struct dsa_keypair *s,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->g))
return TEE_ERROR_OUT_OF_MEMORY;
if (!bn_alloc_max(&s->p))
goto err;
if (!bn_alloc_max(&s->q))
goto err;
if (!bn_alloc_max(&s->y))
goto err;
if (... | Variant | 0 |
TEE_Result crypto_asym_alloc_ecc_public_key(struct ecc_public_key *s,
uint32_t key_type,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
switch (key_type) {
case TEE_TYPE_ECDSA_PUBLIC_KEY:
case TEE_TYPE_ECDH_PUBLIC_KEY:
s->ops = &ecc_public_key_ops;
break;
case TEE_TYPE_SM2_DSA_PU... | Variant | 0 |
TEE_Result crypto_asym_alloc_ecc_keypair(struct ecc_keypair *s,
uint32_t key_type,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
switch (key_type) {
case TEE_TYPE_ECDSA_KEYPAIR:
case TEE_TYPE_ECDH_KEYPAIR:
s->ops = &ecc_keypair_ops;
break;
case TEE_TYPE_SM2_DSA_KEYPAIR:
if (!IS_ENAB... | Variant | 0 |
static void _ltc_ecc_free_public_key(struct ecc_public_key *s)
{
if (!s)
return;
crypto_bignum_free(s->x);
crypto_bignum_free(s->y);
} | Variant | 0 |
void crypto_bignum_free(struct bignum *s)
{
mbedtls_mpi_free((mbedtls_mpi *)s);
free(s);
} | Variant | 0 |
TEE_Result sw_crypto_acipher_alloc_rsa_public_key(struct rsa_public_key *s,
size_t key_size_bits __unused)
{
memset(s, 0, sizeof(*s));
if (!bn_alloc_max(&s->e))
return TEE_ERROR_OUT_OF_MEMORY;
if (!bn_alloc_max(&s->n))
goto err;
return TEE_SUCCESS;
err:
crypto_bignum_free(s->e);
return TEE_ERROR_OUT_O... | Variant | 0 |
void sw_crypto_acipher_free_rsa_public_key(struct rsa_public_key *s)
{
if (!s)
return;
crypto_bignum_free(s->n);
crypto_bignum_free(s->e);
} | Variant | 0 |
void sw_crypto_acipher_free_rsa_keypair(struct rsa_keypair *s)
{
if (!s)
return;
crypto_bignum_free(s->e);
crypto_bignum_free(s->d);
crypto_bignum_free(s->n);
crypto_bignum_free(s->p);
crypto_bignum_free(s->q);
crypto_bignum_free(s->qp);
crypto_bignum_free(s->dp);
crypto_bignum_free(s->dq);
} | Variant | 0 |
static void op_attr_bignum_free(void *attr)
{
struct bignum **bn = attr;
crypto_bignum_free(*bn);
*bn = NULL;
} | Variant | 0 |
void crypto_bignum_free(struct bignum *s)
{
mbedtls_mpi_free((mbedtls_mpi *)s);
free(s);
} | Variant | 0 |
TEE_Result crypto_acipher_alloc_dh_keypair(struct dh_keypair *s,
size_t key_size_bits)
{
memset(s, 0, sizeof(*s));
s->g = crypto_bignum_allocate(key_size_bits);
if (!s->g)
goto err;
s->p = crypto_bignum_allocate(key_size_bits);
if (!s->p)
goto err;
s->y = crypto_bignum_allocate(key_size_bits);
if (!s... | Variant | 0 |
TEE_Result crypto_asym_alloc_ecc_keypair(struct ecc_keypair *s,
uint32_t key_type,
size_t key_size_bits)
{
memset(s, 0, sizeof(*s));
switch (key_type) {
case TEE_TYPE_ECDSA_KEYPAIR:
case TEE_TYPE_ECDH_KEYPAIR:
s->ops = &ecc_keypair_ops;
break;
case TEE_TYPE_SM2_DSA_KEYPAIR:
if (!IS_ENABLED(CFG_C... | Variant | 0 |
static void ecc_free_public_key(struct ecc_public_key *s)
{
if (!s)
return;
crypto_bignum_free(s->x);
crypto_bignum_free(s->y);
} | Variant | 0 |
TEE_Result crypto_asym_alloc_ecc_public_key(struct ecc_public_key *s,
uint32_t key_type,
size_t key_size_bits)
{
memset(s, 0, sizeof(*s));
switch (key_type) {
case TEE_TYPE_ECDSA_PUBLIC_KEY:
case TEE_TYPE_ECDH_PUBLIC_KEY:
s->ops = &ecc_public_key_ops;
break;
case TEE_TYPE_SM2_DSA_PUBLIC_KEY:... | Variant | 0 |
void sw_crypto_acipher_free_rsa_public_key(struct rsa_public_key *s)
{
if (!s)
return;
crypto_bignum_free(s->n);
crypto_bignum_free(s->e);
} | Variant | 0 |
TEE_Result sw_crypto_acipher_alloc_rsa_public_key(struct rsa_public_key *s,
size_t key_size_bits)
{
memset(s, 0, sizeof(*s));
s->e = crypto_bignum_allocate(key_size_bits);
if (!s->e)
return TEE_ERROR_OUT_OF_MEMORY;
s->n = crypto_bignum_allocate(key_size_bits);
if (!s->n)
goto err;
return TEE_SUCCESS;
... | Variant | 0 |
void sw_crypto_acipher_free_rsa_keypair(struct rsa_keypair *s)
{
if (!s)
return;
crypto_bignum_free(s->e);
crypto_bignum_free(s->d);
crypto_bignum_free(s->n);
crypto_bignum_free(s->p);
crypto_bignum_free(s->q);
crypto_bignum_free(s->qp);
crypto_bignum_free(s->dp);
crypto_bignum_free(s->dq);
} | Variant | 0 |
int LiSendMouseButtonEvent(char action, int button) {
PPACKET_HOLDER holder;
int err;
if (!initialized) {
return -2;
}
holder = malloc(sizeof(*holder));
if (holder == NULL) {
return -1;
}
holder->packetLength = sizeof(NV_MOUSE_BUTTON_PACKET);
holder->packet.mouseBu... | Base | 1 |
int startInputStream(void) {
int err;
// After Gen 5, we send input on the control stream
if (ServerMajorVersion < 5) {
inputSock = connectTcpSocket(&RemoteAddr, RemoteAddrLen,
35043, INPUT_STREAM_TIMEOUT_SEC);
if (inputSock == INVALID_SOCKET) {
return LastSocketFail... | Base | 1 |
int LiSendScrollEvent(signed char scrollClicks) {
PPACKET_HOLDER holder;
int err;
if (!initialized) {
return -2;
}
holder = malloc(sizeof(*holder));
if (holder == NULL) {
return -1;
}
holder->packetLength = sizeof(NV_SCROLL_PACKET);
holder->packet.scroll.header.pac... | Base | 1 |
int LiSendMouseMoveEvent(short deltaX, short deltaY) {
PPACKET_HOLDER holder;
int err;
if (!initialized) {
return -2;
}
holder = malloc(sizeof(*holder));
if (holder == NULL) {
return -1;
}
holder->packetLength = sizeof(NV_MOUSE_MOVE_PACKET);
holder->packet.mouseMov... | Base | 1 |
static int transactRtspMessage(PRTSP_MESSAGE request, PRTSP_MESSAGE response, int expectingPayload, int* error) {
// Gen 5+ does RTSP over ENet not TCP
if (ServerMajorVersion >= 5) {
return transactRtspMessageEnet(request, response, expectingPayload, error);
}
else {
return transactRtspM... | Base | 1 |
static int setupStream(PRTSP_MESSAGE response, char* target, int* error) {
RTSP_MESSAGE request;
int ret;
char* transportValue;
*error = -1;
ret = initializeRtspRequest(&request, "SETUP", target);
if (ret != 0) {
if (hasSessionId) {
if (!addOption(&request, "Session", sessi... | Base | 1 |
static bool parseUrlAddrFromRtspUrlString(const char* rtspUrlString, char* destination) {
char* rtspUrlScratchBuffer;
char* portSeparator;
char* v6EscapeEndChar;
char* urlPathSeparator;
int prefixLen;
// Create a copy that we can modify
rtspUrlScratchBuffer = strdup(rtspUrlString);
if (... | Base | 1 |
void track_set_index(Track *track, int i, long ind)
{
if (i > MAXINDEX) {
fprintf(stderr, "too many indexes\n");
return;
}
track->index[i] = ind;
} | Base | 1 |
void InitCodec(const vpx_codec_iface_t &iface, int width, int height,
vpx_codec_ctx_t *enc, vpx_codec_enc_cfg_t *cfg) {
ASSERT_EQ(vpx_codec_enc_config_default(&iface, cfg, 0), VPX_CODEC_OK);
cfg->g_w = width;
cfg->g_h = height;
cfg->g_lag_in_frames = 0;
cfg->g_pass = VPX_RC_ONE_PASS;
ASSERT_E... | Base | 1 |
TEST(EncodeAPI, ConfigResizeChangeThreadCount) {
constexpr int kInitWidth = 1024;
constexpr int kInitHeight = 1024;
for (const auto *iface : kCodecIfaces) {
SCOPED_TRACE(vpx_codec_iface_name(iface));
if (!IsVP9(iface)) {
GTEST_SKIP() << "TODO(https://crbug.com/1486441) remove this condition "
... | Base | 1 |
int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
int new_mi_size;
vp9_set_mb_mi(cm, width, height);
new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
if (cm->mi_alloc_size < new_mi_size) {
cm->free_mi(cm);
if (cm->alloc_mi(cm, new_mi_size)) goto fail;
}
if (cm->seg_map... | Class | 2 |
int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
int new_mi_size;
vp9_set_mb_mi(cm, width, height);
new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
if (cm->mi_alloc_size < new_mi_size) {
cm->free_mi(cm);
if (cm->alloc_mi(cm, new_mi_size)) goto fail;
}
if (cm->seg_map... | Class | 2 |
static int handle_dot_dotdot_filename(struct exfat_de_iter *iter,
struct exfat_dentry *dentry,
int strm_name_len)
{
char *filename;
char error_msg[150];
int num;
if (!memcmp(dentry->name_unicode, MSDOS_DOT, strm_name_len * 2))
filename = ".";
else if (!memcmp(dentry->name_unicode, MSDOS_DOTD... | Base | 1 |
static int read_file_dentry_set(struct exfat_de_iter *iter,
struct exfat_inode **new_node, int *skip_dentries)
{
struct exfat_dentry *file_de, *stream_de, *dentry;
struct exfat_inode *node = NULL;
int i, ret;
ret = exfat_de_iter_get(iter, 0, &file_de);
if (ret || file_de->type != EXFAT_FILE) {
exfat_debug("... | Base | 1 |
static int ksu_sha256(const unsigned char *data, unsigned int datalen,
unsigned char *digest)
{
struct crypto_shash *alg;
char *hash_alg_name = "sha256";
int ret;
alg = crypto_alloc_shash(hash_alg_name, 0, 0);
if (IS_ERR(alg)) {
pr_info("can't alloc alg %s\n", hash_alg_name);
return PTR_ERR(alg);
}
ret = ... | Class | 2 |
static bool check_block(struct file *fp, u32 *size4, loff_t *pos, u32 *offset,
unsigned expected_size, const char* expected_sha256)
{
ksu_kernel_read_compat(fp, size4, 0x4, pos); // signer-sequence length
ksu_kernel_read_compat(fp, size4, 0x4, pos); // signer length
ksu_kernel_read_compat(fp, size4, 0x4, pos); //... | Class | 2 |
static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl)
{
uint32_t delta_poc_st, strp_entry_sign_flag = 0;
rpl->ref_pic_num = get_ue_golomb_long(gb);
if (rpl->ref_pic_num > 0) {
delta_poc_st = get_ue_golomb_long(gb);
rpl->ref_pics[0] = delta_poc_st;
if (rpl->ref_pic... | Base | 1 |
static int _process_request_metaflags(mcp_parser_t *pr, int token) {
if (pr->ntokens <= token) {
pr->t.meta.flags = 0; // no flags found.
return 0;
}
const char *cur = pr->request + pr->tokens[token];
const char *end = pr->request + pr->reqlen - 2;
// We blindly convert flags into b... | Base | 1 |
static int _process_tokenize(mcp_parser_t *pr, const size_t max) {
const char *s = pr->request;
int len = pr->reqlen - 2;
// since multigets can be huge, we can't purely judge reqlen against this
// limit, but we also can't index past it since the tokens are shorts.
if (len > PARSER_MAXLEN) {
... | Base | 1 |
size_t _process_request_next_key(mcp_parser_t *pr) {
const char *cur = pr->request + pr->parsed;
int remain = pr->reqlen - pr->parsed - 2;
// chew off any leading whitespace.
while (remain) {
if (*cur == ' ') {
remain--;
cur++;
pr->parsed++;
} else {
... | Base | 1 |
static void ClearMetadata(VP8LMetadata* const hdr) {
assert(hdr != NULL);
WebPSafeFree(hdr->huffman_image_);
WebPSafeFree(hdr->huffman_tables_);
VP8LHtreeGroupsFree(hdr->htree_groups_);
VP8LColorCacheClear(&hdr->color_cache_);
VP8LColorCacheClear(&hdr->saved_color_cache_);
InitMetadata(hdr);
} | Base | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.