- * set the active key on an association * ASSUMES TCB_LOCK is already held */
| 1249 | * ASSUMES TCB_LOCK is already held |
| 1250 | */ |
| 1251 | int |
| 1252 | sctp_auth_setactivekey(struct sctp_tcb *stcb, uint16_t keyid) |
| 1253 | { |
| 1254 | sctp_sharedkey_t *skey = NULL; |
| 1255 | |
| 1256 | /* find the key on the assoc */ |
| 1257 | skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, keyid); |
| 1258 | if (skey == NULL) { |
| 1259 | /* that key doesn't exist */ |
| 1260 | return (-1); |
| 1261 | } |
| 1262 | if ((skey->deactivated) && (skey->refcount > 1)) { |
| 1263 | /* can't reactivate a deactivated key with other refcounts */ |
| 1264 | return (-1); |
| 1265 | } |
| 1266 | |
| 1267 | /* set the (new) active key */ |
| 1268 | stcb->asoc.authinfo.active_keyid = keyid; |
| 1269 | /* reset the deactivated flag */ |
| 1270 | skey->deactivated = 0; |
| 1271 | |
| 1272 | return (0); |
| 1273 | } |
| 1274 | |
| 1275 | /*- |
| 1276 | * set the active key on an endpoint |
no test coverage detected