1069 lines
53 KiB
Diff
1069 lines
53 KiB
Diff
From d921a1eada3e12cd97a63995a6d84b049032dccc Mon Sep 17 00:00:00 2001
|
|
From: guowentao <guowentao@xfusion.com>
|
|
Date: Fri, 16 Jun 2023 11:23:24 +0800
|
|
Subject: [PATCH] add SM2 genkey function
|
|
|
|
Signed-off-by: guowentao <guowentao@xfusion.com>
|
|
---
|
|
Makefile.am | 3 +-
|
|
Makefile.in | 313 +++++++++++++++++++++------------
|
|
bash-completion/tpm2tss-genkey | 2 +-
|
|
include/tpm2-tss-engine.h | 11 ++
|
|
src/tpm2-tss-engine-common.c | 10 ++
|
|
src/tpm2-tss-engine-common.h | 38 ++++
|
|
src/tpm2-tss-engine-err.c | 3 +
|
|
src/tpm2-tss-engine-err.h | 3 +
|
|
src/tpm2-tss-engine-sm2.c | 289 ++++++++++++++++++++++++++++++
|
|
src/tpm2tss-genkey.c | 46 ++++-
|
|
10 files changed, 604 insertions(+), 114 deletions(-)
|
|
create mode 100644 src/tpm2-tss-engine-sm2.c
|
|
|
|
diff --git a/Makefile.am b/Makefile.am
|
|
index 5acf88c..a869109 100644
|
|
--- a/Makefile.am
|
|
+++ b/Makefile.am
|
|
@@ -73,7 +73,8 @@ libtpm2tss_la_SOURCES = src/tpm2-tss-engine.c \
|
|
src/tpm2-tss-engine-err.h \
|
|
src/tpm2-tss-engine-ecc.c \
|
|
src/tpm2-tss-engine-rand.c \
|
|
- src/tpm2-tss-engine-rsa.c
|
|
+ src/tpm2-tss-engine-rsa.c \
|
|
+ src/tpm2-tss-engine-sm2.c
|
|
libtpm2tss_la_CFLAGS = $(AM_CFLAGS)
|
|
libtpm2tss_la_LIBADD = $(AM_LDADD)
|
|
libtpm2tss_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -avoid-version \
|
|
diff --git a/Makefile.in b/Makefile.in
|
|
index 8816a17..7871b36 100644
|
|
--- a/Makefile.in
|
|
+++ b/Makefile.in
|
|
@@ -1,7 +1,7 @@
|
|
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
|
|
+# Makefile.in generated by automake 1.16.2 from Makefile.am.
|
|
# @configure_input@
|
|
|
|
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
|
|
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
|
|
|
# This Makefile.in is free software; the Free Software Foundation
|
|
# gives unlimited permission to copy and/or distribute it,
|
|
@@ -46,7 +46,7 @@
|
|
#;*****************************************************************************;
|
|
|
|
# aminclude_static.am generated automatically by Autoconf
|
|
-# from AX_AM_MACROS_STATIC on Fri Nov 20 14:52:29 CET 2020
|
|
+# from AX_AM_MACROS_STATIC on Wed May 10 15:58:55 CST 2023
|
|
|
|
|
|
|
|
@@ -158,6 +158,13 @@ mkinstalldirs = $(install_sh) -d
|
|
CONFIG_HEADER = $(top_builddir)/src/config.h
|
|
CONFIG_CLEAN_FILES =
|
|
CONFIG_CLEAN_VPATH_FILES =
|
|
+am__installdirs = "$(DESTDIR)$(bindir)" \
|
|
+ "$(DESTDIR)$(openssl_enginedir)" "$(DESTDIR)$(man1dir)" \
|
|
+ "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(bash_completiondir)" \
|
|
+ "$(DESTDIR)$(includedir)"
|
|
+@UNIT_TRUE@am__EXEEXT_1 = test/error_tpm2-tss-engine-common$(EXEEXT)
|
|
+am__EXEEXT_2 = $(am__EXEEXT_1)
|
|
+PROGRAMS = $(bin_PROGRAMS)
|
|
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
|
am__vpath_adj = case $$p in \
|
|
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
|
@@ -185,10 +192,6 @@ am__uninstall_files_from_dir = { \
|
|
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
|
$(am__cd) "$$dir" && rm -f $$files; }; \
|
|
}
|
|
-am__installdirs = "$(DESTDIR)$(openssl_enginedir)" \
|
|
- "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \
|
|
- "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(bash_completiondir)" \
|
|
- "$(DESTDIR)$(includedir)"
|
|
LTLIBRARIES = $(openssl_engine_LTLIBRARIES)
|
|
am__DEPENDENCIES_1 =
|
|
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
|
@@ -200,7 +203,8 @@ am_libtpm2tss_la_OBJECTS = src/libtpm2tss_la-tpm2-tss-engine.lo \
|
|
src/libtpm2tss_la-tpm2-tss-engine-err.lo \
|
|
src/libtpm2tss_la-tpm2-tss-engine-ecc.lo \
|
|
src/libtpm2tss_la-tpm2-tss-engine-rand.lo \
|
|
- src/libtpm2tss_la-tpm2-tss-engine-rsa.lo
|
|
+ src/libtpm2tss_la-tpm2-tss-engine-rsa.lo \
|
|
+ src/libtpm2tss_la-tpm2-tss-engine-sm2.lo
|
|
libtpm2tss_la_OBJECTS = $(am_libtpm2tss_la_OBJECTS)
|
|
AM_V_lt = $(am__v_lt_@AM_V@)
|
|
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
|
@@ -209,22 +213,20 @@ am__v_lt_1 =
|
|
libtpm2tss_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libtpm2tss_la_CFLAGS) \
|
|
$(CFLAGS) $(libtpm2tss_la_LDFLAGS) $(LDFLAGS) -o $@
|
|
-@UNIT_TRUE@am__EXEEXT_1 = test/error_tpm2-tss-engine-common$(EXEEXT)
|
|
-am__EXEEXT_2 = $(am__EXEEXT_1)
|
|
-PROGRAMS = $(bin_PROGRAMS)
|
|
am__test_error_tpm2_tss_engine_common_SOURCES_DIST = \
|
|
test/error_tpm2-tss-engine-common.c src/tpm2-tss-engine.c \
|
|
src/tpm2-tss-engine-common.c src/tpm2-tss-engine-common.h \
|
|
src/tpm2-tss-engine-err.c src/tpm2-tss-engine-err.h \
|
|
src/tpm2-tss-engine-ecc.c src/tpm2-tss-engine-rand.c \
|
|
- src/tpm2-tss-engine-rsa.c
|
|
+ src/tpm2-tss-engine-rsa.c src/tpm2-tss-engine-sm2.c
|
|
am__objects_1 = src/test_error_tpm2_tss_engine_common-tpm2-tss-engine.$(OBJEXT) \
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-common.$(OBJEXT) \
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-err.$(OBJEXT) \
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-ecc.$(OBJEXT) \
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.$(OBJEXT) \
|
|
- src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.$(OBJEXT)
|
|
-@UNIT_TRUE@am_test_error_tpm2_tss_engine_common_OBJECTS = test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.$(OBJEXT) \
|
|
+ src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.$(OBJEXT) \
|
|
+ src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.$(OBJEXT)
|
|
+@UNIT_TRUE@am_test_error_tpm2_tss_engine_common_OBJECTS = test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.$(OBJEXT) \
|
|
@UNIT_TRUE@ $(am__objects_1)
|
|
test_error_tpm2_tss_engine_common_OBJECTS = \
|
|
$(am_test_error_tpm2_tss_engine_common_OBJECTS)
|
|
@@ -256,7 +258,24 @@ am__v_at_0 = @
|
|
am__v_at_1 =
|
|
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
|
|
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
|
|
-am__depfiles_maybe = depfiles
|
|
+am__maybe_remake_depfiles = depfiles
|
|
+am__depfiles_remade = \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-common.Plo \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-ecc.Plo \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-err.Plo \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rand.Plo \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rsa.Plo \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Plo \
|
|
+ src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine.Plo \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-common.Po \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-ecc.Po \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-err.Po \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.Po \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.Po \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Po \
|
|
+ src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine.Po \
|
|
+ src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Po \
|
|
+ test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
am__mv = mv -f
|
|
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
|
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
|
@@ -669,7 +688,6 @@ prefix = @prefix@
|
|
program_transform_name = @program_transform_name@
|
|
psdir = @psdir@
|
|
realpath = @realpath@
|
|
-runstatedir = @runstatedir@
|
|
sbindir = @sbindir@
|
|
sharedstatedir = @sharedstatedir@
|
|
srcdir = @srcdir@
|
|
@@ -725,7 +743,8 @@ libtpm2tss_la_SOURCES = src/tpm2-tss-engine.c \
|
|
src/tpm2-tss-engine-err.h \
|
|
src/tpm2-tss-engine-ecc.c \
|
|
src/tpm2-tss-engine-rand.c \
|
|
- src/tpm2-tss-engine-rsa.c
|
|
+ src/tpm2-tss-engine-rsa.c \
|
|
+ src/tpm2-tss-engine-sm2.c
|
|
|
|
libtpm2tss_la_CFLAGS = $(AM_CFLAGS)
|
|
libtpm2tss_la_LIBADD = $(AM_LDADD)
|
|
@@ -804,8 +823,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
|
echo ' $(SHELL) ./config.status'; \
|
|
$(SHELL) ./config.status;; \
|
|
*) \
|
|
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
|
- cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
|
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
|
|
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
|
|
esac;
|
|
$(top_srcdir)/aminclude_static.am $(am__empty):
|
|
|
|
@@ -832,62 +851,6 @@ $(top_srcdir)/src/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
|
|
|
distclean-hdr:
|
|
-rm -f src/config.h src/stamp-h1
|
|
-
|
|
-install-openssl_engineLTLIBRARIES: $(openssl_engine_LTLIBRARIES)
|
|
- @$(NORMAL_INSTALL)
|
|
- @list='$(openssl_engine_LTLIBRARIES)'; test -n "$(openssl_enginedir)" || list=; \
|
|
- list2=; for p in $$list; do \
|
|
- if test -f $$p; then \
|
|
- list2="$$list2 $$p"; \
|
|
- else :; fi; \
|
|
- done; \
|
|
- test -z "$$list2" || { \
|
|
- echo " $(MKDIR_P) '$(DESTDIR)$(openssl_enginedir)'"; \
|
|
- $(MKDIR_P) "$(DESTDIR)$(openssl_enginedir)" || exit 1; \
|
|
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(openssl_enginedir)'"; \
|
|
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(openssl_enginedir)"; \
|
|
- }
|
|
-
|
|
-uninstall-openssl_engineLTLIBRARIES:
|
|
- @$(NORMAL_UNINSTALL)
|
|
- @list='$(openssl_engine_LTLIBRARIES)'; test -n "$(openssl_enginedir)" || list=; \
|
|
- for p in $$list; do \
|
|
- $(am__strip_dir) \
|
|
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(openssl_enginedir)/$$f'"; \
|
|
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(openssl_enginedir)/$$f"; \
|
|
- done
|
|
-
|
|
-clean-openssl_engineLTLIBRARIES:
|
|
- -test -z "$(openssl_engine_LTLIBRARIES)" || rm -f $(openssl_engine_LTLIBRARIES)
|
|
- @list='$(openssl_engine_LTLIBRARIES)'; \
|
|
- locs=`for p in $$list; do echo $$p; done | \
|
|
- sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
|
- sort -u`; \
|
|
- test -z "$$locs" || { \
|
|
- echo rm -f $${locs}; \
|
|
- rm -f $${locs}; \
|
|
- }
|
|
-src/$(am__dirstamp):
|
|
- @$(MKDIR_P) src
|
|
- @: > src/$(am__dirstamp)
|
|
-src/$(DEPDIR)/$(am__dirstamp):
|
|
- @$(MKDIR_P) src/$(DEPDIR)
|
|
- @: > src/$(DEPDIR)/$(am__dirstamp)
|
|
-src/libtpm2tss_la-tpm2-tss-engine.lo: src/$(am__dirstamp) \
|
|
- src/$(DEPDIR)/$(am__dirstamp)
|
|
-src/libtpm2tss_la-tpm2-tss-engine-common.lo: src/$(am__dirstamp) \
|
|
- src/$(DEPDIR)/$(am__dirstamp)
|
|
-src/libtpm2tss_la-tpm2-tss-engine-err.lo: src/$(am__dirstamp) \
|
|
- src/$(DEPDIR)/$(am__dirstamp)
|
|
-src/libtpm2tss_la-tpm2-tss-engine-ecc.lo: src/$(am__dirstamp) \
|
|
- src/$(DEPDIR)/$(am__dirstamp)
|
|
-src/libtpm2tss_la-tpm2-tss-engine-rand.lo: src/$(am__dirstamp) \
|
|
- src/$(DEPDIR)/$(am__dirstamp)
|
|
-src/libtpm2tss_la-tpm2-tss-engine-rsa.lo: src/$(am__dirstamp) \
|
|
- src/$(DEPDIR)/$(am__dirstamp)
|
|
-
|
|
-libtpm2tss.la: $(libtpm2tss_la_OBJECTS) $(libtpm2tss_la_DEPENDENCIES) $(EXTRA_libtpm2tss_la_DEPENDENCIES)
|
|
- $(AM_V_CCLD)$(libtpm2tss_la_LINK) -rpath $(openssl_enginedir) $(libtpm2tss_la_OBJECTS) $(libtpm2tss_la_LIBADD) $(LIBS)
|
|
install-binPROGRAMS: $(bin_PROGRAMS)
|
|
@$(NORMAL_INSTALL)
|
|
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
|
@@ -946,13 +909,71 @@ clean-checkPROGRAMS:
|
|
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
|
echo " rm -f" $$list; \
|
|
rm -f $$list
|
|
+
|
|
+install-openssl_engineLTLIBRARIES: $(openssl_engine_LTLIBRARIES)
|
|
+ @$(NORMAL_INSTALL)
|
|
+ @list='$(openssl_engine_LTLIBRARIES)'; test -n "$(openssl_enginedir)" || list=; \
|
|
+ list2=; for p in $$list; do \
|
|
+ if test -f $$p; then \
|
|
+ list2="$$list2 $$p"; \
|
|
+ else :; fi; \
|
|
+ done; \
|
|
+ test -z "$$list2" || { \
|
|
+ echo " $(MKDIR_P) '$(DESTDIR)$(openssl_enginedir)'"; \
|
|
+ $(MKDIR_P) "$(DESTDIR)$(openssl_enginedir)" || exit 1; \
|
|
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(openssl_enginedir)'"; \
|
|
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(openssl_enginedir)"; \
|
|
+ }
|
|
+
|
|
+uninstall-openssl_engineLTLIBRARIES:
|
|
+ @$(NORMAL_UNINSTALL)
|
|
+ @list='$(openssl_engine_LTLIBRARIES)'; test -n "$(openssl_enginedir)" || list=; \
|
|
+ for p in $$list; do \
|
|
+ $(am__strip_dir) \
|
|
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(openssl_enginedir)/$$f'"; \
|
|
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(openssl_enginedir)/$$f"; \
|
|
+ done
|
|
+
|
|
+clean-openssl_engineLTLIBRARIES:
|
|
+ -test -z "$(openssl_engine_LTLIBRARIES)" || rm -f $(openssl_engine_LTLIBRARIES)
|
|
+ @list='$(openssl_engine_LTLIBRARIES)'; \
|
|
+ locs=`for p in $$list; do echo $$p; done | \
|
|
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
|
+ sort -u`; \
|
|
+ test -z "$$locs" || { \
|
|
+ echo rm -f $${locs}; \
|
|
+ rm -f $${locs}; \
|
|
+ }
|
|
+src/$(am__dirstamp):
|
|
+ @$(MKDIR_P) src
|
|
+ @: > src/$(am__dirstamp)
|
|
+src/$(DEPDIR)/$(am__dirstamp):
|
|
+ @$(MKDIR_P) src/$(DEPDIR)
|
|
+ @: > src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine-common.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine-err.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine-ecc.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine-rand.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine-rsa.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/libtpm2tss_la-tpm2-tss-engine-sm2.lo: src/$(am__dirstamp) \
|
|
+ src/$(DEPDIR)/$(am__dirstamp)
|
|
+
|
|
+libtpm2tss.la: $(libtpm2tss_la_OBJECTS) $(libtpm2tss_la_DEPENDENCIES) $(EXTRA_libtpm2tss_la_DEPENDENCIES)
|
|
+ $(AM_V_CCLD)$(libtpm2tss_la_LINK) -rpath $(openssl_enginedir) $(libtpm2tss_la_OBJECTS) $(libtpm2tss_la_LIBADD) $(LIBS)
|
|
test/$(am__dirstamp):
|
|
@$(MKDIR_P) test
|
|
@: > test/$(am__dirstamp)
|
|
test/$(DEPDIR)/$(am__dirstamp):
|
|
@$(MKDIR_P) test/$(DEPDIR)
|
|
@: > test/$(DEPDIR)/$(am__dirstamp)
|
|
-test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.$(OBJEXT): \
|
|
+test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.$(OBJEXT): \
|
|
test/$(am__dirstamp) test/$(DEPDIR)/$(am__dirstamp)
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine.$(OBJEXT): \
|
|
src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
|
@@ -966,6 +987,8 @@ src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.$(OBJEXT): \
|
|
src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.$(OBJEXT): \
|
|
src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
|
+src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.$(OBJEXT): \
|
|
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
|
|
|
test/error_tpm2-tss-engine-common$(EXEEXT): $(test_error_tpm2_tss_engine_common_OBJECTS) $(test_error_tpm2_tss_engine_common_DEPENDENCIES) $(EXTRA_test_error_tpm2_tss_engine_common_DEPENDENCIES) test/$(am__dirstamp)
|
|
@rm -f test/error_tpm2-tss-engine-common$(EXEEXT)
|
|
@@ -986,20 +1009,28 @@ mostlyclean-compile:
|
|
distclean-compile:
|
|
-rm -f *.tab.c
|
|
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-common.Plo@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-ecc.Plo@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-err.Plo@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rand.Plo@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rsa.Plo@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine.Plo@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-common.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-ecc.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-err.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Po@am__quote@
|
|
-@AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po@am__quote@
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-common.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-ecc.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-err.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rand.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rsa.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine.Plo@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-common.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-ecc.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-err.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Po@am__quote@ # am--include-marker
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po@am__quote@ # am--include-marker
|
|
+
|
|
+$(am__depfiles_remade):
|
|
+ @$(MKDIR_P) $(@D)
|
|
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
|
|
+
|
|
+am--depfiles: $(am__depfiles_remade)
|
|
|
|
.c.o:
|
|
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
|
@@ -1067,19 +1098,26 @@ src/libtpm2tss_la-tpm2-tss-engine-rsa.lo: src/tpm2-tss-engine-rsa.c
|
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtpm2tss_la_CFLAGS) $(CFLAGS) -c -o src/libtpm2tss_la-tpm2-tss-engine-rsa.lo `test -f 'src/tpm2-tss-engine-rsa.c' || echo '$(srcdir)/'`src/tpm2-tss-engine-rsa.c
|
|
|
|
-test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o: test/error_tpm2-tss-engine-common.c
|
|
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o -MD -MP -MF test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo -c -o test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o `test -f 'test/error_tpm2-tss-engine-common.c' || echo '$(srcdir)/'`test/error_tpm2-tss-engine-common.c
|
|
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test/error_tpm2-tss-engine-common.c' object='test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o' libtool=no @AMDEPBACKSLASH@
|
|
+src/libtpm2tss_la-tpm2-tss-engine-sm2.lo: src/tpm2-tss-engine-sm2.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtpm2tss_la_CFLAGS) $(CFLAGS) -MT src/libtpm2tss_la-tpm2-tss-engine-sm2.lo -MD -MP -MF src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Tpo -c -o src/libtpm2tss_la-tpm2-tss-engine-sm2.lo `test -f 'src/tpm2-tss-engine-sm2.c' || echo '$(srcdir)/'`src/tpm2-tss-engine-sm2.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Tpo src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Plo
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tpm2-tss-engine-sm2.c' object='src/libtpm2tss_la-tpm2-tss-engine-sm2.lo' libtool=yes @AMDEPBACKSLASH@
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtpm2tss_la_CFLAGS) $(CFLAGS) -c -o src/libtpm2tss_la-tpm2-tss-engine-sm2.lo `test -f 'src/tpm2-tss-engine-sm2.c' || echo '$(srcdir)/'`src/tpm2-tss-engine-sm2.c
|
|
+
|
|
+test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o: test/error_tpm2-tss-engine-common.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o -MD -MP -MF test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo -c -o test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o `test -f 'test/error_tpm2-tss-engine-common.c' || echo '$(srcdir)/'`test/error_tpm2-tss-engine-common.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test/error_tpm2-tss-engine-common.c' object='test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o' libtool=no @AMDEPBACKSLASH@
|
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o `test -f 'test/error_tpm2-tss-engine-common.c' || echo '$(srcdir)/'`test/error_tpm2-tss-engine-common.c
|
|
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.o `test -f 'test/error_tpm2-tss-engine-common.c' || echo '$(srcdir)/'`test/error_tpm2-tss-engine-common.c
|
|
|
|
-test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj: test/error_tpm2-tss-engine-common.c
|
|
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj -MD -MP -MF test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo -c -o test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj `if test -f 'test/error_tpm2-tss-engine-common.c'; then $(CYGPATH_W) 'test/error_tpm2-tss-engine-common.c'; else $(CYGPATH_W) '$(srcdir)/test/error_tpm2-tss-engine-common.c'; fi`
|
|
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo test/$(DEPDIR)/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test/error_tpm2-tss-engine-common.c' object='test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj' libtool=no @AMDEPBACKSLASH@
|
|
+test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj: test/error_tpm2-tss-engine-common.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj -MD -MP -MF test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo -c -o test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj `if test -f 'test/error_tpm2-tss-engine-common.c'; then $(CYGPATH_W) 'test/error_tpm2-tss-engine-common.c'; else $(CYGPATH_W) '$(srcdir)/test/error_tpm2-tss-engine-common.c'; fi`
|
|
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Tpo test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test/error_tpm2-tss-engine-common.c' object='test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj' libtool=no @AMDEPBACKSLASH@
|
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o test/test_error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj `if test -f 'test/error_tpm2-tss-engine-common.c'; then $(CYGPATH_W) 'test/error_tpm2-tss-engine-common.c'; else $(CYGPATH_W) '$(srcdir)/test/error_tpm2-tss-engine-common.c'; fi`
|
|
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o test/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.obj `if test -f 'test/error_tpm2-tss-engine-common.c'; then $(CYGPATH_W) 'test/error_tpm2-tss-engine-common.c'; else $(CYGPATH_W) '$(srcdir)/test/error_tpm2-tss-engine-common.c'; fi`
|
|
|
|
src/test_error_tpm2_tss_engine_common-tpm2-tss-engine.o: src/tpm2-tss-engine.c
|
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT src/test_error_tpm2_tss_engine_common-tpm2-tss-engine.o -MD -MP -MF src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine.Tpo -c -o src/test_error_tpm2_tss_engine_common-tpm2-tss-engine.o `test -f 'src/tpm2-tss-engine.c' || echo '$(srcdir)/'`src/tpm2-tss-engine.c
|
|
@@ -1165,6 +1203,20 @@ src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.obj: src/tpm2-tss-engi
|
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.obj `if test -f 'src/tpm2-tss-engine-rsa.c'; then $(CYGPATH_W) 'src/tpm2-tss-engine-rsa.c'; else $(CYGPATH_W) '$(srcdir)/src/tpm2-tss-engine-rsa.c'; fi`
|
|
|
|
+src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.o: src/tpm2-tss-engine-sm2.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.o -MD -MP -MF src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Tpo -c -o src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.o `test -f 'src/tpm2-tss-engine-sm2.c' || echo '$(srcdir)/'`src/tpm2-tss-engine-sm2.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Tpo src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Po
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tpm2-tss-engine-sm2.c' object='src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.o' libtool=no @AMDEPBACKSLASH@
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.o `test -f 'src/tpm2-tss-engine-sm2.c' || echo '$(srcdir)/'`src/tpm2-tss-engine-sm2.c
|
|
+
|
|
+src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.obj: src/tpm2-tss-engine-sm2.c
|
|
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -MT src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.obj -MD -MP -MF src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Tpo -c -o src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.obj `if test -f 'src/tpm2-tss-engine-sm2.c'; then $(CYGPATH_W) 'src/tpm2-tss-engine-sm2.c'; else $(CYGPATH_W) '$(srcdir)/src/tpm2-tss-engine-sm2.c'; fi`
|
|
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Tpo src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Po
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tpm2-tss-engine-sm2.c' object='src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.obj' libtool=no @AMDEPBACKSLASH@
|
|
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_error_tpm2_tss_engine_common_CFLAGS) $(CFLAGS) -c -o src/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.obj `if test -f 'src/tpm2-tss-engine-sm2.c'; then $(CYGPATH_W) 'src/tpm2-tss-engine-sm2.c'; else $(CYGPATH_W) '$(srcdir)/src/tpm2-tss-engine-sm2.c'; fi`
|
|
+
|
|
src/tpm2tss_genkey-tpm2tss-genkey.o: src/tpm2tss-genkey.c
|
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tpm2tss_genkey_CFLAGS) $(CFLAGS) -MT src/tpm2tss_genkey-tpm2tss-genkey.o -MD -MP -MF src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Tpo -c -o src/tpm2tss_genkey-tpm2tss-genkey.o `test -f 'src/tpm2tss-genkey.c' || echo '$(srcdir)/'`src/tpm2tss-genkey.c
|
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Tpo src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Po
|
|
@@ -1502,7 +1554,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
|
|
fi; \
|
|
$$success || exit 1
|
|
|
|
-check-TESTS:
|
|
+check-TESTS: $(check_PROGRAMS)
|
|
@list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
|
|
@list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
|
|
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
|
|
@@ -1546,7 +1598,10 @@ test/error_tpm2-tss-engine-common.log: test/error_tpm2-tss-engine-common$(EXEEXT
|
|
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
|
@HAVE_PANDOC_TRUE@dist-hook:
|
|
|
|
-distdir: $(DISTFILES)
|
|
+distdir: $(BUILT_SOURCES)
|
|
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
|
|
+
|
|
+distdir-am: $(DISTFILES)
|
|
$(am__remove_distdir)
|
|
test -d "$(distdir)" || mkdir "$(distdir)"
|
|
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
|
@@ -1604,6 +1659,10 @@ dist-xz: distdir
|
|
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
|
|
$(am__post_remove_distdir)
|
|
|
|
+dist-zstd: distdir
|
|
+ tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
|
|
+ $(am__post_remove_distdir)
|
|
+
|
|
dist-tarZ: distdir
|
|
@echo WARNING: "Support for distribution archives compressed with" \
|
|
"legacy program 'compress' is deprecated." >&2
|
|
@@ -1646,6 +1705,8 @@ distcheck: dist
|
|
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
|
|
*.zip*) \
|
|
unzip $(distdir).zip ;;\
|
|
+ *.tar.zst*) \
|
|
+ zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
|
|
esac
|
|
chmod -R a-w $(distdir)
|
|
chmod u+w $(distdir)
|
|
@@ -1716,9 +1777,9 @@ check-am: all-am
|
|
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
|
|
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
|
|
check: check-am
|
|
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(MANS) $(DATA) $(HEADERS)
|
|
+all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(MANS) $(DATA) $(HEADERS)
|
|
installdirs:
|
|
- for dir in "$(DESTDIR)$(openssl_enginedir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(bash_completiondir)" "$(DESTDIR)$(includedir)"; do \
|
|
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(openssl_enginedir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(bash_completiondir)" "$(DESTDIR)$(includedir)"; do \
|
|
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
|
done
|
|
install: install-am
|
|
@@ -1789,7 +1850,22 @@ clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
|
|
|
|
distclean: distclean-am
|
|
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
|
- -rm -rf src/$(DEPDIR) test/$(DEPDIR)
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-common.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-ecc.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-err.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rand.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rsa.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine.Plo
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-common.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-ecc.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-err.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine.Po
|
|
+ -rm -f src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Po
|
|
+ -rm -f test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
-rm -f Makefile
|
|
distclean-am: clean-am distclean-compile distclean-generic \
|
|
distclean-hdr distclean-libtool distclean-local distclean-tags
|
|
@@ -1839,7 +1915,22 @@ installcheck-am:
|
|
maintainer-clean: maintainer-clean-am
|
|
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
|
-rm -rf $(top_srcdir)/autom4te.cache
|
|
- -rm -rf src/$(DEPDIR) test/$(DEPDIR)
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-common.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-ecc.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-err.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rand.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-rsa.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine-sm2.Plo
|
|
+ -rm -f src/$(DEPDIR)/libtpm2tss_la-tpm2-tss-engine.Plo
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-common.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-ecc.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-err.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rand.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-rsa.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine-sm2.Po
|
|
+ -rm -f src/$(DEPDIR)/test_error_tpm2_tss_engine_common-tpm2-tss-engine.Po
|
|
+ -rm -f src/$(DEPDIR)/tpm2tss_genkey-tpm2tss-genkey.Po
|
|
+ -rm -f test/$(DEPDIR)/error_tpm2_tss_engine_common-error_tpm2-tss-engine-common.Po
|
|
-rm -f Makefile
|
|
maintainer-clean-am: distclean-am maintainer-clean-generic
|
|
|
|
@@ -1865,8 +1956,8 @@ uninstall-man: uninstall-man1 uninstall-man3
|
|
|
|
.MAKE: check-am install-am install-exec-am install-strip uninstall-am
|
|
|
|
-.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-TESTS \
|
|
- check-am check-valgrind-am check-valgrind-drd-am \
|
|
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \
|
|
+ check-TESTS check-am check-valgrind-am check-valgrind-drd-am \
|
|
check-valgrind-drd-local check-valgrind-helgrind-am \
|
|
check-valgrind-helgrind-local check-valgrind-local \
|
|
check-valgrind-memcheck-am check-valgrind-memcheck-local \
|
|
@@ -1875,9 +1966,9 @@ uninstall-man: uninstall-man1 uninstall-man3
|
|
clean-generic clean-libtool clean-local \
|
|
clean-openssl_engineLTLIBRARIES cscope cscopelist-am ctags \
|
|
ctags-am dist dist-all dist-bzip2 dist-gzip dist-hook \
|
|
- dist-lzip dist-shar dist-tarZ dist-xz dist-zip distcheck \
|
|
- distclean distclean-compile distclean-generic distclean-hdr \
|
|
- distclean-libtool distclean-local distclean-tags \
|
|
+ dist-lzip dist-shar dist-tarZ dist-xz dist-zip dist-zstd \
|
|
+ distcheck distclean distclean-compile distclean-generic \
|
|
+ distclean-hdr distclean-libtool distclean-local distclean-tags \
|
|
distcleancheck distdir distuninstallcheck dvi dvi-am html \
|
|
html-am info info-am install install-am \
|
|
install-bash_completionDATA install-binPROGRAMS install-data \
|
|
diff --git a/bash-completion/tpm2tss-genkey b/bash-completion/tpm2tss-genkey
|
|
index 3897ff6..bb7d469 100644
|
|
--- a/bash-completion/tpm2tss-genkey
|
|
+++ b/bash-completion/tpm2tss-genkey
|
|
@@ -7,7 +7,7 @@ _tpm2tss-genkey()
|
|
|
|
case "${prev}" in
|
|
-a | --alg)
|
|
- COMPREPLY=( $(compgen -W "rsa ecdsa" -- ${cur}) );
|
|
+ COMPREPLY=( $(compgen -W "rsa ecdsa sm2" -- ${cur}) );
|
|
return 0
|
|
;;
|
|
-c | --curve)
|
|
diff --git a/include/tpm2-tss-engine.h b/include/tpm2-tss-engine.h
|
|
index f7902bd..ac48f4c 100644
|
|
--- a/include/tpm2-tss-engine.h
|
|
+++ b/include/tpm2-tss-engine.h
|
|
@@ -88,6 +88,17 @@ tpm2tss_ecc_getappdata(EC_KEY *key);
|
|
int
|
|
tpm2tss_ecc_setappdata(EC_KEY *key, TPM2_DATA *data);
|
|
|
|
+int
|
|
+tpm2tss_sm2_genkey(EC_KEY *key, TPMI_ECC_CURVE curve, const char *password,
|
|
+ TPM2_HANDLE parentHandle);
|
|
+
|
|
+TPM2_DATA *
|
|
+tpm2tss_sm2_getappdata(EC_KEY *key);
|
|
+
|
|
+int
|
|
+tpm2tss_sm2_setappdata(EC_KEY *key, TPM2_DATA *data);
|
|
+
|
|
+
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
diff --git a/src/tpm2-tss-engine-common.c b/src/tpm2-tss-engine-common.c
|
|
index 11d6997..4e78707 100755
|
|
--- a/src/tpm2-tss-engine-common.c
|
|
+++ b/src/tpm2-tss-engine-common.c
|
|
@@ -406,6 +406,7 @@ tpm2tss_tpm2data_read(const char *filename, TPM2_DATA **tpm2Datap)
|
|
|
|
static TPM2B_PUBLIC primaryEccTemplate = TPM2B_PUBLIC_PRIMARY_ECC_TEMPLATE;
|
|
static TPM2B_PUBLIC primaryRsaTemplate = TPM2B_PUBLIC_PRIMARY_RSA_TEMPLATE;
|
|
+static TPM2B_PUBLIC primarysm2Template = TPM2B_PUBLIC_PRIMARY_SM2_TEMPLATE;
|
|
|
|
static TPM2B_SENSITIVE_CREATE primarySensitive = {
|
|
.sensitive = {
|
|
@@ -482,6 +483,15 @@ init_tpm_parent(ESYS_CONTEXT **esys_ctx,
|
|
}
|
|
}
|
|
|
|
+ if (primaryTemplate == NULL) {
|
|
+ for (index = 0; index < capabilityData->data.algorithms.count; index++) {
|
|
+ if (capabilityData->data.algorithms.algProperties[index].alg == TPM2_ALG_SM2) {
|
|
+ primaryTemplate = &primarysm2Template;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
if (primaryTemplate == NULL) {
|
|
for (index = 0; index < capabilityData->data.algorithms.count; index++) {
|
|
if (capabilityData->data.algorithms.algProperties[index].alg == TPM2_ALG_RSA) {
|
|
diff --git a/src/tpm2-tss-engine-common.h b/src/tpm2-tss-engine-common.h
|
|
index 8399eab..14c98a0 100755
|
|
--- a/src/tpm2-tss-engine-common.h
|
|
+++ b/src/tpm2-tss-engine-common.h
|
|
@@ -136,6 +136,44 @@ TSS2_RC init_tpm_key ( ESYS_CONTEXT **esys_ctx,
|
|
} \
|
|
}
|
|
|
|
+#define TPM2B_PUBLIC_PRIMARY_SM2_TEMPLATE { \
|
|
+ .publicArea = { \
|
|
+ .type = TPM2_ALG_ECC, \
|
|
+ .nameAlg = ENGINE_HASH_ALG, \
|
|
+ .objectAttributes = (TPMA_OBJECT_USERWITHAUTH | \
|
|
+ TPMA_OBJECT_RESTRICTED | \
|
|
+ TPMA_OBJECT_DECRYPT | \
|
|
+ TPMA_OBJECT_NODA | \
|
|
+ TPMA_OBJECT_FIXEDTPM | \
|
|
+ TPMA_OBJECT_FIXEDPARENT | \
|
|
+ TPMA_OBJECT_SENSITIVEDATAORIGIN), \
|
|
+ .authPolicy = { \
|
|
+ .size = 0, \
|
|
+ }, \
|
|
+ .parameters.eccDetail = { \
|
|
+ .symmetric = { \
|
|
+ .algorithm = TPM2_ALG_AES, \
|
|
+ .keyBits.aes = 128, \
|
|
+ .mode.aes = TPM2_ALG_CFB, \
|
|
+ }, \
|
|
+ .scheme = { \
|
|
+ .scheme = TPM2_ALG_NULL, \
|
|
+ .details = {} \
|
|
+ }, \
|
|
+ .curveID = TPM2_ECC_SM2_P256, \
|
|
+ .kdf = { \
|
|
+ .scheme = TPM2_ALG_NULL, \
|
|
+ .details = {} \
|
|
+ }, \
|
|
+ }, \
|
|
+ .unique.ecc = { \
|
|
+ .x.size = 0, \
|
|
+ .y.size = 0 \
|
|
+ } \
|
|
+ } \
|
|
+}
|
|
+
|
|
+
|
|
typedef struct {
|
|
ASN1_OBJECT *type;
|
|
ASN1_BOOLEAN emptyAuth;
|
|
diff --git a/src/tpm2-tss-engine-err.c b/src/tpm2-tss-engine-err.c
|
|
index 489d19e..08ca749 100644
|
|
--- a/src/tpm2-tss-engine-err.c
|
|
+++ b/src/tpm2-tss-engine-err.c
|
|
@@ -68,6 +68,9 @@ static ERR_STRING_DATA TPM2TSS_f[] = {
|
|
ERR_F(rsa_priv_dec),
|
|
ERR_F(tpm2tss_rsa_genkey),
|
|
ERR_F(populate_rsa),
|
|
+ /* tpm2-tss-engine-sm2.c */
|
|
+ ERR_F(tpm2tss_sm2_genkey),
|
|
+ ERR_F(populate_sm2),
|
|
{0, NULL}
|
|
};
|
|
|
|
diff --git a/src/tpm2-tss-engine-err.h b/src/tpm2-tss-engine-err.h
|
|
index b9f8445..e6a7219 100644
|
|
--- a/src/tpm2-tss-engine-err.h
|
|
+++ b/src/tpm2-tss-engine-err.h
|
|
@@ -95,6 +95,9 @@ void ERR_error(int function, int reason, const char *file, int line);
|
|
#define TPM2TSS_F_rsa_priv_dec 141
|
|
#define TPM2TSS_F_tpm2tss_rsa_genkey 142
|
|
#define TPM2TSS_F_populate_rsa 143
|
|
+/* tpm2-tss-engine-rsa.c */
|
|
+#define TPM2TSS_F_tpm2tss_sm2_genkey 144
|
|
+#define TPM2TSS_F_populate_sm2 145
|
|
|
|
/* Reason codes */
|
|
#define TPM2TSS_R_TPM2DATA_READ_FAILED 100
|
|
diff --git a/src/tpm2-tss-engine-sm2.c b/src/tpm2-tss-engine-sm2.c
|
|
new file mode 100644
|
|
index 0000000..679b36c
|
|
--- /dev/null
|
|
+++ b/src/tpm2-tss-engine-sm2.c
|
|
@@ -0,0 +1,289 @@
|
|
+/*******************************************************************************
|
|
+ * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
|
|
+ * All rights reserved.
|
|
+ *
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
+ *
|
|
+ * 1. Redistributions of source code must retain the above copyright notice,
|
|
+ * this list of conditions and the following disclaimer.
|
|
+ *
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
+ * this list of conditions and the following disclaimer in the documentation
|
|
+ * and/or other materials provided with the distribution.
|
|
+ *
|
|
+ * 3. Neither the name of tpm2-tss-engine nor the names of its contributors
|
|
+ * may be used to endorse or promote products derived from this software
|
|
+ * without specific prior written permission.
|
|
+ *
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
+ * THE POSSIBILITY OF SUCH DAMAGE.
|
|
+ ******************************************************************************/
|
|
+
|
|
+#include <string.h>
|
|
+
|
|
+#include <openssl/engine.h>
|
|
+#include <openssl/ec.h>
|
|
+#include <openssl/ecdsa.h>
|
|
+
|
|
+#include <tss2/tss2_mu.h>
|
|
+#include <tss2/tss2_esys.h>
|
|
+
|
|
+#include "tpm2-tss-engine.h"
|
|
+#include "tpm2-tss-engine-common.h"
|
|
+
|
|
+static int ec_sm2_key_app_data = -1;
|
|
+
|
|
+static TPM2B_DATA allOutsideInfo = {
|
|
+ .size = 0,
|
|
+};
|
|
+
|
|
+static TPML_PCR_SELECTION allCreationPCR = {
|
|
+ .count = 0,
|
|
+};
|
|
+
|
|
+static TPM2B_PUBLIC keyEcTemplate = {
|
|
+ .publicArea = {
|
|
+ .type = TPM2_ALG_ECC,
|
|
+ .nameAlg = ENGINE_HASH_ALG,
|
|
+ .objectAttributes = (TPMA_OBJECT_USERWITHAUTH |
|
|
+ TPMA_OBJECT_SIGN_ENCRYPT |
|
|
+ TPMA_OBJECT_FIXEDTPM |
|
|
+ TPMA_OBJECT_FIXEDPARENT |
|
|
+ TPMA_OBJECT_SENSITIVEDATAORIGIN |
|
|
+ TPMA_OBJECT_NODA),
|
|
+ .parameters.eccDetail = {
|
|
+ .curveID = 0, /* To be filled out later */
|
|
+ .symmetric = {
|
|
+ .algorithm = TPM2_ALG_NULL,
|
|
+ .keyBits.aes = 0,
|
|
+ .mode.aes = 0,
|
|
+ },
|
|
+ .scheme = {
|
|
+ .scheme = TPM2_ALG_NULL,
|
|
+ .details = {}
|
|
+ },
|
|
+ .kdf = {
|
|
+ .scheme = TPM2_ALG_NULL,
|
|
+ .details = {}
|
|
+ },
|
|
+ },
|
|
+ .unique.ecc = {
|
|
+ .x.size = 0,
|
|
+ .y.size = 0
|
|
+ }
|
|
+ }
|
|
+};
|
|
+
|
|
+/** Retrieve app data
|
|
+ *
|
|
+ * Since the ECC api (opposed to the RSA api) does not provide a standardized
|
|
+ * way to retrieve app data between the library and an application, this helper
|
|
+ * is defined
|
|
+ * @param key The key object
|
|
+ * @retval tpm2Data The corresponding TPM data
|
|
+ * @retval NULL on failure.
|
|
+ */
|
|
+TPM2_DATA *
|
|
+tpm2tss_sm2_getappdata(EC_KEY *key)
|
|
+{
|
|
+ return EC_KEY_get_ex_data(key, ec_sm2_key_app_data);
|
|
+}
|
|
+
|
|
+/** Set app data
|
|
+ *
|
|
+ * Since the ECC api (opposed to the RSA api) does not provide a standardized
|
|
+ * way to set app data between the library and an application, this helper
|
|
+ * is defined
|
|
+ * @param key The key object
|
|
+ * @param tpm2Data The corresponding TPM data
|
|
+ * @retval 1 on success
|
|
+ * @retval 0 on failure
|
|
+ */
|
|
+int
|
|
+tpm2tss_sm2_setappdata(EC_KEY *key, TPM2_DATA *tpm2Data)
|
|
+{
|
|
+ return EC_KEY_set_ex_data(key, ec_sm2_key_app_data, tpm2Data);
|
|
+}
|
|
+
|
|
+/** Helper to populate the sm2 key object.
|
|
+ *
|
|
+ * In order to use an ECC key object in a typical manner, all fields of the
|
|
+ * OpenSSL's corresponding object bust be filled. This function fills the public
|
|
+ * values correctly.
|
|
+ * @param key The key object to fill.
|
|
+ * @retval 0 on failure
|
|
+ * @retval 1 on success
|
|
+ */
|
|
+static int
|
|
+populate_sm2(EC_KEY *key)
|
|
+{
|
|
+ EC_GROUP *ecgroup = NULL;
|
|
+ int nid;
|
|
+ BIGNUM *x = NULL, *y = NULL;
|
|
+ TPM2_DATA *tpm2Data = tpm2tss_sm2_getappdata(key);
|
|
+ if (tpm2Data == NULL)
|
|
+ return 0;
|
|
+
|
|
+ switch (tpm2Data->pub.publicArea.parameters.eccDetail.curveID) {
|
|
+ case TPM2_ECC_SM2_P256:
|
|
+ nid = NID_sm2;
|
|
+ break;
|
|
+ default:
|
|
+ nid = -1;
|
|
+ }
|
|
+ if (nid < 0) {
|
|
+ ERR(populate_sm2, TPM2TSS_R_UNKNOWN_CURVE);
|
|
+ return 0;
|
|
+ }
|
|
+ ecgroup = EC_GROUP_new_by_curve_name(nid);
|
|
+ if (ecgroup == NULL) {
|
|
+ ERR(populate_sm2, TPM2TSS_R_UNKNOWN_CURVE);
|
|
+ return 0;
|
|
+ }
|
|
+ if (!EC_KEY_set_group(key, ecgroup)) {
|
|
+ ERR(populate_sm2, TPM2TSS_R_GENERAL_FAILURE);
|
|
+ EC_GROUP_free(ecgroup);
|
|
+ return 0;
|
|
+ }
|
|
+ EC_KEY_set_asn1_flag(key, OPENSSL_EC_NAMED_CURVE);
|
|
+ EC_GROUP_free(ecgroup);
|
|
+
|
|
+ x = BN_bin2bn(tpm2Data->pub.publicArea.unique.ecc.x.buffer,
|
|
+ tpm2Data->pub.publicArea.unique.ecc.x.size, NULL);
|
|
+
|
|
+ y = BN_bin2bn(tpm2Data->pub.publicArea.unique.ecc.y.buffer,
|
|
+ tpm2Data->pub.publicArea.unique.ecc.y.size, NULL);
|
|
+
|
|
+ if (!x || !y) {
|
|
+ ERR(populate_sm2, ERR_R_MALLOC_FAILURE);
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ if (!EC_KEY_set_public_key_affine_coordinates(key, x, y)) {
|
|
+ ERR(populate_sm2, TPM2TSS_R_GENERAL_FAILURE);
|
|
+ BN_free(y);
|
|
+ BN_free(x);
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ BN_free(y);
|
|
+ BN_free(x);
|
|
+
|
|
+ return 1;
|
|
+}
|
|
+
|
|
+
|
|
+/** Generate a tpm2tss sm2 key object.
|
|
+ *
|
|
+ * This function creates a new TPM ECC key. The TPM data is stored inside the
|
|
+ * object*s app data and can be retrieved using tpm2tss_sm2_getappdata().
|
|
+ * @param key The key object for the TPM ECC key to be created
|
|
+ * @param curve The curve to be used for the key
|
|
+ * @param password The Password to be set for the new key
|
|
+ * @retval 1 on success
|
|
+ * @retval 0 on failure
|
|
+ */
|
|
+int
|
|
+tpm2tss_sm2_genkey(EC_KEY *key, TPMI_ECC_CURVE curve, const char *password,
|
|
+ TPM2_HANDLE parentHandle)
|
|
+{
|
|
+ DBG("GenKey for sm2.\n");
|
|
+
|
|
+ TSS2_RC r;
|
|
+ ESYS_CONTEXT *esys_ctx = NULL;
|
|
+ ESYS_TR parent = ESYS_TR_NONE;
|
|
+ TPM2B_PUBLIC *keyPublic = NULL;
|
|
+ TPM2B_PRIVATE *keyPrivate = NULL;
|
|
+ TPM2_DATA *tpm2Data = NULL;
|
|
+ TPM2B_PUBLIC inPublic = keyEcTemplate;
|
|
+ TPM2B_SENSITIVE_CREATE inSensitive = {
|
|
+ .sensitive = {
|
|
+ .userAuth = {
|
|
+ .size = 0,
|
|
+ },
|
|
+ .data = {
|
|
+ .size = 0,
|
|
+ }
|
|
+ }
|
|
+ };
|
|
+
|
|
+ tpm2Data = OPENSSL_malloc(sizeof(*tpm2Data));
|
|
+ if (tpm2Data == NULL) {
|
|
+ ERR(tpm2tss_sm2_genkey, ERR_R_MALLOC_FAILURE);
|
|
+ goto error;
|
|
+ }
|
|
+ memset(tpm2Data, 0, sizeof(*tpm2Data));
|
|
+
|
|
+ inPublic.publicArea.parameters.eccDetail.curveID = curve;
|
|
+
|
|
+ if (password) {
|
|
+ DBG("Setting a password for the created key.\n");
|
|
+ if (strlen(password) > sizeof(tpm2Data->userauth.buffer) - 1) {
|
|
+ goto error;
|
|
+ }
|
|
+ tpm2Data->userauth.size = strlen(password);
|
|
+ memcpy(&tpm2Data->userauth.buffer[0], password,
|
|
+ tpm2Data->userauth.size);
|
|
+
|
|
+ inSensitive.sensitive.userAuth.size = strlen(password);
|
|
+ memcpy(&inSensitive.sensitive.userAuth.buffer[0], password,
|
|
+ strlen(password));
|
|
+ } else
|
|
+ tpm2Data->emptyAuth = 1;
|
|
+
|
|
+ r = init_tpm_parent(&esys_ctx, parentHandle, &parent);
|
|
+ ERRchktss(tpm2tss_sm2_genkey, r, goto error);
|
|
+
|
|
+ tpm2Data->parent = parentHandle;
|
|
+
|
|
+ DBG("Generating the SM2 key inside the TPM.\n");
|
|
+
|
|
+ r = Esys_Create(esys_ctx, parent,
|
|
+ ESYS_TR_PASSWORD, ESYS_TR_NONE, ESYS_TR_NONE,
|
|
+ &inSensitive, &inPublic, &allOutsideInfo, &allCreationPCR,
|
|
+ &keyPrivate, &keyPublic, NULL, NULL, NULL);
|
|
+ ERRchktss(tpm2tss_sm2_genkey, r, goto error);
|
|
+
|
|
+ DBG("Generated the SM2 key inside the TPM.\n");
|
|
+
|
|
+ tpm2Data->pub = *keyPublic;
|
|
+ tpm2Data->priv = *keyPrivate;
|
|
+
|
|
+ if (!tpm2tss_sm2_setappdata(key, tpm2Data)) {
|
|
+ ERR(tpm2tss_sm2_genkey, TPM2TSS_R_GENERAL_FAILURE);
|
|
+ goto error;
|
|
+ }
|
|
+
|
|
+ if (!populate_sm2(key)) {
|
|
+ goto error;
|
|
+ }
|
|
+
|
|
+ goto end;
|
|
+ error:
|
|
+ r = -1;
|
|
+ tpm2tss_sm2_setappdata(key, NULL);
|
|
+ if (tpm2Data)
|
|
+ OPENSSL_free(tpm2Data);
|
|
+
|
|
+ end:
|
|
+ free(keyPrivate);
|
|
+ free(keyPublic);
|
|
+
|
|
+ if (parent != ESYS_TR_NONE && !parentHandle)
|
|
+ Esys_FlushContext(esys_ctx, parent);
|
|
+
|
|
+ esys_ctx_free(&esys_ctx);
|
|
+
|
|
+ return (r == TSS2_RC_SUCCESS);
|
|
+}
|
|
+
|
|
diff --git a/src/tpm2tss-genkey.c b/src/tpm2tss-genkey.c
|
|
index 2e2c2e5..29429aa 100644
|
|
--- a/src/tpm2tss-genkey.c
|
|
+++ b/src/tpm2tss-genkey.c
|
|
@@ -37,6 +37,7 @@
|
|
#include <openssl/conf.h>
|
|
#include <openssl/engine.h>
|
|
#include <openssl/pem.h>
|
|
+#include <openssl/evp.h>
|
|
|
|
#include "tpm2-tss-engine.h"
|
|
#include "tpm2-tss-engine-common.h"
|
|
@@ -51,7 +52,7 @@ char *help =
|
|
"Arguments:\n"
|
|
" <filename> storage for the encrypted private key\n"
|
|
"Options:\n"
|
|
- " -a, --alg public key algorithm (rsa, ecdsa) (default: rsa)\n"
|
|
+ " -a, --alg public key algorithm (rsa, ecdsa, sm2) (default: rsa)\n"
|
|
" -c, --curve curve for ecc (default: nist_p256)\n"
|
|
" -e, --exponent exponent for rsa (default: 65537)\n"
|
|
" -h, --help print help\n"
|
|
@@ -139,6 +140,10 @@ parse_opts(int argc, char **argv)
|
|
} else if (strcasecmp(optarg, "ecdsa") == 0) {
|
|
opt.alg = TPM2_ALG_ECDSA;
|
|
break;
|
|
+ } else if (strcasecmp(optarg, "sm2") == 0) {
|
|
+ opt.alg = TPM2_ALG_SM2;
|
|
+ opt.curve = TPM2_ECC_SM2_P256;
|
|
+ break;
|
|
} else {
|
|
ERR("Unknown algorithm.\n");
|
|
exit(1);
|
|
@@ -294,6 +299,42 @@ genkey_ecdsa()
|
|
return tpm2Data;
|
|
}
|
|
|
|
+/** Generate an sm2 key
|
|
+ *
|
|
+ * This function calls out to generate an sm2 key using the TPM.
|
|
+ * @retval TPM2_DATA data to be written to disk
|
|
+ * @retval NULL on failure
|
|
+ */
|
|
+static TPM2_DATA *
|
|
+genkey_sm2()
|
|
+{
|
|
+ EC_KEY *eckey = NULL;
|
|
+
|
|
+ eckey = EC_KEY_new();
|
|
+ if (!eckey) {
|
|
+ ERR("out of memory\n");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (!tpm2tss_sm2_genkey(eckey, opt.curve, opt.password, opt.parent)) {
|
|
+ EC_KEY_free(eckey);
|
|
+ ERR("Error: Generating key failed\n");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ TPM2_DATA *tpm2Data = calloc(1, sizeof(*tpm2Data));
|
|
+ if (tpm2Data == NULL) {
|
|
+ ERR("out of memory\n");
|
|
+ EC_KEY_free(eckey);
|
|
+ return NULL;
|
|
+ }
|
|
+ memcpy(tpm2Data, tpm2tss_sm2_getappdata(eckey), sizeof(*tpm2Data));
|
|
+
|
|
+ EC_KEY_free(eckey);
|
|
+
|
|
+ return tpm2Data;
|
|
+}
|
|
+
|
|
/** Main function
|
|
*
|
|
* This function initializes OpenSSL and then calls the key generation
|
|
@@ -362,6 +403,9 @@ main(int argc, char **argv)
|
|
case TPM2_ALG_ECDSA:
|
|
tpm2Data = genkey_ecdsa();
|
|
break;
|
|
+ case TPM2_ALG_SM2:
|
|
+ tpm2Data = genkey_sm2();
|
|
+ break;
|
|
default:
|
|
break;
|
|
}
|
|
--
|
|
2.27.0
|
|
|