int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received)
    {
    BIGNUM *t1 = BN_new();
    BIGNUM *t2 = BN_new();
    int ret = 0;

   /*
    * g' = g^{xc + xa + xb} [from our POV]
    * t1 = xa + xb
    */
    BN_mod_add(t1, ctx->xa, ctx->xb, ctx->p.q, ctx->ctx);
   /* t2 = g^{t1} = g^{xa+xb} */
    BN_mod_exp(t2, ctx->p.g, t1, ctx->p.p, ctx->ctx);
   /* t1 = g^{xc} * t2 = g^{xc + xa + xb} */
    BN_mod_mul(t1, ctx->p.gxc, t2, ctx->p.p, ctx->ctx);

    if(verify_zkp(received, t1, ctx))
	ret = 1;
    else
	JPAKEerr(JPAKE_F_JPAKE_STEP2_PROCESS, JPAKE_R_VERIFY_B_FAILED);

    compute_key(ctx, received->gx);

   /* cleanup */
    BN_free(t2);
    BN_free(t1);

    return ret;
    }
		inline buffer dh_key::compute_key(bn::bignum pub_key) const
		{
			buffer result(size());

			result.data().resize(compute_key(buffer_cast<uint8_t*>(result), buffer_size(result), pub_key.raw()));

			return result;
		}
/**
 * Generate an event id with specified type.
 *
 * @param seed1 Seed1.
 * @param seed2 Seed2, this parameter will be ignored if the value is NULL.
 * @param type The type of key. The length of generated id will be 20
 *		characters if type is KEY_SHORT; 32 characters if type is
 *		KEY_LONG.
 *
 * @return a pointer to result haskkey if successful, or NULL if not.
 */
char *generate_event_id(const char *seed1, size_t slen1, const char *seed2,
			size_t slen2, enum key_type type)
{
	int ret;
	char *buf;
	char *key;
	size_t klen;

	if (!seed1 || !slen1)
		return NULL;

	if (type == KEY_SHORT)
		klen = SHORT_KEY_LENGTH;
	else if (type == KEY_LONG)
		klen = LONG_KEY_LENGTH;
	else
		return NULL;

	key = (char *)malloc(klen + 1);
	if (!key) {
		LOGE("failed to generate event id, out of memory\n");
		return NULL;
	}

	if (seed2) {
		if (asprintf(&buf, "%s%s", seed1, seed2) == -1) {
			LOGE("failed to generate event id, out of memory\n");
			free(key);
			return NULL;
		}
		ret = compute_key(key, klen, (const char *)buf, slen1 + slen2);
		free(buf);
	} else {
		ret = compute_key(key, klen, seed1, slen1);
	}

	if (ret < 0) {
		LOGE("compute_key error\n");
		free(key);
		key = NULL;
	}

	return key;
}
Exemple #4
0
void IpAddress::set_from_string(char *sym_addr) {
  if(strchr(sym_addr, '.')) {
    addr.ipVersion = 4, addr.localHost = 0, addr.ipType.ipv4 = inet_addr(sym_addr);
  } else {
    if(inet_pton(AF_INET6, sym_addr, &addr.ipType.ipv6) <= 0) {
      /* We failed */
      addr.ipVersion = 4, addr.localHost = 0, addr.ipType.ipv4 = 0;
    } else {
      addr.ipVersion = 6, addr.localHost = 0;
    }
  }

  compute_key();
}
Exemple #5
0
void IpAddress::set(IpAddress *ip) {
  memcpy(&addr, &ip->addr, sizeof(struct ipAddress));
  ip_key = ip->ip_key;
  compute_key();
}
Exemple #6
0
IpAddress::IpAddress(struct ndpi_in6_addr *_ipv6) {
  ip_key = 0;
  set_ipv6(_ipv6);
  addr.privateIP = false;
  compute_key();
}
Exemple #7
0
IpAddress::IpAddress(u_int32_t _ipv4) {
  ip_key = 0;
  set_ipv4(_ipv4);
  compute_key();
}
Exemple #8
0
IpAddress::IpAddress(char *string) {
  ip_key = 0;
  set_from_string(string);
  compute_key();
}
Exemple #9
0
IpAddress::IpAddress() {
  ip_key = 0;
  memset(&addr, 0, sizeof(addr));
  compute_key();
}
bool EDPSimpleSUBListener::computeKey(CacheChange_t* change)
{
    CDRMessage_t aux_msg;
	return compute_key(&aux_msg,change);
}