bi_ptr compute_parameterized_gamma(int k, TSS_DAA_PK_internal *issuer_pk) {
	int length;
	int hashLength = bi_nbin_size( issuer_pk->gamma) + sizeof(int);
	BYTE *hash;
	int big_indian_k = htonl( k);
	BYTE *bytes;
	bi_ptr value, result;

	hash = (BYTE *)malloc( hashLength);
	if (hash == NULL) {
		LogError("malloc of %d bytes failed", hashLength);
		return NULL;
	}
	// hash[0-3] = big_indian(k)
	memcpy( hash, &big_indian_k, sizeof(int));
	// hash[4-end] = issuer_pk->gamma
	bi_2_nbin1( &length, &hash[sizeof(int)], issuer_pk->gamma);
	// allocation
	bytes = compute_bytes( hashLength, hash,
				DAA_PARAM_LENGTH_MFG1_GAMMA,
				DAA_PARAM_get_message_digest());
	if( bytes == NULL) return NULL;
	// allocation
	value = bi_set_as_nbin( DAA_PARAM_LENGTH_MFG1_GAMMA, bytes);
	if( value == NULL) return NULL;
	result = project_into_group_gamma( value, issuer_pk); // allocation
	if (result == NULL) {
		LogError("malloc of %d bytes failed", hashLength);
		return NULL;
	}
	bi_free_ptr( value);
	free( bytes);
	return result;
}
Example #2
0
YogVal
YogEncoding_conv_from_yog(YogEnv* env, YogHandle* self, YogHandle* s)
{
    uint_t bytes_num = compute_bytes(env, self, s);
    YogVal bin = YogBinary_of_size(env, bytes_num + 1);
    char* begin = BINARY_CSTR(bin);
    char* pc = begin;
    uint_t size = STRING_SIZE(HDL2VAL(s));
    uint_t i;
    for (i = 0; i < size; i++) {
        YogConvCharFromYog conv = HDL_AS(YogEncoding, self)->conv_char_from_yog;
        pc += conv(env, self, STRING_CHARS(HDL2VAL(s))[i], pc);
    }
    *pc = '\0';
    BINARY_SIZE(bin) = pc - begin + 1;

    return bin;
}
bi_ptr compute_zeta( int nameLength, unsigned char *name, TSS_DAA_PK_internal *issuer_pk) {
	BYTE *bytes;
	bi_ptr base;
	bi_ptr result;

	LogDebug("compute_zeta: %d [%s] pk:%x", nameLength, name, (int)issuer_pk);
	bytes = compute_bytes( nameLength,
				name,
				DAA_PARAM_LENGTH_MFG1_GAMMA,
				DAA_PARAM_get_message_digest());
	if( bytes == NULL) return NULL;
	base = bi_set_as_nbin( DAA_PARAM_LENGTH_MFG1_GAMMA, bytes);
	if( base == NULL) return NULL;
	LogDebug("base: %ld [%s]", bi_nbin_size( base), bi_2_hex_char( base));
	result = project_into_group_gamma( base, issuer_pk);
	if( result == NULL) return NULL;
	bi_free_ptr( base);
	free( bytes);
	LogDebug("return zeta:%s\n", bi_2_hex_char( result));
	return result;
}
Example #4
0
 static size_t compute_count(long chip_size) {
     long bytes = compute_bytes(chip_size);
     long real_count = (bytes - OVERHEAD)/chip_size;
     return std::min<long>(MAX_CHIPS, real_count);
 }