mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-09-23 22:03:48 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # README.md
This commit is contained in:
@@ -1,165 +0,0 @@
|
||||
#
|
||||
# crypto/cpk/Makefile
|
||||
#
|
||||
|
||||
DIR= cpk
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
INCLUDES= -I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g -Wall
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=cpktest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= cpk_lib.c cpk_map.c cpk_kap.c cpk_asn1.c cpk_prn.c cpk_err.c
|
||||
LIBOBJ= cpk_lib.o cpk_map.o cpk_kap.o cpk_asn1.o cpk_prn.o cpk_err.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= cpk.h
|
||||
HEADER= $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
cpk_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
|
||||
cpk_asn1.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
cpk_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
cpk_asn1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
cpk_asn1.o: ../../include/openssl/ecdsa.h ../../include/openssl/ecies.h
|
||||
cpk_asn1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
cpk_asn1.o: ../../include/openssl/kdf.h ../../include/openssl/lhash.h
|
||||
cpk_asn1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
cpk_asn1.o: ../../include/openssl/opensslconf.h
|
||||
cpk_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_asn1.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_asn1.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_asn1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_asn1.o: ../../include/openssl/x509_vfy.h cpk.h cpk_asn1.c
|
||||
cpk_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_err.o: ../../include/openssl/buffer.h ../../include/openssl/cpk.h
|
||||
cpk_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
cpk_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
cpk_err.o: ../../include/openssl/ecdsa.h ../../include/openssl/ecies.h
|
||||
cpk_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
cpk_err.o: ../../include/openssl/kdf.h ../../include/openssl/lhash.h
|
||||
cpk_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
cpk_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
cpk_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
cpk_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
cpk_err.o: ../../include/openssl/sm2.h ../../include/openssl/sm3.h
|
||||
cpk_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
cpk_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
cpk_err.o: cpk_err.c
|
||||
cpk_kap.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_kap.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
cpk_kap.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
cpk_kap.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
cpk_kap.o: ../../include/openssl/ecies.h ../../include/openssl/err.h
|
||||
cpk_kap.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
|
||||
cpk_kap.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
cpk_kap.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
cpk_kap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_kap.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_kap.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_kap.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_kap.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_kap.o: ../../include/openssl/x509_vfy.h cpk.h cpk_kap.c
|
||||
cpk_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
|
||||
cpk_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
cpk_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
cpk_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
cpk_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/ecies.h
|
||||
cpk_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
cpk_lib.o: ../../include/openssl/kdf.h ../../include/openssl/lhash.h
|
||||
cpk_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
cpk_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
cpk_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
cpk_lib.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
|
||||
cpk_lib.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_lib.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_lib.o: ../../include/openssl/x509_vfy.h cpk.h cpk_lib.c
|
||||
cpk_map.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_map.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
cpk_map.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
cpk_map.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
cpk_map.o: ../../include/openssl/ecies.h ../../include/openssl/err.h
|
||||
cpk_map.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
|
||||
cpk_map.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
cpk_map.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
cpk_map.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_map.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_map.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_map.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_map.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_map.o: ../../include/openssl/x509_vfy.h cpk.h cpk_map.c
|
||||
cpk_prn.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
cpk_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
cpk_prn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
cpk_prn.o: ../../include/openssl/ecies.h ../../include/openssl/err.h
|
||||
cpk_prn.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
|
||||
cpk_prn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
cpk_prn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
cpk_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_prn.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_prn.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_prn.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_prn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_prn.o: ../../include/openssl/x509_vfy.h cpk.h cpk_prn.c
|
||||
@@ -1,165 +0,0 @@
|
||||
#
|
||||
# crypto/cpk/Makefile
|
||||
#
|
||||
|
||||
DIR= cpk
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
INCLUDES= -I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g -Wall
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=cpktest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= cpk_lib.c cpk_map.c cpk_kap.c cpk_asn1.c cpk_prn.c cpk_err.c
|
||||
LIBOBJ= cpk_lib.o cpk_map.o cpk_kap.o cpk_asn1.o cpk_prn.o cpk_err.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= cpk.h
|
||||
HEADER= $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
cpk_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
|
||||
cpk_asn1.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
cpk_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
cpk_asn1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
cpk_asn1.o: ../../include/openssl/ecdsa.h ../../include/openssl/ecies.h
|
||||
cpk_asn1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
cpk_asn1.o: ../../include/openssl/kdf.h ../../include/openssl/lhash.h
|
||||
cpk_asn1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
cpk_asn1.o: ../../include/openssl/opensslconf.h
|
||||
cpk_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_asn1.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_asn1.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_asn1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_asn1.o: ../../include/openssl/x509_vfy.h cpk.h cpk_asn1.c
|
||||
cpk_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_err.o: ../../include/openssl/buffer.h ../../include/openssl/cpk.h
|
||||
cpk_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
cpk_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
cpk_err.o: ../../include/openssl/ecdsa.h ../../include/openssl/ecies.h
|
||||
cpk_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
cpk_err.o: ../../include/openssl/kdf.h ../../include/openssl/lhash.h
|
||||
cpk_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
cpk_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
cpk_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
cpk_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
cpk_err.o: ../../include/openssl/sm2.h ../../include/openssl/sm3.h
|
||||
cpk_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
cpk_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
cpk_err.o: cpk_err.c
|
||||
cpk_kap.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_kap.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
cpk_kap.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
cpk_kap.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
cpk_kap.o: ../../include/openssl/ecies.h ../../include/openssl/err.h
|
||||
cpk_kap.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
|
||||
cpk_kap.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
cpk_kap.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
cpk_kap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_kap.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_kap.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_kap.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_kap.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_kap.o: ../../include/openssl/x509_vfy.h cpk.h cpk_kap.c
|
||||
cpk_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
|
||||
cpk_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
cpk_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
cpk_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
cpk_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/ecies.h
|
||||
cpk_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
cpk_lib.o: ../../include/openssl/kdf.h ../../include/openssl/lhash.h
|
||||
cpk_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
cpk_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
cpk_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
cpk_lib.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
|
||||
cpk_lib.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_lib.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_lib.o: ../../include/openssl/x509_vfy.h cpk.h cpk_lib.c
|
||||
cpk_map.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_map.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
cpk_map.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
cpk_map.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
cpk_map.o: ../../include/openssl/ecies.h ../../include/openssl/err.h
|
||||
cpk_map.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
|
||||
cpk_map.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
cpk_map.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
cpk_map.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_map.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_map.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_map.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_map.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_map.o: ../../include/openssl/x509_vfy.h cpk.h cpk_map.c
|
||||
cpk_prn.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
cpk_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
cpk_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
cpk_prn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
cpk_prn.o: ../../include/openssl/ecies.h ../../include/openssl/err.h
|
||||
cpk_prn.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
|
||||
cpk_prn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
cpk_prn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
cpk_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
cpk_prn.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
cpk_prn.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
|
||||
cpk_prn.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
|
||||
cpk_prn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
cpk_prn.o: ../../include/openssl/x509_vfy.h cpk.h cpk_prn.c
|
||||
177
crypto/cpk/cpk.h
177
crypto/cpk/cpk.h
@@ -1,177 +0,0 @@
|
||||
/* crypto/cpk/cpk.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 - 2015 The GmSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 GmSSL PROJECT OR
|
||||
* ITS 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CPK_H
|
||||
#define HEADER_CPK_H
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
#include <openssl/ecies.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CPK_MAX_ID_LENGTH 64
|
||||
|
||||
|
||||
typedef struct cpk_master_secret_st {
|
||||
long version;
|
||||
X509_NAME *id;
|
||||
X509_ALGOR *pkey_algor;
|
||||
X509_ALGOR *map_algor;
|
||||
ASN1_OCTET_STRING *secret_factors;
|
||||
} CPK_MASTER_SECRET;
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(CPK_MASTER_SECRET)
|
||||
|
||||
typedef struct cpk_public_params_st {
|
||||
long version;
|
||||
X509_NAME *id;
|
||||
X509_ALGOR *pkey_algor;
|
||||
X509_ALGOR *map_algor;
|
||||
ASN1_OCTET_STRING *public_factors;
|
||||
} CPK_PUBLIC_PARAMS;
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(CPK_PUBLIC_PARAMS)
|
||||
|
||||
X509_ALGOR *CPK_MAP_new_default(void);
|
||||
int CPK_MAP_is_valid(const X509_ALGOR *algor);
|
||||
int CPK_MAP_num_factors(const X509_ALGOR *algor);
|
||||
int CPK_MAP_num_indexes(const X509_ALGOR *algor);
|
||||
int CPK_MAP_str2index(const X509_ALGOR *algor, const char *str, int *index);
|
||||
int CPK_MAP_print(BIO *out, X509_ALGOR *map, int indent, unsigned long flags);
|
||||
|
||||
CPK_MASTER_SECRET *CPK_MASTER_SECRET_create(const char *domain_id, EVP_PKEY *pkey, X509_ALGOR *map_algor);
|
||||
CPK_PUBLIC_PARAMS *CPK_MASTER_SECRET_extract_public_params(CPK_MASTER_SECRET *master);
|
||||
EVP_PKEY *CPK_MASTER_SECRET_extract_private_key(CPK_MASTER_SECRET *master, const char *id);
|
||||
EVP_PKEY *CPK_PUBLIC_PARAMS_extract_public_key(CPK_PUBLIC_PARAMS *params, const char *id);
|
||||
|
||||
|
||||
int CPK_PUBLIC_PARAMS_compute_share_key(CPK_PUBLIC_PARAMS *params,
|
||||
void *out, size_t outlen, const char *id, EVP_PKEY *priv_key,
|
||||
void *(*kdf)(const void *in, size_t inlen, void *out, size_t *outlen));
|
||||
|
||||
char *CPK_MASTER_SECRET_get_name(CPK_MASTER_SECRET *master, char *buf, int size);
|
||||
char *CPK_PUBLIC_PARAMS_get_name(CPK_PUBLIC_PARAMS *params);
|
||||
int CPK_MASTER_SECRET_digest(CPK_MASTER_SECRET *master, const EVP_MD *type, unsigned char *md, unsigned int *len);
|
||||
int CPK_PUBLIC_PARAMS_digest(CPK_PUBLIC_PARAMS *params, const EVP_MD *type, unsigned char *md, unsigned int *len);
|
||||
int CPK_MASTER_SECRET_print(BIO *out, CPK_MASTER_SECRET *master, int indent, unsigned long flags);
|
||||
int CPK_PUBLIC_PARAMS_print(BIO *out, CPK_PUBLIC_PARAMS *params, int indent, unsigned long flags);
|
||||
int CPK_MASTER_SECRET_validate_public_params(CPK_MASTER_SECRET *master, CPK_PUBLIC_PARAMS *params);
|
||||
int CPK_PUBLIC_PARAMS_validate_private_key(CPK_PUBLIC_PARAMS *params, const char *id, const EVP_PKEY *pkey);
|
||||
CPK_MASTER_SECRET *d2i_CPK_MASTER_SECRET_bio(BIO *bp, CPK_MASTER_SECRET **master);
|
||||
int i2d_CPK_MASTER_SECRET_bio(BIO *bp, CPK_MASTER_SECRET *master);
|
||||
CPK_PUBLIC_PARAMS *d2i_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS **params);
|
||||
int i2d_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS *params);
|
||||
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_CPK_strings(void);
|
||||
|
||||
/* Error codes for the CPK functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CPK_F_CPK_MAP_NEW_DEFAULT 100
|
||||
# define CPK_F_CPK_MAP_NUM_FACTORS 101
|
||||
# define CPK_F_CPK_MAP_NUM_INDEXES 102
|
||||
# define CPK_F_CPK_MAP_STR2INDEX 103
|
||||
# define CPK_F_CPK_MASTER_SECRET_CREATE 104
|
||||
# define CPK_F_CPK_MASTER_SECRET_DIGEST 105
|
||||
# define CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY 106
|
||||
# define CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS 107
|
||||
# define CPK_F_CPK_MASTER_SECRET_PRINT 108
|
||||
# define CPK_F_CPK_MASTER_SECRET_VALIDATE_PUBLIC_PARAMS 109
|
||||
# define CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY 110
|
||||
# define CPK_F_CPK_PUBLIC_PARAMS_DIGEST 111
|
||||
# define CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY 112
|
||||
# define CPK_F_CPK_PUBLIC_PARAMS_PRINT 113
|
||||
# define CPK_F_CPK_PUBLIC_PARAMS_VALIDATE_PRIVATE_KEY 114
|
||||
# define CPK_F_X509_ALGOR_GET1_DSA 115
|
||||
# define CPK_F_X509_ALGOR_GET1_EC_KEY 116
|
||||
|
||||
/* Reason codes. */
|
||||
# define CPK_R_ADD_SIGNING_TIME 100
|
||||
# define CPK_R_BAD_ARGUMENT 101
|
||||
# define CPK_R_BAD_DATA 102
|
||||
# define CPK_R_DERIVE_KEY_FAILED 103
|
||||
# define CPK_R_DER_DECODE_FAILED 104
|
||||
# define CPK_R_DIGEST_FAILED 105
|
||||
# define CPK_R_ECIES_DECRYPT_FAILED 106
|
||||
# define CPK_R_ECIES_ENCRYPT_FAILED 107
|
||||
# define CPK_R_INVALID_ID_LENGTH 108
|
||||
# define CPK_R_INVALID_MAP_ALGOR 109
|
||||
# define CPK_R_INVALID_PKEY_TYPE 110
|
||||
# define CPK_R_MAP_FAILED 111
|
||||
# define CPK_R_PKEY_TYPE_NOT_MATCH 112
|
||||
# define CPK_R_SET_RECIP_INFO 113
|
||||
# define CPK_R_SET_SIGNER 114
|
||||
# define CPK_R_STACK_ERROR 115
|
||||
# define CPK_R_UNABLE_TO_FIND_MESSAGE_DIGEST 116
|
||||
# define CPK_R_UNKNOWN_CIPHER_TYPE 117
|
||||
# define CPK_R_UNKNOWN_CURVE 118
|
||||
# define CPK_R_UNKNOWN_DIGEST_TYPE 119
|
||||
# define CPK_R_UNKNOWN_ECDH_TYPE 120
|
||||
# define CPK_R_UNKNOWN_MAP_TYPE 121
|
||||
# define CPK_R_UNKNOWN_PKCS7_TYPE 122
|
||||
# define CPK_R_UNSUPPORTED_PKCS7_CONTENT_TYPE 123
|
||||
# define CPK_R_VERIFY_FAILED 124
|
||||
# define CPK_R_WITHOUT_DECRYPT_KEY 125
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,91 +0,0 @@
|
||||
/* crypto/cpk/cpk_asn1.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 - 2015 The GmSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 GmSSL PROJECT OR
|
||||
* ITS 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 <openssl/asn1t.h>
|
||||
#include "cpk.h"
|
||||
|
||||
ASN1_SEQUENCE(CPK_MASTER_SECRET) = {
|
||||
ASN1_SIMPLE(CPK_MASTER_SECRET, version, LONG),
|
||||
ASN1_SIMPLE(CPK_MASTER_SECRET, id, X509_NAME),
|
||||
ASN1_SIMPLE(CPK_MASTER_SECRET, pkey_algor, X509_ALGOR),
|
||||
ASN1_SIMPLE(CPK_MASTER_SECRET, map_algor, X509_ALGOR),
|
||||
ASN1_SIMPLE(CPK_MASTER_SECRET, secret_factors, ASN1_OCTET_STRING)
|
||||
} ASN1_SEQUENCE_END(CPK_MASTER_SECRET)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(CPK_MASTER_SECRET)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(CPK_MASTER_SECRET)
|
||||
|
||||
ASN1_SEQUENCE(CPK_PUBLIC_PARAMS) = {
|
||||
ASN1_SIMPLE(CPK_PUBLIC_PARAMS, version, LONG),
|
||||
ASN1_SIMPLE(CPK_PUBLIC_PARAMS, id, X509_NAME),
|
||||
ASN1_SIMPLE(CPK_PUBLIC_PARAMS, pkey_algor, X509_ALGOR),
|
||||
ASN1_SIMPLE(CPK_PUBLIC_PARAMS, map_algor, X509_ALGOR),
|
||||
ASN1_SIMPLE(CPK_PUBLIC_PARAMS, public_factors, ASN1_OCTET_STRING)
|
||||
} ASN1_SEQUENCE_END(CPK_PUBLIC_PARAMS)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(CPK_PUBLIC_PARAMS)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(CPK_PUBLIC_PARAMS)
|
||||
|
||||
|
||||
CPK_MASTER_SECRET *d2i_CPK_MASTER_SECRET_bio(BIO *bp, CPK_MASTER_SECRET **master) {
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CPK_MASTER_SECRET), bp, master);
|
||||
}
|
||||
|
||||
int i2d_CPK_MASTER_SECRET_bio(BIO *bp, CPK_MASTER_SECRET *master) {
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CPK_MASTER_SECRET), bp, master);
|
||||
}
|
||||
|
||||
CPK_PUBLIC_PARAMS *d2i_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS **params) {
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CPK_PUBLIC_PARAMS), bp, params);
|
||||
}
|
||||
|
||||
int i2d_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS *params) {
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CPK_PUBLIC_PARAMS), bp, params);
|
||||
}
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/* crypto/cpk/cpk_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2016 The OpenSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
||||
* made to it will be overwritten when the script next updates this file,
|
||||
* only reason strings will be preserved.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/cpk.h>
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_CPK,func,0)
|
||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_CPK,0,reason)
|
||||
|
||||
static ERR_STRING_DATA CPK_str_functs[] = {
|
||||
{ERR_FUNC(CPK_F_CPK_MAP_NEW_DEFAULT), "CPK_MAP_new_default"},
|
||||
{ERR_FUNC(CPK_F_CPK_MAP_NUM_FACTORS), "CPK_MAP_num_factors"},
|
||||
{ERR_FUNC(CPK_F_CPK_MAP_NUM_INDEXES), "CPK_MAP_num_indexes"},
|
||||
{ERR_FUNC(CPK_F_CPK_MAP_STR2INDEX), "CPK_MAP_str2index"},
|
||||
{ERR_FUNC(CPK_F_CPK_MASTER_SECRET_CREATE), "CPK_MASTER_SECRET_create"},
|
||||
{ERR_FUNC(CPK_F_CPK_MASTER_SECRET_DIGEST), "CPK_MASTER_SECRET_digest"},
|
||||
{ERR_FUNC(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY),
|
||||
"CPK_MASTER_SECRET_extract_private_key"},
|
||||
{ERR_FUNC(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS),
|
||||
"CPK_MASTER_SECRET_extract_public_params"},
|
||||
{ERR_FUNC(CPK_F_CPK_MASTER_SECRET_PRINT), "CPK_MASTER_SECRET_print"},
|
||||
{ERR_FUNC(CPK_F_CPK_MASTER_SECRET_VALIDATE_PUBLIC_PARAMS),
|
||||
"CPK_MASTER_SECRET_validate_public_params"},
|
||||
{ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY),
|
||||
"CPK_PUBLIC_PARAMS_compute_share_key"},
|
||||
{ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_DIGEST), "CPK_PUBLIC_PARAMS_digest"},
|
||||
{ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY),
|
||||
"CPK_PUBLIC_PARAMS_extract_public_key"},
|
||||
{ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_PRINT), "CPK_PUBLIC_PARAMS_print"},
|
||||
{ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_VALIDATE_PRIVATE_KEY),
|
||||
"CPK_PUBLIC_PARAMS_validate_private_key"},
|
||||
{ERR_FUNC(CPK_F_X509_ALGOR_GET1_DSA), "X509_ALGOR_GET1_DSA"},
|
||||
{ERR_FUNC(CPK_F_X509_ALGOR_GET1_EC_KEY), "X509_ALGOR_GET1_EC_KEY"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static ERR_STRING_DATA CPK_str_reasons[] = {
|
||||
{ERR_REASON(CPK_R_ADD_SIGNING_TIME), "add signing time"},
|
||||
{ERR_REASON(CPK_R_BAD_ARGUMENT), "bad argument"},
|
||||
{ERR_REASON(CPK_R_BAD_DATA), "bad data"},
|
||||
{ERR_REASON(CPK_R_DERIVE_KEY_FAILED), "derive key failed"},
|
||||
{ERR_REASON(CPK_R_DER_DECODE_FAILED), "der decode failed"},
|
||||
{ERR_REASON(CPK_R_DIGEST_FAILED), "digest failed"},
|
||||
{ERR_REASON(CPK_R_ECIES_DECRYPT_FAILED), "ecies decrypt failed"},
|
||||
{ERR_REASON(CPK_R_ECIES_ENCRYPT_FAILED), "ecies encrypt failed"},
|
||||
{ERR_REASON(CPK_R_INVALID_ID_LENGTH), "invalid id length"},
|
||||
{ERR_REASON(CPK_R_INVALID_MAP_ALGOR), "invalid map algor"},
|
||||
{ERR_REASON(CPK_R_INVALID_PKEY_TYPE), "invalid pkey type"},
|
||||
{ERR_REASON(CPK_R_MAP_FAILED), "map failed"},
|
||||
{ERR_REASON(CPK_R_PKEY_TYPE_NOT_MATCH), "pkey type not match"},
|
||||
{ERR_REASON(CPK_R_SET_RECIP_INFO), "set recip info"},
|
||||
{ERR_REASON(CPK_R_SET_SIGNER), "set signer"},
|
||||
{ERR_REASON(CPK_R_STACK_ERROR), "stack error"},
|
||||
{ERR_REASON(CPK_R_UNABLE_TO_FIND_MESSAGE_DIGEST),
|
||||
"unable to find message digest"},
|
||||
{ERR_REASON(CPK_R_UNKNOWN_CIPHER_TYPE), "unknown cipher type"},
|
||||
{ERR_REASON(CPK_R_UNKNOWN_CURVE), "unknown curve"},
|
||||
{ERR_REASON(CPK_R_UNKNOWN_DIGEST_TYPE), "unknown digest type"},
|
||||
{ERR_REASON(CPK_R_UNKNOWN_ECDH_TYPE), "unknown ecdh type"},
|
||||
{ERR_REASON(CPK_R_UNKNOWN_MAP_TYPE), "unknown map type"},
|
||||
{ERR_REASON(CPK_R_UNKNOWN_PKCS7_TYPE), "unknown pkcs7 type"},
|
||||
{ERR_REASON(CPK_R_UNSUPPORTED_PKCS7_CONTENT_TYPE),
|
||||
"unsupported pkcs7 content type"},
|
||||
{ERR_REASON(CPK_R_VERIFY_FAILED), "verify failed"},
|
||||
{ERR_REASON(CPK_R_WITHOUT_DECRYPT_KEY), "without decrypt key"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void ERR_load_CPK_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(CPK_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings(0, CPK_str_functs);
|
||||
ERR_load_strings(0, CPK_str_reasons);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/* crypto/cpk/cpk_kap.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 - 2015 The GmSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 GmSSL PROJECT OR
|
||||
* ITS 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 <openssl/evp.h>
|
||||
#include <openssl/ecdh.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "cpk.h"
|
||||
|
||||
int CPK_PUBLIC_PARAMS_compute_share_key(CPK_PUBLIC_PARAMS *params,
|
||||
void *out, size_t outlen, const char *id, EVP_PKEY *priv_key,
|
||||
void *(*kdf)(const void *in, size_t inlen, void *out, size_t *outlen))
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY *pub_key = NULL;
|
||||
int pkey_type = OBJ_obj2nid(params->pkey_algor->algorithm);
|
||||
|
||||
OPENSSL_assert(kdf != NULL);
|
||||
|
||||
printf("%d\n", __LINE__);
|
||||
if (EVP_PKEY_id(priv_key) != pkey_type) {
|
||||
CPKerr(CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY,
|
||||
ERR_R_MALLOC_FAILURE); //FIXME: ERR_R_XXX
|
||||
goto err;
|
||||
}
|
||||
if (!(pub_key = CPK_PUBLIC_PARAMS_extract_public_key(params, id))) {
|
||||
CPKerr(CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY,
|
||||
ERR_R_MALLOC_FAILURE); //FIXME: ERR_R_XXX
|
||||
goto err;
|
||||
}
|
||||
if (pkey_type == EVP_PKEY_EC) {
|
||||
|
||||
if (!ECDH_compute_key(out, outlen,
|
||||
EC_KEY_get0_public_key((EC_KEY *)EVP_PKEY_get0(pub_key)),
|
||||
(EC_KEY *)EVP_PKEY_get0(priv_key), kdf)) {
|
||||
CPKerr(CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY,
|
||||
ERR_R_MALLOC_FAILURE); //FIXME: ERR_R_XXX
|
||||
goto err;
|
||||
}
|
||||
} else if (pkey_type == EVP_PKEY_DH) {
|
||||
// not supported yet
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
1029
crypto/cpk/cpk_lib.c
1029
crypto/cpk/cpk_lib.c
File diff suppressed because it is too large
Load Diff
@@ -1,179 +0,0 @@
|
||||
/* crypto/cpk/cpk_map.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 - 2015 The GmSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 GmSSL PROJECT OR
|
||||
* ITS 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/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "cpk.h"
|
||||
|
||||
X509_ALGOR *CPK_MAP_new_default()
|
||||
{
|
||||
X509_ALGOR *algor = NULL;
|
||||
const EVP_MD *md = EVP_sha1();
|
||||
|
||||
if (md != EVP_sha1() && md != EVP_sha384()) {
|
||||
CPKerr(CPK_F_CPK_MAP_NEW_DEFAULT, CPK_R_BAD_ARGUMENT);
|
||||
goto end;
|
||||
}
|
||||
if (!(algor = X509_ALGOR_new())) {
|
||||
CPKerr(CPK_F_CPK_MAP_NEW_DEFAULT, ERR_R_X509_LIB);
|
||||
goto end;
|
||||
}
|
||||
if (!X509_ALGOR_set0(algor, OBJ_nid2obj(EVP_MD_nid(md)),
|
||||
V_ASN1_UNDEF, NULL)) {
|
||||
X509_ALGOR_free(algor);
|
||||
algor = NULL;
|
||||
CPKerr(CPK_F_CPK_MAP_NEW_DEFAULT, ERR_R_X509_LIB);
|
||||
goto end;
|
||||
}
|
||||
end:
|
||||
return algor;
|
||||
}
|
||||
|
||||
int CPK_MAP_is_valid(const X509_ALGOR *algor)
|
||||
{
|
||||
OPENSSL_assert(algor);
|
||||
OPENSSL_assert(algor->algorithm);
|
||||
switch (OBJ_obj2nid(algor->algorithm)) {
|
||||
case NID_sha1:
|
||||
case NID_sha384:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CPK_MAP_num_subset(const X509_ALGOR *algor)
|
||||
{
|
||||
OPENSSL_assert(algor);
|
||||
OPENSSL_assert(algor->algorithm);
|
||||
switch (OBJ_obj2nid(algor->algorithm)) {
|
||||
case NID_sha1:
|
||||
return 32;
|
||||
case NID_sha384:
|
||||
return 4096;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CPK_MAP_num_factors(const X509_ALGOR *algor)
|
||||
{
|
||||
return 1024;
|
||||
}
|
||||
|
||||
int CPK_MAP_num_indexes(const X509_ALGOR *algor)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
int CPK_MAP_num_index(const X509_ALGOR *algor)
|
||||
{
|
||||
OPENSSL_assert(algor);
|
||||
OPENSSL_assert(algor->algorithm);
|
||||
switch (OBJ_obj2nid(algor->algorithm)) {
|
||||
case NID_sha1:
|
||||
return 32;
|
||||
case NID_sha384:
|
||||
return 32;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CPK_MAP_str2index(const X509_ALGOR *algor, const char *str, int *index)
|
||||
{
|
||||
int ret = 0;
|
||||
const EVP_MD *md;
|
||||
unsigned char dgst[EVP_MAX_MD_SIZE];
|
||||
unsigned int dgstlen;
|
||||
BIGNUM *bn = NULL;
|
||||
int i, num_index, num_subset;
|
||||
|
||||
OPENSSL_assert(algor);
|
||||
OPENSSL_assert(algor->algorithm);
|
||||
OPENSSL_assert(str);
|
||||
OPENSSL_assert(strlen(str) > 0);
|
||||
|
||||
if (!CPK_MAP_is_valid(algor)) {
|
||||
CPKerr(CPK_F_CPK_MAP_STR2INDEX, CPK_R_INVALID_MAP_ALGOR);
|
||||
goto err;
|
||||
}
|
||||
if (!index) {
|
||||
ret = CPK_MAP_num_index(algor);
|
||||
goto err;
|
||||
}
|
||||
if (!(md = EVP_get_digestbyobj(algor->algorithm))) {
|
||||
CPKerr(CPK_F_CPK_MAP_STR2INDEX, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (!EVP_Digest(str, strlen(str), dgst, &dgstlen, md, NULL)) {
|
||||
CPKerr(CPK_F_CPK_MAP_STR2INDEX, ERR_R_EVP_LIB);
|
||||
return 0;
|
||||
}
|
||||
if (!(bn = BN_new())) {
|
||||
CPKerr(CPK_F_CPK_MAP_STR2INDEX, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (!BN_bin2bn(dgst, dgstlen, bn)) {
|
||||
CPKerr(CPK_F_CPK_MAP_STR2INDEX, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_index = CPK_MAP_num_index(algor);
|
||||
num_subset = CPK_MAP_num_subset(algor);
|
||||
|
||||
for (i = 0; i < num_index; i++) {
|
||||
int r = BN_mod_word(bn, num_subset);
|
||||
index[i] = num_subset * i + r;
|
||||
}
|
||||
ret = num_index;
|
||||
err:
|
||||
if (bn) BN_free(bn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/* crypto/cpk/cpk_prn.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 - 2015 The GmSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 GmSSL PROJECT OR
|
||||
* ITS 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/bio.h>
|
||||
#include "cpk.h"
|
||||
|
||||
int CPK_MASTER_SECRET_print(BIO *out, CPK_MASTER_SECRET *master,
|
||||
int indent, unsigned long flags)
|
||||
{
|
||||
|
||||
BIO_printf(out, "%s() not implemented\n", __FUNCTION__);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CPK_PUBLIC_PARAMS_print(BIO *out, CPK_PUBLIC_PARAMS *params,
|
||||
int indent, unsigned long flags)
|
||||
{
|
||||
BIO_printf(out, "%s() not implemented\n", __FUNCTION__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,220 +0,0 @@
|
||||
/* crypto/cpk/cpktest.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 - 2015 The GmSSL Project. 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. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 GmSSL PROJECT OR
|
||||
* ITS 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/cpk.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include <openssl/ecies.h>
|
||||
|
||||
|
||||
const char *id_short = "id";
|
||||
const char *id_long =
|
||||
"123456789022345678903234567890423456789052345678906234567890"
|
||||
"123456789022345678903234567890423456789052345678906234567890";
|
||||
|
||||
|
||||
|
||||
int EVP_PKEY_print_fp(const EVP_PKEY *pkey, FILE *fp)
|
||||
{
|
||||
ASN1_PCTX *ctx = ASN1_PCTX_new();
|
||||
BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);
|
||||
|
||||
EVP_PKEY_print_params(bio, pkey, 0, ctx);
|
||||
EVP_PKEY_print_public(bio, pkey, 0, ctx);
|
||||
EVP_PKEY_print_private(bio, pkey, 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int r, i;
|
||||
KDF_FUNC kdf = NULL;
|
||||
EC_GROUP *ec_group = NULL;
|
||||
EC_KEY *ec_key = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY *pub_key = NULL;
|
||||
EVP_PKEY *priv_key = NULL;
|
||||
X509_ALGOR *map = NULL;
|
||||
CPK_MASTER_SECRET *master = NULL;
|
||||
CPK_PUBLIC_PARAMS *params = NULL;
|
||||
BIO *bio_out = NULL;
|
||||
unsigned char *buf = NULL;
|
||||
unsigned char *p;
|
||||
const unsigned char *cp;
|
||||
int len;
|
||||
|
||||
/* init openssl global functions */
|
||||
ERR_load_crypto_strings();
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
/* prepare cpk setup parameters */
|
||||
ec_key = EC_KEY_new_by_curve_name(OBJ_sn2nid("prime192v1"));
|
||||
assert(ec_key != NULL);
|
||||
|
||||
EC_GROUP_set_asn1_flag((EC_GROUP *)EC_KEY_get0_group(ec_key), OPENSSL_EC_NAMED_CURVE);
|
||||
r = EC_KEY_generate_key(ec_key);
|
||||
assert(r == 1);
|
||||
|
||||
pkey = EVP_PKEY_new();
|
||||
assert(pkey != NULL);
|
||||
r = EVP_PKEY_set1_EC_KEY(pkey, ec_key);
|
||||
assert(r == 1);
|
||||
map = CPK_MAP_new_default();
|
||||
assert(map != NULL);
|
||||
|
||||
|
||||
//EVP_PKEY_print_fp(pkey, stdout);
|
||||
|
||||
/* generate master_secret and public_params */
|
||||
master = CPK_MASTER_SECRET_create("domainid", pkey, map);
|
||||
OPENSSL_assert(master);
|
||||
|
||||
bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
OPENSSL_assert(bio_out);
|
||||
|
||||
r = CPK_MASTER_SECRET_print(bio_out, master, 0, 0);
|
||||
assert(r == 1);
|
||||
|
||||
EVP_PKEY_free(pkey);
|
||||
pkey = NULL;
|
||||
pkey = CPK_MASTER_SECRET_extract_private_key(master, "id");
|
||||
assert(pkey != NULL);
|
||||
EVP_PKEY_free(pkey);
|
||||
//pkey = CPK_MASTER_SECRET_extract_private_key(master, NULL);
|
||||
//assert(pkey == NULL);
|
||||
pkey = CPK_MASTER_SECRET_extract_private_key(master, id_long);
|
||||
assert(pkey != NULL);
|
||||
printf("EVP_PKEY of '%s':\n", id_long);
|
||||
EVP_PKEY_print_fp(pkey, stdout);
|
||||
printf("\n");
|
||||
|
||||
params = CPK_MASTER_SECRET_extract_public_params(master);
|
||||
assert(params);
|
||||
r = CPK_PUBLIC_PARAMS_print(bio_out, params, 0, 0);
|
||||
assert(r == 1);
|
||||
printf("\n");
|
||||
|
||||
printf("test CPK_PUBLIC_PARAMS_extract_public_key()\n");
|
||||
pub_key = CPK_PUBLIC_PARAMS_extract_public_key(params, id_short);
|
||||
assert(pub_key != NULL);
|
||||
EVP_PKEY_free(pub_key);
|
||||
|
||||
pub_key = CPK_PUBLIC_PARAMS_extract_public_key(params, id_long);
|
||||
assert(pub_key != NULL);
|
||||
printf("Public Key of '%s':\n", id_long);
|
||||
EVP_PKEY_print_fp(pkey, stdout);
|
||||
printf("\n");
|
||||
|
||||
|
||||
r = CPK_MASTER_SECRET_validate_public_params(master, params);
|
||||
assert(r == 1);
|
||||
if (priv_key) EVP_PKEY_free(priv_key);
|
||||
priv_key = CPK_MASTER_SECRET_extract_private_key(master, "identity");
|
||||
assert(priv_key);
|
||||
r = CPK_PUBLIC_PARAMS_validate_private_key(params, "identity", priv_key);
|
||||
assert(r == 1);
|
||||
r = CPK_PUBLIC_PARAMS_validate_private_key(params, "id", priv_key);
|
||||
assert(r == 0);
|
||||
|
||||
/* der encoding and decoding */
|
||||
len = i2d_CPK_MASTER_SECRET(master, NULL);
|
||||
assert(len > 0);
|
||||
if (buf != NULL) OPENSSL_free(buf);
|
||||
buf = OPENSSL_malloc(len);
|
||||
assert(buf != NULL);
|
||||
p = buf;
|
||||
len = i2d_CPK_MASTER_SECRET(master, &p);
|
||||
assert(len > 0);
|
||||
assert(p - buf == len);
|
||||
|
||||
cp = buf;
|
||||
if (master) CPK_MASTER_SECRET_free(master);
|
||||
master = NULL;
|
||||
master = d2i_CPK_MASTER_SECRET(NULL, &cp, len);
|
||||
assert(master != NULL);
|
||||
r = CPK_MASTER_SECRET_validate_public_params(master, params);
|
||||
assert(r == 1);
|
||||
|
||||
kdf = KDF_get_x9_63(EVP_sha1());
|
||||
assert(kdf != NULL);
|
||||
|
||||
|
||||
if (priv_key != NULL) EVP_PKEY_free(priv_key);
|
||||
priv_key = CPK_MASTER_SECRET_extract_private_key(master, "Alice");
|
||||
assert(priv_key != NULL);
|
||||
|
||||
if (buf != NULL) OPENSSL_free(buf);
|
||||
buf = OPENSSL_malloc(1024);
|
||||
assert(buf != NULL);
|
||||
r = CPK_PUBLIC_PARAMS_compute_share_key(params, buf, 64, "Bob", priv_key, kdf);
|
||||
for (i = 0; i < 64; i++) printf("%02x", buf[i]); printf("\n");
|
||||
|
||||
if (priv_key != NULL)
|
||||
EVP_PKEY_free(priv_key);
|
||||
priv_key = CPK_MASTER_SECRET_extract_private_key(master, "Bob");
|
||||
assert(priv_key != NULL);
|
||||
r = CPK_PUBLIC_PARAMS_compute_share_key(params, buf, 64, "Alice", priv_key, kdf);
|
||||
for (i = 0; i < 64; i++) printf("%02x", buf[i]); printf("\n");
|
||||
|
||||
|
||||
printf("ok\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user