diff options
Diffstat (limited to 'p11-kit')
-rwxr-xr-x | p11-kit/gen-pkcs11-gnu.sh | 16 | ||||
-rwxr-xr-x | p11-kit/gen-virtual-fixed.sh | 28 | ||||
-rw-r--r-- | p11-kit/libp11-kit-0.dll.def | 101 | ||||
-rw-r--r-- | p11-kit/libp11-kit.map | 105 | ||||
-rw-r--r-- | p11-kit/meson.build | 299 | ||||
-rwxr-xr-x | p11-kit/meson_post_install.sh | 15 | ||||
-rw-r--r-- | p11-kit/pkcs11-gnu.c | 3 |
7 files changed, 567 insertions, 0 deletions
diff --git a/p11-kit/gen-pkcs11-gnu.sh b/p11-kit/gen-pkcs11-gnu.sh new file mode 100755 index 0000000..a8b204d --- /dev/null +++ b/p11-kit/gen-pkcs11-gnu.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +source="$1" +target="$2" + +rm -f $target-t $target && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + echo; \ + echo '#include <stdlib.h>'; \ + echo '#include "p11-kit/p11-kit.h"'; \ + cat $source; \ + echo "void *${target}_funcs[] = {" | sed 's/[^][ *a-z0-9_={]/_/g'; \ + sed -n -e '/^typedef/d' -e 's/.* \(p11_kit_[^ ]*\) *(.*/ \1,/p' $source; \ + echo '};'; \ + } > $target-t && \ + mv -f $target-t $target diff --git a/p11-kit/gen-virtual-fixed.sh b/p11-kit/gen-virtual-fixed.sh new file mode 100755 index 0000000..b4f0978 --- /dev/null +++ b/p11-kit/gen-virtual-fixed.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +target="$1" +closures="$2" + +rm -f $target-t $target && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + echo; \ + counter=0; \ + while test $counter -lt $closures; do \ + echo "P11_VIRTUAL_FIXED_FUNCTIONS($counter)"; \ + counter=`expr $counter + 1`; \ + done; \ + echo; \ + echo "CK_FUNCTION_LIST p11_virtual_fixed[P11_VIRTUAL_MAX_FIXED] = {"; \ + counter=0; \ + while test $counter -lt $closures; do \ + echo " P11_VIRTUAL_FIXED_INITIALIZER($counter),"; \ + counter=`expr $counter + 1`; \ + done; \ + echo '};'; \ + echo; \ + counter=0; \ + while test $counter -lt $closures; do \ + echo "P11_VIRTUAL_FIXED_GET_FUNCTION_LIST($counter)"; \ + counter=`expr $counter + 1`; \ + done; \ + } > $target-t && mv -f $target-t $target diff --git a/p11-kit/libp11-kit-0.dll.def b/p11-kit/libp11-kit-0.dll.def new file mode 100644 index 0000000..777d56a --- /dev/null +++ b/p11-kit/libp11-kit-0.dll.def @@ -0,0 +1,101 @@ +EXPORTS +C_GetFunctionList +p11_kit_be_loud +p11_kit_be_quiet +p11_kit_config_option +p11_kit_finalize_module +p11_kit_finalize_registered +p11_kit_initialize_module +p11_kit_initialize_registered +p11_kit_iter_add_callback +p11_kit_iter_add_filter +p11_kit_iter_begin +p11_kit_iter_begin_with +p11_kit_iter_destroy_object +p11_kit_iter_free +p11_kit_iter_get_attributes +p11_kit_iter_get_kind +p11_kit_iter_get_module +p11_kit_iter_get_object +p11_kit_iter_get_session +p11_kit_iter_get_slot +p11_kit_iter_get_slot_info +p11_kit_iter_get_token +p11_kit_iter_keep_session +p11_kit_iter_load_attributes +p11_kit_iter_new +p11_kit_iter_next +p11_kit_iter_set_uri +p11_kit_load_initialize_module +p11_kit_message +p11_kit_module_finalize +p11_kit_module_for_name +p11_kit_module_get_filename +p11_kit_module_get_flags +p11_kit_module_get_name +p11_kit_module_initialize +p11_kit_module_load +p11_kit_module_release +p11_kit_modules_finalize +p11_kit_modules_finalize_and_release +p11_kit_modules_initialize +p11_kit_modules_load +p11_kit_modules_load_and_initialize +p11_kit_modules_release +p11_kit_override_system_files +p11_kit_pin_file_callback +p11_kit_pin_get_length +p11_kit_pin_get_value +p11_kit_pin_new +p11_kit_pin_new_for_buffer +p11_kit_pin_new_for_string +p11_kit_pin_ref +p11_kit_pin_register_callback +p11_kit_pin_request +p11_kit_pin_unref +p11_kit_pin_unregister_callback +p11_kit_registered_module_to_name +p11_kit_registered_modules +p11_kit_registered_name_to_module +p11_kit_registered_option +p11_kit_remote_serve_module +p11_kit_remote_serve_token +p11_kit_remote_serve_tokens +p11_kit_set_progname +p11_kit_space_strdup +p11_kit_space_strlen +p11_kit_strerror +p11_kit_uri_any_unrecognized +p11_kit_uri_clear_attribute +p11_kit_uri_clear_attributes +p11_kit_uri_format +p11_kit_uri_free +p11_kit_uri_get_attribute +p11_kit_uri_get_attributes +p11_kit_uri_get_module_info +p11_kit_uri_get_module_name +p11_kit_uri_get_module_path +p11_kit_uri_get_pin_source +p11_kit_uri_get_pin_value +p11_kit_uri_get_pinfile +p11_kit_uri_get_slot_id +p11_kit_uri_get_slot_info +p11_kit_uri_get_token_info +p11_kit_uri_get_vendor_query +p11_kit_uri_match_attributes +p11_kit_uri_match_module_info +p11_kit_uri_match_slot_info +p11_kit_uri_match_token_info +p11_kit_uri_message +p11_kit_uri_new +p11_kit_uri_parse +p11_kit_uri_set_attribute +p11_kit_uri_set_attributes +p11_kit_uri_set_module_name +p11_kit_uri_set_module_path +p11_kit_uri_set_pin_source +p11_kit_uri_set_pin_value +p11_kit_uri_set_pinfile +p11_kit_uri_set_slot_id +p11_kit_uri_set_unrecognized +p11_kit_uri_set_vendor_query diff --git a/p11-kit/libp11-kit.map b/p11-kit/libp11-kit.map new file mode 100644 index 0000000..6a661f3 --- /dev/null +++ b/p11-kit/libp11-kit.map @@ -0,0 +1,105 @@ +LIBP11_KIT_1.0 { + global: + C_GetFunctionList; + p11_kit_be_loud; + p11_kit_be_quiet; + p11_kit_config_option; + p11_kit_finalize_module; + p11_kit_finalize_registered; + p11_kit_initialize_module; + p11_kit_initialize_registered; + p11_kit_iter_add_callback; + p11_kit_iter_add_filter; + p11_kit_iter_begin; + p11_kit_iter_begin_with; + p11_kit_iter_destroy_object; + p11_kit_iter_free; + p11_kit_iter_get_attributes; + p11_kit_iter_get_kind; + p11_kit_iter_get_module; + p11_kit_iter_get_object; + p11_kit_iter_get_session; + p11_kit_iter_get_slot; + p11_kit_iter_get_slot_info; + p11_kit_iter_get_token; + p11_kit_iter_keep_session; + p11_kit_iter_load_attributes; + p11_kit_iter_new; + p11_kit_iter_next; + p11_kit_iter_set_uri; + p11_kit_load_initialize_module; + p11_kit_message; + p11_kit_module_finalize; + p11_kit_module_for_name; + p11_kit_module_get_filename; + p11_kit_module_get_flags; + p11_kit_module_get_name; + p11_kit_module_initialize; + p11_kit_module_load; + p11_kit_module_release; + p11_kit_modules_finalize; + p11_kit_modules_finalize_and_release; + p11_kit_modules_initialize; + p11_kit_modules_load; + p11_kit_modules_load_and_initialize; + p11_kit_modules_release; + p11_kit_override_system_files; + p11_kit_pin_file_callback; + p11_kit_pin_get_length; + p11_kit_pin_get_value; + p11_kit_pin_new; + p11_kit_pin_new_for_buffer; + p11_kit_pin_new_for_string; + p11_kit_pin_ref; + p11_kit_pin_register_callback; + p11_kit_pin_request; + p11_kit_pin_unref; + p11_kit_pin_unregister_callback; + p11_kit_registered_modules; + p11_kit_registered_module_to_name; + p11_kit_registered_name_to_module; + p11_kit_registered_option; + p11_kit_remote_serve_module; + p11_kit_remote_serve_token; + p11_kit_remote_serve_tokens; + p11_kit_set_progname; + p11_kit_space_strdup; + p11_kit_space_strlen; + p11_kit_strerror; + p11_kit_uri_any_unrecognized; + p11_kit_uri_clear_attribute; + p11_kit_uri_clear_attributes; + p11_kit_uri_format; + p11_kit_uri_free; + p11_kit_uri_get_attribute; + p11_kit_uri_get_attributes; + p11_kit_uri_get_module_info; + p11_kit_uri_get_module_name; + p11_kit_uri_get_module_path; + p11_kit_uri_get_pinfile; + p11_kit_uri_get_pin_source; + p11_kit_uri_get_pin_value; + p11_kit_uri_get_slot_id; + p11_kit_uri_get_slot_info; + p11_kit_uri_get_token_info; + p11_kit_uri_get_vendor_query; + p11_kit_uri_match_attributes; + p11_kit_uri_match_module_info; + p11_kit_uri_match_slot_info; + p11_kit_uri_match_token_info; + p11_kit_uri_message; + p11_kit_uri_new; + p11_kit_uri_parse; + p11_kit_uri_set_attribute; + p11_kit_uri_set_attributes; + p11_kit_uri_set_module_name; + p11_kit_uri_set_module_path; + p11_kit_uri_set_pinfile; + p11_kit_uri_set_pin_source; + p11_kit_uri_set_pin_value; + p11_kit_uri_set_slot_id; + p11_kit_uri_set_unrecognized; + p11_kit_uri_set_vendor_query; + local: + *; +}; diff --git a/p11-kit/meson.build b/p11-kit/meson.build new file mode 100644 index 0000000..33e1683 --- /dev/null +++ b/p11-kit/meson.build @@ -0,0 +1,299 @@ +install_headers('deprecated.h', + 'iter.h', + 'p11-kit.h', + 'pin.h', + 'remote.h', + 'uri.h', + subdir: 'p11-kit-1/p11-kit') + +libp11_kit_internal_sources = [ + 'conf.c', + 'log.c', + 'filter.c', + 'rpc-transport.c', + 'rpc-message.c', + 'rpc-client.c' +] + +libp11_kit_internal_sources += custom_target('generate virtual-fixed-generated.h', + output: 'virtual-fixed-generated.h', + command: [ + meson.current_source_dir() / 'gen-virtual-fixed.sh', + '@OUTPUT@', '64' + ]) +libp11_kit_internal_sources += 'virtual.c' + +libp11_kit_internal_c_args = [ + '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(p11_system_config_file), + '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(p11_system_config_modules), + '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(p11_package_config_modules), + '-DP11_USER_CONFIG_FILE="@0@"'.format(p11_user_config_file), + '-DP11_USER_CONFIG_MODULES="@0@"'.format(p11_user_config_modules), + '-DP11_MODULE_PATH="@0@"'.format(p11_module_path) +] + +libp11_kit_internal = static_library('p11-kit-internal', + libp11_kit_internal_sources, + dependencies: [libp11_common_dep, + libp11_library_dep] + libffi_deps, + c_args: libp11_kit_internal_c_args, + implicit_include_directories: false, + gnu_symbol_visibility: 'hidden') + +libp11_kit_sources = [ + 'iter.c', + 'messages.c', + 'modules.c', + 'pin.c', + 'proxy.c', + 'proxy-init.c', + 'rpc-server.c', + 'uri.c', + 'util.c' +] + +libp11_kit_symbol_map = meson.current_source_dir() / 'libp11-kit.map' +libp11_kit_ldflags = cc.get_supported_link_arguments([ + '-Wl,--version-script,' + libp11_kit_symbol_map +]) +libp11_kit_symbol_def = meson.current_source_dir() / 'libp11-kit-@0@.dll.def'.format(soversion) + +libp11_kit = shared_library('p11-kit', + libp11_kit_sources, + install: true, + version: library_version, + soversion: soversion, + dependencies: libffi_deps + dlopen_deps, + include_directories: [configinc, commoninc], + implicit_include_directories: false, + c_args: libp11_kit_internal_c_args, + link_args: libp11_kit_ldflags, + link_depends: [libp11_kit_symbol_map, + libp11_kit_symbol_def], + link_with: libp11_kit_internal, + vs_module_defs: libp11_kit_symbol_def) + +libp11_kit_dep = declare_dependency(link_with: libp11_kit, + include_directories: [configinc, commoninc]) + +meson.add_install_script( + 'meson_post_install.sh', + libdir, + datadir / 'p11-kit' / 'modules' +) + +if host_system != 'windows' + shared_module('p11-kit-client', + 'client.c', 'client-init.c', + name_prefix: '', + include_directories: [configinc, commoninc], + link_with: [libp11_kit_internal]) +endif + +fixtures_dir = meson.current_source_dir() / 'fixtures' + +if host_system == 'windows' + libp11_kit_testable_c_args = [ + '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(fixtures_dir / 'system-pkcs11.conf'), + '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'system-modules' / 'win32'), + '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'package-modules' / 'win32'), + '-DP11_USER_CONFIG_FILE="@0@"'.format(fixtures_dir / 'user-pkcs11.conf'), + '-DP11_USER_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'user-modules' / 'win32') + ] +else + libp11_kit_testable_c_args = [ + '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(fixtures_dir / 'system-pkcs11.conf'), + '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'system-modules'), + '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'package-modules'), + '-DP11_USER_CONFIG_FILE="@0@"'.format(fixtures_dir / 'user-pkcs11.conf'), + '-DP11_USER_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'user-modules') + ] +endif + +libp11_kit_testable_c_args += '-DP11_MODULE_PATH="@0@"'.format(meson.current_build_dir()) + +libp11_kit_testable = static_library('p11-kit-testable', + libp11_kit_internal_sources, + libp11_kit_sources, + c_args: libp11_kit_testable_c_args, + implicit_include_directories: false, + dependencies: [libp11_common_dep, libp11_library_dep] + libffi_deps + dlopen_deps) + +p11_kit_sources = [ + 'lists.c', + 'p11-kit.c' +] + +executable('p11-kit', + p11_kit_sources, + c_args: common_c_args, + dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, + link_with: libp11_kit, + install: true) + +executable('p11-kit-remote', + 'remote.c', + c_args: common_c_args, + dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, + link_with: libp11_kit, + install: true, + install_dir: prefix / privatedir) + +executable('p11-kit-remote-testable', + 'remote.c', + c_args: common_c_args, + dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, + link_with: libp11_kit_testable) + +executable('p11-kit-server', + 'server.c', + c_args: common_c_args + [ + '-DP11_KIT_REMOTE="p11-kit-remote"' + ], + dependencies: [libp11_tool_dep, libp11_common_dep] + libsystemd_deps + libffi_deps + dlopen_deps, + implicit_include_directories: false, + link_with: libp11_kit, + install: true, + install_dir: prefix / privatedir) + +executable('p11-kit-server-testable', + 'server.c', + c_args: common_c_args + [ + '-DP11_KIT_REMOTE="p11-kit-remote-testable"' + ], + implicit_include_directories: false, + dependencies: [libp11_tool_dep, libp11_common_dep] + libsystemd_deps + libffi_deps + dlopen_deps, + link_with: libp11_kit_testable) + +# Check if compilation succeeds with CRYPTOKI_GNU=1 + +pkcs11_gnu_headers = [ + 'iter.h', + 'pin.h', + 'uri.h' +] + +gnu_h_gen = generator(find_program('gen-pkcs11-gnu.sh'), + output: 'pkcs11-gnu-@BASENAME@.h', + arguments: ['@INPUT@', '@OUTPUT@']) + +gnu_h = gnu_h_gen.process(pkcs11_gnu_headers) + +static_library('p11-kit-pkcs11-gnu', + gnu_h, + 'pkcs11-gnu.c', + include_directories: [configinc, commoninc]) + +# Tests ---------------------------------------------------------------- + +p11_kit_tests = [ + 'test-progname', + 'test-util', + 'test-conf', + 'test-uri', + 'test-pin', + 'test-init', + 'test-modules', + 'test-deprecated', + 'test-proxy', + 'test-iter', + 'test-rpc', + 'test-virtual', + 'test-managed', + 'test-log', + 'test-filter', + 'test-transport' +] + +if host_system != 'windows' + p11_kit_tests += 'test-server' +endif + +foreach name : p11_kit_tests + t = executable(name, '@0@.c'.format(name), + c_args: tests_c_args + libp11_kit_testable_c_args, + include_directories: [configinc, commoninc], + dependencies: [libp11_test_dep, libp11_common_dep] + libffi_deps + dlopen_deps + pthread_create_deps, + link_with: libp11_kit_testable) + test(name, t) +endforeach + +p11_kit_progs = [ + 'print-messages', + 'frob-setuid' +] + +foreach name : p11_kit_progs + t = executable(name, '@0@.c'.format(name), + c_args: tests_c_args, + include_directories: [configinc, commoninc], + dependencies: [libp11_test_dep, libp11_common_dep] + libffi_deps + dlopen_deps + pthread_create_deps, + link_with: libp11_kit_testable) +endforeach + +p11_kit_tests_env = environment() +p11_kit_tests_env.set('abs_top_builddir', top_build_dir) +p11_kit_tests_env.set('P11_MODULE_PATH', meson.current_build_dir()) + +if host_system != 'windows' + test('test-messages.sh', + find_program('test-messages.sh'), + env: p11_kit_tests_env) + + test('test-server.sh', + find_program('test-server.sh'), + env: p11_kit_tests_env) +endif + +mock_sources = { + 'mock-one': ['mock-module-ep.c'], + 'mock-two': ['mock-module-ep2.c'], + 'mock-three': ['mock-module-ep.c'], + 'mock-four': ['mock-module-ep.c'], + 'mock-five': ['mock-module-ep3.c'], + 'mock-seven': ['mock-module-ep5.c'], + 'mock-eight': ['mock-module-ep6.c'], + 'mock-nine': ['mock-module-ep7.c'] +} + +if host_system != 'windows' + mock_sources += {'mock-six': ['mock-module-ep4.c']} +endif + +foreach name, sources : mock_sources + shared_module(name, + sources, + name_prefix: '', + include_directories: [configinc, commoninc], + dependencies: [libp11_test_dep, libp11_common_dep]) +endforeach + +p11_kit_pc_variables = [ + 'p11_module_configs=@0@'.format(prefix / p11_package_config_modules), + 'p11_module_path=@0@'.format(prefix / p11_module_path), + 'proxy_module=@0@/p11-kit-proxy.so'.format(prefix / libdir), + 'p11_system_config_modules=@0@'.format(prefix / p11_package_config_modules) +] + +if trust_paths != '' + p11_kit_pc_variables += [ + 'p11_trust_paths=@0@'.format(trust_paths) + ] +endif + +pkg.generate(libraries: libp11_kit, + filebase: 'p11-kit-1', + name: 'p11-kit', + description: 'Library and proxy module for properly loading and sharing PKCS#11 modules.', + subdirs: 'p11-kit-1', + variables: p11_kit_pc_variables) + +pkcs11_conf_example_conf = configuration_data({ + 'p11_system_config_file': prefix / p11_system_config_file, + 'p11_user_config': prefix / p11_user_config +}) +pkcs11_conf_example = configure_file(input: 'pkcs11.conf.example.in', + output: '@BASENAME@', + configuration: pkcs11_conf_example_conf) +install_data(pkcs11_conf_example, + install_dir: prefix / p11_system_config) diff --git a/p11-kit/meson_post_install.sh b/p11-kit/meson_post_install.sh new file mode 100755 index 0000000..9a59db8 --- /dev/null +++ b/p11-kit/meson_post_install.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set +x + +libdir="$1" +p11_package_config_modules="$2" + +# Proxy module is actually same as library, so install a link +for i in so dylib; do + test -f "$MESON_INSTALL_DESTDIR_PREFIX/$libdir/libp11-kit.$i" && + ln -sf `readlink $MESON_INSTALL_DESTDIR_PREFIX/$libdir/libp11-kit.$i` \ + "$MESON_INSTALL_DESTDIR_PREFIX/$libdir/p11-kit-proxy.$i" || true; +done + +mkdir -p "$MESON_INSTALL_DESTDIR_PREFIX/$p11_package_config_modules" diff --git a/p11-kit/pkcs11-gnu.c b/p11-kit/pkcs11-gnu.c new file mode 100644 index 0000000..86d9374 --- /dev/null +++ b/p11-kit/pkcs11-gnu.c @@ -0,0 +1,3 @@ +#include "pkcs11-gnu-iter.h" +#include "pkcs11-gnu-pin.h" +#include "pkcs11-gnu-uri.h" |