tipc: add automatic rekeying for encryption key
authorTuong Lien <tuong.t.lien@dektech.com.au>
Fri, 18 Sep 2020 01:17:29 +0000 (08:17 +0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Sep 2020 20:58:37 +0000 (13:58 -0700)
commit23700da29b83e859a8c3727fddd33ba74c4f3a39
treed16e181d17d508c028cac6e3fcc624a90f04fb39
parent1ef6f7c9390ff5308c940ff8d0a53533a4673ad9
tipc: add automatic rekeying for encryption key

Rekeying is required for security since a key is less secure when using
for a long time. Also, key will be detached when its nonce value (or
seqno ...) is exhausted. We now make the rekeying process automatic and
configurable by user.

Basically, TIPC will at a specific interval generate a new key by using
the kernel 'Random Number Generator' cipher, then attach it as the node
TX key and securely distribute to others in the cluster as RX keys (-
the key exchange). The automatic key switching will then take over, and
make the new key active shortly. Afterwards, the traffic from this node
will be encrypted with the new session key. The same can happen in peer
nodes but not necessarily at the same time.

For simplicity, the automatically generated key will be initiated as a
per node key. It is not too hard to also support a cluster key rekeying
(e.g. a given node will generate a unique cluster key and update to the
others in the cluster...), but that doesn't bring much benefit, while a
per-node key is even more secure.

We also enable user to force a rekeying or change the rekeying interval
via netlink, the new 'set key' command option: 'TIPC_NLA_NODE_REKEYING'
is added for these purposes as follows:
- A value >= 1 will be set as the rekeying interval (in minutes);
- A value of 0 will disable the rekeying;
- A value of 'TIPC_REKEYING_NOW' (~0) will force an immediate rekeying;

The default rekeying interval is (60 * 24) minutes i.e. done every day.
There isn't any restriction for the value but user shouldn't set it too
small or too large which results in an "ineffective" rekeying (thats ok
for testing though).

Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/tipc.h
include/uapi/linux/tipc_netlink.h
net/tipc/crypto.c
net/tipc/crypto.h
net/tipc/netlink.c
net/tipc/node.c