Skip to content

Commit aa21990

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: rxperf: Add test RxGK server keys
Add RxGK server keys of bytes containing { 0, 1, 2, 3, 4, ... } to the server keyring for the rxperf test server. This allows the rxperf test client to connect to it. Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Simon Horman <[email protected]> cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fba6995 commit aa21990

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

net/rxrpc/rxperf.c

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define pr_fmt(fmt) "rxperf: " fmt
99
#include <linux/module.h>
1010
#include <linux/slab.h>
11+
#include <crypto/krb5.h>
1112
#include <net/sock.h>
1213
#include <net/af_rxrpc.h>
1314
#define RXRPC_TRACE_ONLY_DEFINE_ENUMS
@@ -550,9 +551,9 @@ static int rxperf_process_call(struct rxperf_call *call)
550551
}
551552

552553
/*
553-
* Add a key to the security keyring.
554+
* Add an rxkad key to the security keyring.
554555
*/
555-
static int rxperf_add_key(struct key *keyring)
556+
static int rxperf_add_rxkad_key(struct key *keyring)
556557
{
557558
key_ref_t kref;
558559
int ret;
@@ -578,6 +579,47 @@ static int rxperf_add_key(struct key *keyring)
578579
return ret;
579580
}
580581

582+
#ifdef CONFIG_RXGK
583+
/*
584+
* Add a yfs-rxgk key to the security keyring.
585+
*/
586+
static int rxperf_add_yfs_rxgk_key(struct key *keyring, u32 enctype)
587+
{
588+
const struct krb5_enctype *krb5 = crypto_krb5_find_enctype(enctype);
589+
key_ref_t kref;
590+
char name[64];
591+
int ret;
592+
u8 key[32];
593+
594+
if (!krb5 || krb5->key_len > sizeof(key))
595+
return 0;
596+
597+
/* The key is just { 0, 1, 2, 3, 4, ... } */
598+
for (int i = 0; i < krb5->key_len; i++)
599+
key[i] = i;
600+
601+
sprintf(name, "%u:6:1:%u", RX_PERF_SERVICE, enctype);
602+
603+
kref = key_create_or_update(make_key_ref(keyring, true),
604+
"rxrpc_s", name,
605+
key, krb5->key_len,
606+
KEY_POS_VIEW | KEY_POS_READ | KEY_POS_SEARCH |
607+
KEY_USR_VIEW,
608+
KEY_ALLOC_NOT_IN_QUOTA);
609+
610+
if (IS_ERR(kref)) {
611+
pr_err("Can't allocate rxperf server key: %ld\n", PTR_ERR(kref));
612+
return PTR_ERR(kref);
613+
}
614+
615+
ret = key_link(keyring, key_ref_to_ptr(kref));
616+
if (ret < 0)
617+
pr_err("Can't link rxperf server key: %d\n", ret);
618+
key_ref_put(kref);
619+
return ret;
620+
}
621+
#endif
622+
581623
/*
582624
* Initialise the rxperf server.
583625
*/
@@ -607,9 +649,29 @@ static int __init rxperf_init(void)
607649
goto error_keyring;
608650
}
609651
rxperf_sec_keyring = keyring;
610-
ret = rxperf_add_key(keyring);
652+
ret = rxperf_add_rxkad_key(keyring);
653+
if (ret < 0)
654+
goto error_key;
655+
#ifdef CONFIG_RXGK
656+
ret = rxperf_add_yfs_rxgk_key(keyring, KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96);
657+
if (ret < 0)
658+
goto error_key;
659+
ret = rxperf_add_yfs_rxgk_key(keyring, KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96);
660+
if (ret < 0)
661+
goto error_key;
662+
ret = rxperf_add_yfs_rxgk_key(keyring, KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128);
663+
if (ret < 0)
664+
goto error_key;
665+
ret = rxperf_add_yfs_rxgk_key(keyring, KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192);
666+
if (ret < 0)
667+
goto error_key;
668+
ret = rxperf_add_yfs_rxgk_key(keyring, KRB5_ENCTYPE_CAMELLIA128_CTS_CMAC);
669+
if (ret < 0)
670+
goto error_key;
671+
ret = rxperf_add_yfs_rxgk_key(keyring, KRB5_ENCTYPE_CAMELLIA256_CTS_CMAC);
611672
if (ret < 0)
612673
goto error_key;
674+
#endif
613675

614676
ret = rxperf_open_socket();
615677
if (ret < 0)

0 commit comments

Comments
 (0)