@@ -30,8 +30,8 @@ static void rxrpc_destroy_s(struct key *);
30
30
static void rxrpc_describe_s (const struct key * , struct seq_file * );
31
31
32
32
/*
33
- * rxrpc server defined keys take "<serviceId>:<securityIndex>" as the
34
- * description and an 8-byte decryption key as the payload
33
+ * rxrpc server keys take "<serviceId>:<securityIndex>[:<sec-specific>] " as the
34
+ * description and the key material as the payload.
35
35
*/
36
36
struct key_type key_type_rxrpc_s = {
37
37
.name = "rxrpc_s" ,
@@ -45,64 +45,62 @@ struct key_type key_type_rxrpc_s = {
45
45
};
46
46
47
47
/*
48
- * Vet the description for an RxRPC server key
48
+ * Vet the description for an RxRPC server key.
49
49
*/
50
50
static int rxrpc_vet_description_s (const char * desc )
51
51
{
52
- unsigned long num ;
52
+ unsigned long service , sec_class ;
53
53
char * p ;
54
54
55
- num = simple_strtoul (desc , & p , 10 );
56
- if (* p != ':' || num > 65535 )
55
+ service = simple_strtoul (desc , & p , 10 );
56
+ if (* p != ':' || service > 65535 )
57
57
return - EINVAL ;
58
- num = simple_strtoul (p + 1 , & p , 10 );
59
- if (* p || num < 1 || num > 255 )
58
+ sec_class = simple_strtoul (p + 1 , & p , 10 );
59
+ if (( * p && * p != ':' ) || sec_class < 1 || sec_class > 255 )
60
60
return - EINVAL ;
61
61
return 0 ;
62
62
}
63
63
64
64
/*
65
65
* Preparse a server secret key.
66
- *
67
- * The data should be the 8-byte secret key.
68
66
*/
69
67
static int rxrpc_preparse_s (struct key_preparsed_payload * prep )
70
68
{
71
- struct crypto_skcipher * ci ;
69
+ const struct rxrpc_security * sec ;
70
+ unsigned int service , sec_class ;
71
+ int n ;
72
72
73
73
_enter ("%zu" , prep -> datalen );
74
74
75
- if (prep -> datalen != 8 )
75
+ if (! prep -> orig_description )
76
76
return - EINVAL ;
77
77
78
- memcpy (& prep -> payload .data [2 ], prep -> data , 8 );
78
+ if (sscanf (prep -> orig_description , "%u:%u%n" , & service , & sec_class , & n ) != 2 )
79
+ return - EINVAL ;
79
80
80
- ci = crypto_alloc_skcipher ("pcbc(des)" , 0 , CRYPTO_ALG_ASYNC );
81
- if (IS_ERR (ci )) {
82
- _leave (" = %ld" , PTR_ERR (ci ));
83
- return PTR_ERR (ci );
84
- }
81
+ sec = rxrpc_security_lookup (sec_class );
82
+ if (!sec )
83
+ return - ENOPKG ;
85
84
86
- if (crypto_skcipher_setkey (ci , prep -> data , 8 ) < 0 )
87
- BUG ();
85
+ prep -> payload .data [1 ] = (struct rxrpc_security * )sec ;
88
86
89
- prep -> payload .data [0 ] = ci ;
90
- _leave (" = 0" );
91
- return 0 ;
87
+ return sec -> preparse_server_key (prep );
92
88
}
93
89
94
90
static void rxrpc_free_preparse_s (struct key_preparsed_payload * prep )
95
91
{
96
- if (prep -> payload .data [0 ])
97
- crypto_free_skcipher (prep -> payload .data [0 ]);
92
+ const struct rxrpc_security * sec = prep -> payload .data [1 ];
93
+
94
+ if (sec )
95
+ sec -> free_preparse_server_key (prep );
98
96
}
99
97
100
98
static void rxrpc_destroy_s (struct key * key )
101
99
{
102
- if ( key -> payload .data [0 ]) {
103
- crypto_free_skcipher ( key -> payload . data [ 0 ]);
104
- key -> payload . data [ 0 ] = NULL ;
105
- }
100
+ const struct rxrpc_security * sec = key -> payload .data [1 ];
101
+
102
+ if ( sec )
103
+ sec -> destroy_server_key ( key );
106
104
}
107
105
108
106
static void rxrpc_describe_s (const struct key * key , struct seq_file * m )
0 commit comments