int alg_info_snprint_ike(char *buf, int buflen, struct alg_info_ike *alg_info) { char *ptr=buf; int ret; struct ike_info *ike_info; int cnt; int eklen, aklen; const char *sep=""; struct encrypt_desc *enc_desc; struct hash_desc *hash_desc; ALG_INFO_IKE_FOREACH(alg_info, ike_info, cnt) { if (ike_alg_enc_present(ike_info->ike_ealg) && (ike_alg_hash_present(ike_info->ike_halg)) && (lookup_group(ike_info->ike_modp))) { enc_desc=ike_alg_get_encrypter(ike_info->ike_ealg); passert(enc_desc != NULL); hash_desc=ike_alg_get_hasher(ike_info->ike_halg); passert(hash_desc != NULL); eklen=ike_info->ike_eklen; if (!eklen) eklen=enc_desc->keydeflen; aklen=ike_info->ike_hklen; if (!aklen) aklen=hash_desc->hash_digest_len * BITS_PER_BYTE; ret=snprintf(ptr, buflen, "%s%s(%d)_%03d-%s(%d)_%03d-%s(%d)" , sep , enum_name(&oakley_enc_names, ike_info->ike_ealg)+sizeof("OAKLEY") , ike_info->ike_ealg, eklen , enum_name(&oakley_hash_names, ike_info->ike_halg)+sizeof("OAKLEY") , ike_info->ike_halg, aklen , enum_name(&oakley_group_names, ike_info->ike_modp)+sizeof("OAKLEY_GROUP") , ike_info->ike_modp); ptr+=ret; buflen-=ret; if (buflen<0) break; sep = ", "; } } return ptr-buf; }
int alg_info_snprint_ike(char *buf, int buflen, struct alg_info_ike *alg_info) { char *ptr=buf; int ret; struct ike_info *ike_info; int cnt; int eklen, aklen; struct encrypt_desc *enc_desc; struct hash_desc *hash_desc; ALG_INFO_IKE_FOREACH(alg_info, ike_info, cnt) { if (ike_alg_enc_present(ike_info->ike_ealg) && (ike_alg_hash_present(ike_info->ike_halg)) && (lookup_group(ike_info->ike_modp))) { enc_desc=ike_alg_get_encrypter(ike_info->ike_ealg); passert(enc_desc != NULL); hash_desc=ike_alg_get_hasher(ike_info->ike_halg); passert(hash_desc != NULL); eklen=ike_info->ike_eklen; if (!eklen) eklen=enc_desc->keydeflen; aklen=ike_info->ike_hklen; if (!aklen) aklen=hash_desc->hash_digest_len * BITS_PER_BYTE; ret=snprintf(ptr, buflen, "%d_%03d-%d_%03d-%d, ", ike_info->ike_ealg, eklen, ike_info->ike_halg, aklen, ike_info->ike_modp); ptr+=ret; buflen-=ret; if (buflen<0) break; } } return ptr-buf; }
/* check if IKE hash algo is present */ bool ike_alg_hash_present(int halg) { struct hash_desc *hash_desc = ike_alg_get_hasher(halg); return hash_desc ? hash_desc->hash_digest_size : 0; }
/* check if IKE hash algo is present */ bool ike_alg_hash_present(int halg) { const struct hash_desc *hash_desc = ike_alg_get_hasher(halg); return hash_desc != NULL && hash_desc->hash_digest_len != 0; }