Skip to content

Commit

Permalink
remote: Add API to serve a token
Browse files Browse the repository at this point in the history
  • Loading branch information
ueno committed Jan 26, 2017
1 parent d182a61 commit 7efc1e3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/manual/p11-kit-sections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ p11_filter_deny_token
p11_filter_release
p11_filter_subclass
p11_kit_remote_serve_module
p11_kit_remote_serve_token
</SECTION>

<SECTION>
Expand Down
5 changes: 5 additions & 0 deletions p11-kit/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ int p11_kit_remote_serve_module (CK_FUNCTION_LIST *m
int in_fd,
int out_fd);

int p11_kit_remote_serve_token (CK_FUNCTION_LIST *module,
CK_TOKEN_INFO *token,
int in_fd,
int out_fd);

#endif

#ifdef __cplusplus
Expand Down
37 changes: 37 additions & 0 deletions p11-kit/rpc-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#define P11_DEBUG_FLAG P11_DEBUG_RPC
#include "debug.h"
#include "filter.h"
#include "pkcs11.h"
#include "library.h"
#include "private.h"
Expand Down Expand Up @@ -2015,3 +2016,39 @@ p11_kit_remote_serve_module (CK_FUNCTION_LIST *module,

return ret;
}

int
p11_kit_remote_serve_token (CK_FUNCTION_LIST *module,
CK_TOKEN_INFO *token,
int in_fd,
int out_fd)
{
p11_virtual virt;
p11_virtual *filter = NULL;
CK_FUNCTION_LIST *filtered = NULL;
int ret = 1;

return_val_if_fail (module != NULL, 1);
return_val_if_fail (token != NULL, 1);

p11_virtual_init (&virt, &p11_virtual_base, module, NULL);
filter = p11_filter_subclass (&virt, NULL);
if (filter == NULL)
goto out;

filtered = p11_virtual_wrap (filter, (p11_destroyer)p11_virtual_uninit);
if (filtered == NULL)
goto out;

p11_filter_allow_token (filter, token);

ret = p11_kit_remote_serve_module (filtered, in_fd, out_fd);

out:
if (filtered != NULL)
p11_virtual_unwrap (filtered);
if (filter != NULL)
p11_filter_release (filter);

return ret;
}

0 comments on commit 7efc1e3

Please sign in to comment.