2323#include <keys/user-type.h>
2424#include "ar-internal.h"
2525
26- static int rxrpc_vet_description_s (const char * );
2726static int rxrpc_preparse (struct key_preparsed_payload * );
28- static int rxrpc_preparse_s (struct key_preparsed_payload * );
2927static void rxrpc_free_preparse (struct key_preparsed_payload * );
30- static void rxrpc_free_preparse_s (struct key_preparsed_payload * );
3128static void rxrpc_destroy (struct key * );
32- static void rxrpc_destroy_s (struct key * );
3329static void rxrpc_describe (const struct key * , struct seq_file * );
34- static void rxrpc_describe_s (const struct key * , struct seq_file * );
3530static long rxrpc_read (const struct key * , char * , size_t );
3631
3732/*
@@ -50,38 +45,6 @@ struct key_type key_type_rxrpc = {
5045};
5146EXPORT_SYMBOL (key_type_rxrpc );
5247
53- /*
54- * rxrpc server defined keys take "<serviceId>:<securityIndex>" as the
55- * description and an 8-byte decryption key as the payload
56- */
57- struct key_type key_type_rxrpc_s = {
58- .name = "rxrpc_s" ,
59- .flags = KEY_TYPE_NET_DOMAIN ,
60- .vet_description = rxrpc_vet_description_s ,
61- .preparse = rxrpc_preparse_s ,
62- .free_preparse = rxrpc_free_preparse_s ,
63- .instantiate = generic_key_instantiate ,
64- .destroy = rxrpc_destroy_s ,
65- .describe = rxrpc_describe_s ,
66- };
67-
68- /*
69- * Vet the description for an RxRPC server key
70- */
71- static int rxrpc_vet_description_s (const char * desc )
72- {
73- unsigned long num ;
74- char * p ;
75-
76- num = simple_strtoul (desc , & p , 10 );
77- if (* p != ':' || num > 65535 )
78- return - EINVAL ;
79- num = simple_strtoul (p + 1 , & p , 10 );
80- if (* p || num < 1 || num > 255 )
81- return - EINVAL ;
82- return 0 ;
83- }
84-
8548/*
8649 * parse an RxKAD type XDR format token
8750 * - the caller guarantees we have at least 4 words
@@ -433,45 +396,6 @@ static void rxrpc_free_preparse(struct key_preparsed_payload *prep)
433396 rxrpc_free_token_list (prep -> payload .data [0 ]);
434397}
435398
436- /*
437- * Preparse a server secret key.
438- *
439- * The data should be the 8-byte secret key.
440- */
441- static int rxrpc_preparse_s (struct key_preparsed_payload * prep )
442- {
443- struct crypto_skcipher * ci ;
444-
445- _enter ("%zu" , prep -> datalen );
446-
447- if (prep -> datalen != 8 )
448- return - EINVAL ;
449-
450- memcpy (& prep -> payload .data [2 ], prep -> data , 8 );
451-
452- ci = crypto_alloc_skcipher ("pcbc(des)" , 0 , CRYPTO_ALG_ASYNC );
453- if (IS_ERR (ci )) {
454- _leave (" = %ld" , PTR_ERR (ci ));
455- return PTR_ERR (ci );
456- }
457-
458- if (crypto_skcipher_setkey (ci , prep -> data , 8 ) < 0 )
459- BUG ();
460-
461- prep -> payload .data [0 ] = ci ;
462- _leave (" = 0" );
463- return 0 ;
464- }
465-
466- /*
467- * Clean up preparse data.
468- */
469- static void rxrpc_free_preparse_s (struct key_preparsed_payload * prep )
470- {
471- if (prep -> payload .data [0 ])
472- crypto_free_skcipher (prep -> payload .data [0 ]);
473- }
474-
475399/*
476400 * dispose of the data dangling from the corpse of a rxrpc key
477401 */
@@ -480,17 +404,6 @@ static void rxrpc_destroy(struct key *key)
480404 rxrpc_free_token_list (key -> payload .data [0 ]);
481405}
482406
483- /*
484- * dispose of the data dangling from the corpse of a rxrpc key
485- */
486- static void rxrpc_destroy_s (struct key * key )
487- {
488- if (key -> payload .data [0 ]) {
489- crypto_free_skcipher (key -> payload .data [0 ]);
490- key -> payload .data [0 ] = NULL ;
491- }
492- }
493-
494407/*
495408 * describe the rxrpc key
496409 */
@@ -517,14 +430,6 @@ static void rxrpc_describe(const struct key *key, struct seq_file *m)
517430 }
518431}
519432
520- /*
521- * describe the rxrpc server key
522- */
523- static void rxrpc_describe_s (const struct key * key , struct seq_file * m )
524- {
525- seq_puts (m , key -> description );
526- }
527-
528433/*
529434 * grab the security key for a socket
530435 */
@@ -555,36 +460,6 @@ int rxrpc_request_key(struct rxrpc_sock *rx, sockptr_t optval, int optlen)
555460 return 0 ;
556461}
557462
558- /*
559- * grab the security keyring for a server socket
560- */
561- int rxrpc_server_keyring (struct rxrpc_sock * rx , sockptr_t optval , int optlen )
562- {
563- struct key * key ;
564- char * description ;
565-
566- _enter ("" );
567-
568- if (optlen <= 0 || optlen > PAGE_SIZE - 1 )
569- return - EINVAL ;
570-
571- description = memdup_sockptr_nul (optval , optlen );
572- if (IS_ERR (description ))
573- return PTR_ERR (description );
574-
575- key = request_key (& key_type_keyring , description , NULL );
576- if (IS_ERR (key )) {
577- kfree (description );
578- _leave (" = %ld" , PTR_ERR (key ));
579- return PTR_ERR (key );
580- }
581-
582- rx -> securities = key ;
583- kfree (description );
584- _leave (" = 0 [key %x]" , key -> serial );
585- return 0 ;
586- }
587-
588463/*
589464 * generate a server data key
590465 */
0 commit comments