From: Martin Willi Date: Wed, 21 Dec 2011 11:13:43 +0000 (+0100) Subject: Added a keymat_t version to cast it safely X-Git-Tag: 5.0.0~338^2~9^2~124 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3bacc1f4298619effcdb5f575667d27dfb06cab5;p=thirdparty%2Fstrongswan.git Added a keymat_t version to cast it safely --- diff --git a/src/libcharon/sa/ikev1/keymat_v1.c b/src/libcharon/sa/ikev1/keymat_v1.c index 100c9526a9..a0dbd52967 100644 --- a/src/libcharon/sa/ikev1/keymat_v1.c +++ b/src/libcharon/sa/ikev1/keymat_v1.c @@ -946,6 +946,12 @@ METHOD(keymat_v1_t, confirm_iv, void, } } +METHOD(keymat_t, get_version, ike_version_t, + private_keymat_v1_t *this) +{ + return IKEV1; +} + METHOD(keymat_t, create_dh, diffie_hellman_t*, private_keymat_v1_t *this, diffie_hellman_group_t group) { @@ -984,6 +990,7 @@ keymat_v1_t *keymat_v1_create(bool initiator) INIT(this, .public = { .keymat = { + .get_version = _get_version, .create_dh = _create_dh, .get_aead = _get_aead, .destroy = _destroy, diff --git a/src/libcharon/sa/ikev2/keymat_v2.c b/src/libcharon/sa/ikev2/keymat_v2.c index aacff0a99c..3adceeec4f 100644 --- a/src/libcharon/sa/ikev2/keymat_v2.c +++ b/src/libcharon/sa/ikev2/keymat_v2.c @@ -71,6 +71,12 @@ struct private_keymat_v2_t { chunk_t skp_verify; }; +METHOD(keymat_t, get_version, ike_version_t, + private_keymat_v2_t *this) +{ + return IKEV2; +} + METHOD(keymat_t, create_dh, diffie_hellman_t*, private_keymat_v2_t *this, diffie_hellman_group_t group) { @@ -563,6 +569,7 @@ keymat_v2_t *keymat_v2_create(bool initiator) INIT(this, .public = { .keymat = { + .get_version = _get_version, .create_dh = _create_dh, .get_aead = _get_aead, .destroy = _destroy, diff --git a/src/libcharon/sa/keymat.h b/src/libcharon/sa/keymat.h index 4a551a8f5a..9de2574e1a 100644 --- a/src/libcharon/sa/keymat.h +++ b/src/libcharon/sa/keymat.h @@ -36,6 +36,13 @@ typedef struct keymat_t keymat_t; */ struct keymat_t { + /** + * Get IKE version of this keymat. + * + * @return IKEV1 for keymat_v1_t, IKEV2 for keymat_v2_t + */ + ike_version_t (*get_version)(keymat_t *this); + /** * Create a diffie hellman object for key agreement. *