Ejemplo n.º 1
0
static inline void parse_algo_hdr(struct hdr_field* algo_hdr, int* algo, int* b64_required)
{
	int rc;
	char* delim=NULL;

	str tok;
	str s_tok;

	s_tok.s = algo_hdr->body.s;
	s_tok.len = algo_hdr->body.len;

	do {
		delim = q_memchr(s_tok.s, ATTR_DELIM[0], s_tok.len);

		if (delim==NULL) {
			trim_spaces_lr(s_tok);
			rc = get_algo(&s_tok);
		} else {
			tok.s = s_tok.s;
			tok.len = delim - s_tok.s;

			s_tok.s = delim+1;
			s_tok.len = (delim-tok.s+1);

			trim_spaces_lr(tok);
			rc = get_algo(&tok);
		}

		if (rc < 2 && rc >=0)
			*algo = rc;
		else
			*b64_required = rc;
	} while(delim);
}
Ejemplo n.º 2
0
/** \brief compare 2 objects (ala memcmp)
 * 
 * - it return a value <  0 if the local object is less than the external one
 * - it return a value == 0 if the local object is equal to the external one
 * - it return a value >  0 if the local object is greater than the external one
 */
int skey_auth_type_t::compare( const skey_auth_type_t & other )  const throw()
{
	// handle the case where at least one is null
	if(  is_null() && !other.is_null() )	return -1;
	if( !is_null() &&  other.is_null() )	return +1;
	if(  is_null() &&  other.is_null() )	return  0;
	// NOTE: here both are NOT null
	
	// Handle the case where they are not both of the same algo
	if( get_algo() < other.get_algo())	return -1;
	if( get_algo() > other.get_algo())	return +1;
	// NOTE: here both of the same algo

	// Handle the case where they are not both of the same mode
	if( get_mode() < other.get_mode())	return -1;
	if( get_mode() > other.get_mode())	return +1;
	// NOTE: here both of the same mode

	// Handle the case where they are not both of the same output_len
	if( get_output_len() < other.get_output_len())	return -1;
	if( get_output_len() > other.get_output_len())	return +1;
	// NOTE: here both of the same output_len
	
	// here both at considered equal
	return 0;
}
Ejemplo n.º 3
0
static SLVAL
sl_gcrypt_algorithm_inspect(sl_vm_t* vm, SLVAL self)
{
    gcrypt_algorithm_t* algo = get_algo(vm, self);
    SLVAL str = sl_make_cstring(vm, "#<GCrypt::Algorithm: ");
    str = sl_string_concat(vm, str, algo->name);
    str = sl_string_concat(vm, str, sl_make_cstring(vm, ">"));
    return str;
}
Ejemplo n.º 4
0
static gcrypt_algorithm_t*
get_algo_check(sl_vm_t* vm, SLVAL obj)
{
    gcrypt_algorithm_t* ptr = get_algo(vm, obj);
    if(ptr->algo == 0) {
        sl_throw_message2(vm, vm->lib.TypeError, "Invalid GCrypt::Algorithm");
    }
    return ptr;
}
Ejemplo n.º 5
0
const supported_algo_t *get_dh_group_ipsec(int server_setting)
{
	const char *pfs_setting = config[CONFIG_IPSEC_PFS];

	if (!strcmp(config[CONFIG_IPSEC_PFS], "server")) {
		/* treat server_setting == -1 (unknown) as 0 */
		pfs_setting = (server_setting == 1) ? "dh2" : "nopfs";
	}

	return get_algo(SUPP_ALGO_DH_GROUP, SUPP_ALGO_NAME, 0, pfs_setting, 0);
}
Ejemplo n.º 6
0
    void compressor::change_algo(compression new_algo, U_I new_compression_level)
    {
        if(new_algo == get_algo() && new_compression_level == current_level)
            return;

	if(is_terminated())
	    throw SRC_BUG;

            // flush data and release zlib memory structures
        local_terminate();

            // change to new algorithm
        init(new_algo, compressed, new_compression_level);
    }
Ejemplo n.º 7
0
const supported_algo_t *get_dh_group_ike(void)
{
	return get_algo(SUPP_ALGO_DH_GROUP, SUPP_ALGO_NAME, 0, config[CONFIG_IKE_DH], 0);
}