------------------------------------------------------------ revno: 5278 committer: Henrik Ziegeldorf <henrik.ziegeldorf@xxxxxxxxxxxxxx> branch nick: ecc timestamp: Sat 2011-01-08 15:21:25 +0100 message: Refactored function hip_recreate_r1s_for_entry_move() in order to avoid code duplication. Set local variable to point to signature function and call hip_precreate_r1() only once with this funciton pointer, instead of calling hip_precreate_r1() in every switch case. modified: hipd/cookie.c -- lp:~hipl-core/hipl/ecc https://code.launchpad.net/~hipl-core/hipl/ecc Your team HIPL core team is subscribed to branch lp:~hipl-core/hipl/ecc. To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/ecc/+edit-subscription
=== modified file 'hipd/cookie.c' --- hipd/cookie.c 2011-01-06 16:26:07 +0000 +++ hipd/cookie.c 2011-01-08 14:21:25 +0000 @@ -393,29 +393,28 @@ UNUSED void *opaque) { int err = 0; + int (*signature_func)(void *key, struct hip_common *m); hip_uninit_r1(entry->r1); HIP_IFE(!(entry->r1 = hip_init_r1()), -ENOMEM); switch (hip_get_host_id_algo(entry->host_id)) { case HIP_HI_RSA: - HIP_IFE(!hip_precreate_r1(entry->r1, &entry->lhi.hit, - hip_rsa_sign, - entry->private_key, entry->host_id), -1); + signature_func = hip_rsa_sign; break; case HIP_HI_DSA: - HIP_IFE(!hip_precreate_r1(entry->r1, &entry->lhi.hit, - hip_dsa_sign, - entry->private_key, entry->host_id), -1); + signature_func = hip_dsa_sign; break; case HIP_HI_ECDSA: - HIP_IFE(!hip_precreate_r1(entry->r1, &entry->lhi.hit, - hip_ecdsa_sign, - entry->private_key, entry->host_id), -1); + signature_func = hip_ecdsa_sign; break; default: HIP_IFEL(1,-1, "Unkown algorithm"); } + HIP_IFE(!hip_precreate_r1(entry->r1, &entry->lhi.hit, + signature_func, + entry->private_key, entry->host_id), -1); + out_err: return err; }