* Callback function to receive Passphrases
*/
static shared_key_t* passphrase_cb(passphrase_cb_data_t *data,
+ shared_key_type_t type,
identification_t *me, identification_t *other,
id_match_t *match_me, id_match_t *match_other)
{
chunk_t secret;
char buf[256];
+ if (type != SHARED_ANY && type != SHARED_PRIVATE_KEY_PASS)
+ {
+ return NULL;
+ }
+
if (data->try > 1)
{
if (data->try > 5)
/**
* Callback function to receive PINs
*/
-static shared_key_t* pin_cb(pin_cb_data_t *data,
+static shared_key_t* pin_cb(pin_cb_data_t *data, shared_key_type_t type,
identification_t *me, identification_t *other,
id_match_t *match_me, id_match_t *match_other)
{
chunk_t secret;
char buf[256];
+ if (type != SHARED_ANY && type != SHARED_PIN)
+ {
+ return NULL;
+ }
+
if (!me || !chunk_equals(me->get_encoding(me), data->keyid))
{
return NULL;
enumerator_t public;
/* backref to this */
private_callback_cred_t *this;
+ /* type if requested key */
+ shared_key_type_t type;
/* own identity to match */
identification_t *me;
/* other identity to match */
id_match_t *match_me, id_match_t *match_other)
{
DESTROY_IF(this->current);
- this->current = this->this->cb.shared(this->this->data,
+ this->current = this->this->cb.shared(this->this->data, this->type,
this->me, this->other, match_me, match_other);
if (this->current)
{
.destroy = _shared_destroy,
},
.this = this,
+ .type = type,
.me = me,
.other = other,
);
/**
* Callback function to get shared keys.
*
+ * @param type type of requested shared key
* @param me own identity
* @param other other identity
* @param match_me match result of own identity
* @param match_other match result of other identity
*/
-typedef shared_key_t* (*callback_cred_shared_cb_t)(void *data,
+typedef shared_key_t* (*callback_cred_shared_cb_t)(
+ void *data, shared_key_type_t type,
identification_t *me, identification_t *other,
id_match_t *match_me, id_match_t *match_other);
/**
* Passphrase callback to read from whack fd
*/
-static shared_key_t* whack_pass_cb(prompt_pass_t *pass,
+static shared_key_t* whack_pass_cb(prompt_pass_t *pass, shared_key_type_t type,
identification_t *me, identification_t *other,
id_match_t *match_me, id_match_t *match_other)
{
int n;
+ if (type != SHARED_ANY && type != SHARED_PRIVATE_KEY_PASS)
+ {
+ return NULL;
+ }
+
if (pass->try > MAX_PROMPT_PASS_TRIALS)
{
whack_log(RC_LOG_SERIOUS, "invalid passphrase, too many trials");