Ejemplo n.º 1
0
int
alg_info_snprint_esp(char *buf, int buflen, struct alg_info_esp *alg_info)
{
	char *ptr=buf;
	int ret;
	struct esp_info *esp_info;
	int cnt;
	int eklen, aklen;
	ptr=buf;
	ALG_INFO_ESP_FOREACH(alg_info, esp_info, cnt) {
		if (kernel_alg_esp_enc_ok(esp_info->esp_ealg_id, 0, NULL) &&
			(kernel_alg_esp_auth_ok(esp_info->esp_aalg_id, NULL))) {
		eklen=esp_info->esp_ealg_keylen;
		if (!eklen) 
			eklen=kernel_alg_esp_enc_keylen(esp_info->esp_ealg_id)*BITS_PER_BYTE;
		aklen=esp_info->esp_aalg_keylen;
		if (!aklen) 
			aklen=kernel_alg_esp_auth_keylen(esp_info->esp_aalg_id)*BITS_PER_BYTE;
		ret=snprintf(ptr, buflen, "%d_%03d-%d_%03d, ",
				esp_info->esp_ealg_id,
				eklen,
				esp_info->esp_aalg_id,
				aklen);
		ptr+=ret;
		buflen-=ret;
		if (buflen<0) break;
		}
	}
	return ptr-buf;
}
Ejemplo n.º 2
0
/*
 * print which ESP algorithm has actually been selected, based upon which
 * ones are actually loaded.
 */
int
alg_info_snprint_esp(char *buf, int buflen, struct alg_info_esp *alg_info)
{
	char *ptr=buf;
	int ret;
	struct esp_info *esp_info;
	int cnt;
	int eklen, aklen;
	const char *sep="";

	ptr=buf;

	buf[0]=0; strncat(buf, "none", buflen);

	ALG_INFO_ESP_FOREACH(alg_info, esp_info, cnt) {
	    if (kernel_alg_esp_enc_ok(esp_info->esp_ealg_id, 0, NULL)) {
		DBG_log("esp algid=%d not available", esp_info->esp_ealg_id);
		continue;
	    }

	    if (kernel_alg_esp_auth_ok(esp_info->esp_aalg_id, NULL)) {
		DBG_log("auth algid=%d not available", esp_info->esp_aalg_id);
		continue;
	    }
	    
	    eklen=esp_info->esp_ealg_keylen;
	    if (!eklen) 
		eklen=kernel_alg_esp_enc_keylen(esp_info->esp_ealg_id)*BITS_PER_BYTE;
	    aklen=esp_info->esp_aalg_keylen;
	    if (!aklen) 
		aklen=kernel_alg_esp_auth_keylen(esp_info->esp_aalg_id)*BITS_PER_BYTE;
	    
	    ret=snprintf(ptr, buflen, "%s%s(%d)_%03d-%s(%d)_%03d"
			 , sep
			 , enum_name(&esp_transformid_names, esp_info->esp_ealg_id)+sizeof("ESP")
			 , esp_info->esp_ealg_id, eklen
			 , enum_name(&auth_alg_names, esp_info->esp_aalg_id)+sizeof("AUTH_ALGORITHM_HMAC")
			 , esp_info->esp_aalg_id, aklen);
	    ptr+=ret;
	    buflen-=ret;
	    if (buflen<0) break;

	    sep = ", ";
	}
	return ptr-buf;
}