diff --git a/p11-kit/rpc-client.c b/p11-kit/rpc-client.c index 93e8c7ad..0a9208ba 100644 --- a/p11-kit/rpc-client.c +++ b/p11-kit/rpc-client.c @@ -430,9 +430,12 @@ proto_write_mechanism (p11_rpc_message *msg, /* Make sure this is in the right order */ assert (!msg->signature || p11_rpc_message_verify_part (msg, "M")); - /* This case is valid for C_*Init () functions to cancel operation */ + /* + * The NULL mech is used for C_*Init () functions to cancel operation. + * We use 0xffffffff as a marker to indicate that. + */ if (mech == NULL) { - p11_rpc_buffer_add_uint32 (msg->output, 0); + p11_rpc_buffer_add_uint32 (msg->output, 0xffffffff); return p11_buffer_failed (msg->output) ? CKR_HOST_MEMORY : CKR_OK; } diff --git a/p11-kit/rpc-server.c b/p11-kit/rpc-server.c index 87bd5744..bdaded11 100644 --- a/p11-kit/rpc-server.c +++ b/p11-kit/rpc-server.c @@ -480,8 +480,13 @@ proto_read_mechanism (p11_rpc_message *msg, return PARSE_ERROR; } - if (temp.mechanism == 0) { + /* + * The NULL mech is used for C_*Init () functions to cancel operation. + * We use 0xffffffff as a marker to indicate that. + */ + if (temp.mechanism == 0xffffffff) { *mech = NULL; + msg->parsed = offset; return CKR_OK; }