}
/* Take the key to be used */
- if (key) {
- /* Use key application specified */
- cipher = key->cipher;
- hmac = key->hmac;
- } else if (channel->curr_key) {
- /* Use current private key */
- cipher = channel->curr_key->cipher;
- hmac = channel->curr_key->hmac;
- } else if (!channel->curr_key && channel->private_keys) {
- /* Use just some private key since we don't know what to use
- and private keys are set. */
- silc_dlist_start(channel->private_keys);
- key = silc_dlist_get(channel->private_keys);
- cipher = key->cipher;
- hmac = key->hmac;
-
- /* Use this key as current private key */
- channel->curr_key = key;
+ if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY) {
+ if (key) {
+ /* Use key application specified */
+ cipher = key->cipher;
+ hmac = key->hmac;
+ } else if (channel->curr_key) {
+ /* Use current private key */
+ cipher = channel->curr_key->cipher;
+ hmac = channel->curr_key->hmac;
+ } else if (!channel->curr_key && channel->private_keys) {
+ /* Use just some private key since we don't know what to use
+ and private keys are set. */
+ silc_dlist_start(channel->private_keys);
+ key = silc_dlist_get(channel->private_keys);
+ cipher = key->cipher;
+ hmac = key->hmac;
+
+ /* Use this key as current private key */
+ channel->curr_key = key;
+ } else {
+ /* Use normal channel key generated by the server */
+ cipher = channel->channel_key;
+ hmac = channel->hmac;
+ }
} else {
/* Use normal channel key generated by the server */
cipher = channel->channel_key;
/* If there is no channel private key then just decrypt the message
with the channel key. If private keys are set then just go through
all private keys and check what decrypts correctly. */
- if (!channel->private_keys) {
+ if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
/* Parse the channel message payload. This also decrypts the payload */
payload = silc_channel_payload_parse(buffer, channel->channel_key,
channel->hmac);
if (!payload)
goto out;
- } else {
+ } else if (channel->private_keys) {
SilcChannelPrivateKey entry;
silc_dlist_start(channel->private_keys);
}
if (entry == SILC_LIST_END)
goto out;
+ } else {
+ goto out;
}
message = silc_channel_get_data(payload, NULL);