diff --git a/MINFO b/MINFO new file mode 100644 index 00000000..c6102169 --- /dev/null +++ b/MINFO @@ -0,0 +1,1487 @@ +RELATIVE_DIRECTORY=. +AES_ENC=aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o +AR=ar r +ARFLAGS= +AS=cc -c +ASFLAG=-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM +BASEADDR=0xFB00000 +BASENAME=openssl +BF_ENC=bf_enc.o +BN_ASM=x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o +BUILDENV=PLATFORM='darwin64-x86_64-cc' PROCESSOR='' CC='cc' CFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM' AS='cc' ASFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -c' AR='ar r' NM='nm' RANLIB='/opt/local/bin/ranlib' CROSS_COMPILE='' PERL='/opt/local/bin/perl5' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha mdc2 hmac ripemd whrlpool sm3 des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc bn ec rsa dsa ecdsa dh ecdh ecies dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local' OPENSSLDIR='/usr/local/openssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='-arch x86_64 -dynamiclib' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='.1.0.0.dylib' SHLIB_TARGET='darwin-shared' PEX_LIBS='-Wl,-search_paths_first' EX_LIBS='' CPUID_OBJ='x86_64cpuid.o' BN_ASM='x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o' EC_ASM='ecp_nistz256.o ecp_nistz256-x86_64.o' DES_ENC='des_enc.o fcrypt_b.o' AES_ENC='aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o' CMLL_ENC='cmll-x86_64.o cmll_misc.o' BF_ENC='bf_enc.o' CAST_ENC='c_enc.o' RC4_ENC='rc4_enc.o rc4_skey.o' RC5_ENC='rc5_enc.o' SHA1_ASM_OBJ='sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o' MD5_ASM_OBJ='md5-x86_64.o' RMD160_ASM_OBJ='' WP_ASM_OBJ='wp-x86_64.o' MODES_ASM_OBJ='ghash-x86_64.o aesni-gcm-x86_64.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='macosx' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= +BUILD_CMD=if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e PLATFORM='darwin64-x86_64-cc' PROCESSOR='' CC='cc' CFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM' AS='cc' ASFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -c' AR='ar r' NM='nm' RANLIB='/opt/local/bin/ranlib' CROSS_COMPILE='' PERL='/opt/local/bin/perl5' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha mdc2 hmac ripemd whrlpool sm3 des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc bn ec rsa dsa ecdsa dh ecdh ecies dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local' OPENSSLDIR='/usr/local/openssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='-arch x86_64 -dynamiclib' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='.1.0.0.dylib' SHLIB_TARGET='darwin-shared' PEX_LIBS='-Wl,-search_paths_first' EX_LIBS='' CPUID_OBJ='x86_64cpuid.o' BN_ASM='x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o' EC_ASM='ecp_nistz256.o ecp_nistz256-x86_64.o' DES_ENC='des_enc.o fcrypt_b.o' AES_ENC='aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o' CMLL_ENC='cmll-x86_64.o cmll_misc.o' BF_ENC='bf_enc.o' CAST_ENC='c_enc.o' RC4_ENC='rc4_enc.o rc4_skey.o' RC5_ENC='rc5_enc.o' SHA1_ASM_OBJ='sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o' MD5_ASM_OBJ='md5-x86_64.o' RMD160_ASM_OBJ='' WP_ASM_OBJ='wp-x86_64.o' MODES_ASM_OBJ='ghash-x86_64.o aesni-gcm-x86_64.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='macosx' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi +BUILD_ONE_CMD=if expr " crypto ssl engines apps test tools " : ".* $$dir " >/dev/null 2>&1; then if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e PLATFORM='darwin64-x86_64-cc' PROCESSOR='' CC='cc' CFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM' AS='cc' ASFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -c' AR='ar r' NM='nm' RANLIB='/opt/local/bin/ranlib' CROSS_COMPILE='' PERL='/opt/local/bin/perl5' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha mdc2 hmac ripemd whrlpool sm3 des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc bn ec rsa dsa ecdsa dh ecdh ecies dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local' OPENSSLDIR='/usr/local/openssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='-arch x86_64 -dynamiclib' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='.1.0.0.dylib' SHLIB_TARGET='darwin-shared' PEX_LIBS='-Wl,-search_paths_first' EX_LIBS='' CPUID_OBJ='x86_64cpuid.o' BN_ASM='x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o' EC_ASM='ecp_nistz256.o ecp_nistz256-x86_64.o' DES_ENC='des_enc.o fcrypt_b.o' AES_ENC='aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o' CMLL_ENC='cmll-x86_64.o cmll_misc.o' BF_ENC='bf_enc.o' CAST_ENC='c_enc.o' RC4_ENC='rc4_enc.o rc4_skey.o' RC5_ENC='rc5_enc.o' SHA1_ASM_OBJ='sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o' MD5_ASM_OBJ='md5-x86_64.o' RMD160_ASM_OBJ='' WP_ASM_OBJ='wp-x86_64.o' MODES_ASM_OBJ='ghash-x86_64.o aesni-gcm-x86_64.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='macosx' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi; fi +CAST_ENC=c_enc.o +CC=cc +CFLAG=-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM +CLEARENV=TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ +CMLL_ENC=cmll-x86_64.o cmll_misc.o +CONFIGURE_ARGS=darwin64-x86_64-cc --prefix=/usr/local --openssldir=/usr/local/openssl +CPUID_OBJ=x86_64cpuid.o +DEPFLAG=-DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST +DES_ENC=des_enc.o fcrypt_b.o +DIRS=crypto ssl engines apps test tools +EC_ASM=ecp_nistz256.o ecp_nistz256-x86_64.o +EDIRS=times doc bugs util include certs ms shlib mt demos perl sf dep VMS +ENGDIRS=ccgost +ENGINES_ASM_OBJ= +EXE_EXT= +EXHEADER=e_os2.h +EX_LIBS= +FIPSCANLIB= +FIPSDIR=/usr/local/ssl/fips-2.0 +FIPSLIBDIR= +GENERAL=Makefile +HEADER=e_os.h +HERE=. +HTMLDIR=/usr/local/openssl/html +HTMLSUFFIX=html +INSTALLTOP=/usr/local +INSTALL_PREFIX= +KRB5_INCLUDES= +LIBDIR=lib +LIBKRB5= +LIBS=libcrypto.a libssl.a +LIBZLIB= +MAJOR=1 +MAKEDEPPROG=makedepend +MAKEFILE=Makefile +MAN1=1 +MAN3=3 +MANDIR=/usr/local/openssl/man +MANSUFFIX= +MD5_ASM_OBJ=md5-x86_64.o +MINOR=0.2 +MODES_ASM_OBJ=ghash-x86_64.o aesni-gcm-x86_64.o +NAME=openssl-1.0.2d +NM=nm +ONEDIRS=out tmp +OPENSSLDIR=/usr/local/openssl +OPTIONS=--prefix=/usr/local --openssldir=/usr/local/openssl no-ec_nistp_64_gcc_128 no-gmp no-jpake no-krb5 no-libunbound no-md2 no-rc5 no-rfc3779 no-sctp no-shared no-ssl-trace no-store no-unit-test no-zlib no-zlib-dynamic static-engine +PERL=/opt/local/bin/perl5 +PERLASM_SCHEME=macosx +PEX_LIBS=-Wl,-search_paths_first +PLATFORM=darwin64-x86_64-cc +PROCESSOR= +RANLIB=/opt/local/bin/ranlib +RC4_ENC=rc4_enc.o rc4_skey.o +RC5_ENC=rc5_enc.o +RECURSIVE_BUILD_CMD=for dir in crypto ssl engines apps test tools; do if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e PLATFORM='darwin64-x86_64-cc' PROCESSOR='' CC='cc' CFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM' AS='cc' ASFLAG='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -c' AR='ar r' NM='nm' RANLIB='/opt/local/bin/ranlib' CROSS_COMPILE='' PERL='/opt/local/bin/perl5' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha mdc2 hmac ripemd whrlpool sm3 des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc bn ec rsa dsa ecdsa dh ecdh ecies dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local' OPENSSLDIR='/usr/local/openssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='-arch x86_64 -dynamiclib' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='.1.0.0.dylib' SHLIB_TARGET='darwin-shared' PEX_LIBS='-Wl,-search_paths_first' EX_LIBS='' CPUID_OBJ='x86_64cpuid.o' BN_ASM='x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o' EC_ASM='ecp_nistz256.o ecp_nistz256-x86_64.o' DES_ENC='des_enc.o fcrypt_b.o' AES_ENC='aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o' CMLL_ENC='cmll-x86_64.o cmll_misc.o' BF_ENC='bf_enc.o' CAST_ENC='c_enc.o' RC4_ENC='rc4_enc.o rc4_skey.o' RC5_ENC='rc5_enc.o' SHA1_ASM_OBJ='sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o' MD5_ASM_OBJ='md5-x86_64.o' RMD160_ASM_OBJ='' WP_ASM_OBJ='wp-x86_64.o' MODES_ASM_OBJ='ghash-x86_64.o aesni-gcm-x86_64.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='macosx' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi; done +RMD160_ASM_OBJ= +SDIRS=objects md4 md5 sha mdc2 hmac ripemd whrlpool sm3 des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc bn ec rsa dsa ecdsa dh ecdh ecies dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac +SHA1_ASM_OBJ=sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o +SHARED_CRYPTO=libcrypto.1.0.0.dylib +SHARED_LDFLAGS=-arch x86_64 -dynamiclib +SHARED_LIBS= +SHARED_LIBS_LINK_EXTS=.1.dylib .dylib +SHARED_SSL=libssl.1.0.0.dylib +SHELL=/bin/sh +SHLIBDIRS=crypto ssl +SHLIB_EXT=.1.0.0.dylib +SHLIB_MAJOR=1 +SHLIB_MINOR=0.0 +SHLIB_TARGET=darwin-shared +SHLIB_VERSION_HISTORY= +SHLIB_VERSION_NUMBER=1.0.0 +TAR=tar +TARFILE=openssl-1.0.2d.tar +TARFLAGS=--no-recursion +TESTS=alltests +TOP=. +VERSION=1.0.2d +WDIRS=windows +WP_ASM_OBJ=wp-x86_64.o +WTARFILE=openssl-1.0.2d-win.tar +ZLIB_INCLUDE= +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto +AFLAGS=-I. -I.. -I../include +ALL=Makefile README crypto-lib.com install.com cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h constant_time_locl.h crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h ossl_typ.h +AR=ar r +ASFLAGS=-I. -I.. -I../include +CC=cc +CFLAG=-g +CFLAGS=-I. -I.. -I../include -g +CPUID_OBJ=x86_64cpuid.o +DIR=crypto +EXHEADER=crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h ossl_typ.h +EX_LIBS= +GENERAL=Makefile README crypto-lib.com install.com +HEADER=cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h constant_time_locl.h crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h ossl_typ.h +INCLUDE=-I. -I.. -I../include +INCLUDES=-I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include +LIB=../libcrypto.a +LIBOBJ=cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o x86_64cpuid.o +LIBS= +LIBSRC=cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c +MAKEDEPEND=../util/domd .. -MD makedepend +MAKEDEPPROG=makedepend +MAKEFILE=Makefile +PEX_LIBS= +RECURSIVE_MAKE=[ -n "" ] && for i in ; do (cd $$i && echo "making $$target in crypto/$$i..." && -e TOP=../.. DIR=$$i INCLUDES='-I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include ' $$target ) || exit 1; done; +RM=rm -f +SHARED_LIB=libcrypto +SRC=cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c +TEST=constant_time_test.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/objects +ALL=Makefile README o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c objects.h obj_mac.h obj_dat.h obj_xref.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=objects +EXHEADER=objects.h obj_mac.h +GENERAL=Makefile README +HEADER=objects.h obj_mac.h obj_dat.h obj_xref.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o +LIBSRC=o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c +MAKEFILE=Makefile +PERL=perl +SRC=o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/md4 +ALL=Makefile md4_dgst.c md4_one.c md4_locl.h md4.h +APPS=md4.c +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=md4 +EXHEADER=md4.h +GENERAL=Makefile +HEADER=md4_locl.h md4.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=md4_dgst.o md4_one.o +LIBSRC=md4_dgst.c md4_one.c +MAKEFILE=Makefile +SRC=md4_dgst.c md4_one.c +TEST=md4test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/md5 +AFLAGS=-I.. -I../.. -I../../include +ALL=Makefile md5_dgst.c md5_one.c md5_locl.h md5.h +APPS= +AR=ar r +ASFLAGS=-I.. -I../.. -I../../include +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +CPP=cc -E +DIR=md5 +EXHEADER=md5.h +GENERAL=Makefile +HEADER=md5_locl.h md5.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=md5_dgst.o md5_one.o +LIBSRC=md5_dgst.c md5_one.c +MAKEFILE=Makefile +MD5_ASM_OBJ= +SRC=md5_dgst.c md5_one.c +TEST=md5test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/sha +AFLAGS= +ALL=Makefile sha_dgst.c sha1dgst.c sha_one.c sha1_one.c sha256.c sha512.c sha_locl.h sha.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=sha +EXHEADER=sha.h +GENERAL=Makefile +HEADER=sha_locl.h sha.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o sha256.o sha512.o +LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c sha256.c sha512.c +MAKEFILE=Makefile +SHA1_ASM_OBJ= +SRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c sha256.c sha512.c +TEST=shatest.c sha1test.c sha256t.c sha512t.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/mdc2 +ALL=Makefile mdc2dgst.c mdc2_one.c mdc2.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=mdc2 +EXHEADER=mdc2.h +GENERAL=Makefile +HEADER=mdc2.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=mdc2dgst.o mdc2_one.o +LIBSRC=mdc2dgst.c mdc2_one.c +MAKEFILE=Makefile +SRC=mdc2dgst.c mdc2_one.c +TEST=mdc2test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/hmac +ALL=Makefile hmac.c hm_ameth.c hm_pmeth.c hmac.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=hmac +EXHEADER=hmac.h +GENERAL=Makefile +HEADER=hmac.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=hmac.o hm_ameth.o hm_pmeth.o +LIBSRC=hmac.c hm_ameth.c hm_pmeth.c +MAKEFILE=Makefile +SRC=hmac.c hm_ameth.c hm_pmeth.c +TEST=hmactest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ripemd +AFLAGS= +ALL=Makefile rmd_dgst.c rmd_one.c rmd_locl.h rmdconst.h ripemd.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=ripemd +EXHEADER=ripemd.h +GENERAL=Makefile +HEADER=rmd_locl.h rmdconst.h ripemd.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=rmd_dgst.o rmd_one.o +LIBSRC=rmd_dgst.c rmd_one.c +MAKEFILE=Makefile +RIP_ASM_OBJ= +SRC=rmd_dgst.c rmd_one.c +TEST=rmdtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/whrlpool +AFLAGS= +ALL=Makefile wp_dgst.c wp_block.c wp_locl.h whrlpool.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=whrlpool +EXHEADER=whrlpool.h +GENERAL=Makefile +HEADER=wp_locl.h whrlpool.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=wp_dgst.o wp_block.o +LIBSRC=wp_dgst.c wp_block.c +MAKEFILE=Makefile +SRC=wp_dgst.c wp_block.c +TEST=wp_test.c +TOP=../.. +WP_ASM_OBJ=wp_block.o +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/sm3 +AFLAGS=-I.. -I../.. -I../../include +ALL=Makefile sm3.c byteorder.h sm3.h +APPS= +AR=ar r +ASFLAGS=-I.. -I../.. -I../../include +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +CPP=cc -E +DIR=sm3 +EXHEADER=sm3.h +GENERAL=Makefile +HEADER=byteorder.h sm3.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=sm3.o +LIBSRC=sm3.c +MAKEFILE=Makefile +SM3_ASM_OBJ= +SRC=sm3.c +TEST=sm3test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/des +AFLAGS=-I../.. -I../../include +ALL=Makefile cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c read2pwd.c des_locl.h rpc_des.h spr.h des_ver.h des.h des_old.h +APPS= +AR=ar r +ASFLAGS=-I../.. -I../../include +CC=cc +CFLAG=-g +CFLAGS=-I../.. -I../../include -g +CPP=cc -E +DES_ENC=des_enc.o fcrypt_b.o +DIR=des +EXHEADER=des.h des_old.h +GENERAL=Makefile +HEADER=des_locl.h rpc_des.h spr.h des_ver.h des.h des_old.h +INCLUDES=-I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=set_key.o ecb_enc.o cbc_enc.o ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o enc_read.o enc_writ.o ofb64enc.o ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o des_enc.o fcrypt_b.o fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o +LIBSRC=cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c read2pwd.c +MAKEFILE=Makefile +RANLIB=ranlib +SRC=cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c read2pwd.c +TEST=destest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/aes +AES_ENC=aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o +AFLAGS= +ALL=Makefile aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c aes_ctr.c aes_ige.c aes_wrap.c aes_locl.h aes.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=aes +EXHEADER=aes.h +GENERAL=Makefile +HEADER=aes_locl.h aes.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=aes_misc.o aes_ecb.o aes_cfb.o aes_ofb.o aes_ctr.o aes_ige.o aes_wrap.o aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o +LIBSRC=aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c aes_ctr.c aes_ige.c aes_wrap.c +MAKEFILE=Makefile +SRC=aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c aes_ctr.c aes_ige.c aes_wrap.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rc2 +ALL=Makefile rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c rc2_locl.h rc2.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=rc2 +EXHEADER=rc2.h +GENERAL=Makefile +HEADER=rc2_locl.h rc2.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o +LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +MAKEFILE=Makefile +SRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +TEST=rc2test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rc4 +AFLAGS= +ALL=Makefile rc4_skey.c rc4_enc.c rc4_utl.c rc4.h rc4_locl.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=rc4 +EXHEADER=rc4.h +GENERAL=Makefile +HEADER=rc4.h rc4_locl.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=rc4_enc.o rc4_skey.o rc4_utl.o +LIBSRC=rc4_skey.c rc4_enc.c rc4_utl.c +RC4_ENC=rc4_enc.o rc4_skey.o +SRC=rc4_skey.c rc4_enc.c rc4_utl.c +TEST=rc4test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/idea +ALL=Makefile i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c idea_lcl.h idea.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=idea +EXHEADER=idea.h +GENERAL=Makefile +HEADER=idea_lcl.h idea.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o +LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c +MAKEFILE=Makefile +SRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c +TEST=ideatest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/bf +AFLAGS= +ALL=Makefile bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c bf_pi.h bf_locl.h blowfish.h +APPS= +AR=ar r +ASFLAGS= +BF_ENC=bf_enc.o +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=bf +EXHEADER=blowfish.h +GENERAL=Makefile +HEADER=bf_pi.h bf_locl.h blowfish.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=bf_skey.o bf_ecb.o bf_enc.o bf_cfb64.o bf_ofb64.o +LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c +MAKEFILE=Makefile +SRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c +TEST=bftest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/cast +AFLAGS= +ALL=Makefile c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c cast_s.h cast_lcl.h cast.h +APPS= +AR=ar r +ASFLAGS= +CAST_ENC=c_enc.o +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=cast +EXHEADER=cast.h +GENERAL=Makefile +HEADER=cast_s.h cast_lcl.h cast.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=c_skey.o c_ecb.o c_enc.o c_cfb64.o c_ofb64.o +LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +MAKEFILE=Makefile +SRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +TEST=casttest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/camellia +AFLAGS= +ALL=Makefile camellia.c cmll_misc.c cmll_ecb.c cmll_cbc.c cmll_ofb.c cmll_cfb.c cmll_ctr.c cmll_utl.c cmll_locl.h camellia.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CMLL_ENC=camellia.o cmll_misc.o cmll_cbc.o +CPP=cc -E +DIR=camellia +EXHEADER=camellia.h +GENERAL=Makefile +HEADER=cmll_locl.h camellia.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=cmll_ecb.o cmll_ofb.o cmll_cfb.o cmll_ctr.o cmll_utl.o camellia.o cmll_misc.o cmll_cbc.o +LIBSRC=camellia.c cmll_misc.c cmll_ecb.c cmll_cbc.c cmll_ofb.c cmll_cfb.c cmll_ctr.c cmll_utl.c +MAKEFILE=Makefile +SRC=camellia.c cmll_misc.c cmll_ecb.c cmll_cbc.c cmll_ofb.c cmll_cfb.c cmll_ctr.c cmll_utl.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/seed +ALL=Makefile seed.c seed_ecb.c seed_cbc.c seed_cfb.c seed_ofb.c seed_locl.h seed.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=seed +EXHEADER=seed.h +GENERAL=Makefile +HEADER=seed_locl.h seed.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=seed.o seed_ecb.o seed_cbc.o seed_cfb.o seed_ofb.o +LIBSRC=seed.c seed_ecb.c seed_cbc.c seed_cfb.c seed_ofb.c +MAKEFILE=Makefile +SRC=seed.c seed_ecb.c seed_cbc.c seed_cfb.c seed_ofb.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/modes +AFLAGS=-I.. -I../.. -I../../include +ALL=Makefile cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c ccm128.c xts128.c wrap128.c modes_lcl.h modes.h +APPS= +AR=ar r +ASFLAGS=-I.. -I../.. -I../../include +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=modes +EXHEADER=modes.h +GENERAL=Makefile +HEADER=modes_lcl.h modes.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=cbc128.o ctr128.o cts128.o cfb128.o ofb128.o gcm128.o ccm128.o xts128.o wrap128.o +LIBSRC=cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c ccm128.c xts128.c wrap128.c +MAKEFILE=Makefile +MODES_ASM_OBJ= +SRC=cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c ccm128.c xts128.c wrap128.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/sms4 +ALL=Makefile sms4_cbc.c sms4_cfb.c sms4_ecb.c sms4_ofb.c sms4.c ../../include/openssl/modes.h sms4.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=sms4 +EXHEADER=sms4.h +GENERAL=Makefile +HEADER=../../include/openssl/modes.h sms4.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=sms4_cbc.o sms4_cfb.o sms4_ecb.o sms4_ofb.o sms4.o +LIBSRC=sms4_cbc.c sms4_cfb.c sms4_ecb.c sms4_ofb.c sms4.c +MAKEFILE=Makefile +SRC=sms4_cbc.c sms4_cfb.c sms4_ecb.c sms4_ofb.c sms4.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/zuc +AFLAGS= +ALL=Makefile zuc.c zuc.h +APPS= +AR=ar r +ASFLAGS= +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=zuc +EXHEADER=zuc.h +GENERAL=Makefile +HEADER=zuc.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=zuc.o +LIBSRC=zuc.c +RC4_ENC=rc4_enc.o rc4_skey.o +SRC=zuc.c +TEST= +TOP=../.. +ZUC_ENC=zuc.o +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/bn +AFLAGS=-I.. -I../.. -I../../include +ALL=Makefile bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c bn_depr.c bn_const.c bn_x931p.c bn_lcl.h bn_prime.h bn.h +APPS= +AR=ar r +ASFLAGS=-I.. -I../.. -I../../include +BN_ASM=bn_asm.o +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +CPP=cc -E +DIR=bn +EXHEADER=bn.h +GENERAL=Makefile +HEADER=bn_lcl.h bn_prime.h bn.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o bn_asm.o bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o bn_depr.o bn_const.o bn_x931p.o +LIBSRC=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c bn_depr.c bn_const.c bn_x931p.c +MAKEFILE=Makefile +SRC=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c bn_depr.c bn_const.c bn_x931p.c +TEST=bntest.c exptest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ec +AFLAGS=-I.. -I../.. -I../../include +ALL=Makefile ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c ecp_oct.c ec2_oct.c ec_oct.c ec_lcl.h ec.h +APPS= +AR=ar r +ASFLAGS=-I.. -I../.. -I../../include +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=ec +EXHEADER=ec.h +GENERAL=Makefile +HEADER=ec_lcl.h ec.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=ec_lib.o ecp_smpl.o ecp_mont.o ecp_nist.o ec_cvt.o ec_mult.o ec_err.o ec_curve.o ec_check.o ec_print.o ec_asn1.o ec_key.o ec2_smpl.o ec2_mult.o ec_ameth.o ec_pmeth.o eck_prn.o ecp_nistp224.o ecp_nistp256.o ecp_nistp521.o ecp_nistputil.o ecp_oct.o ec2_oct.o ec_oct.o +LIBSRC=ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c ecp_oct.c ec2_oct.c ec_oct.c +MAKEFILE=Makefile +SRC=ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c ecp_oct.c ec2_oct.c ec_oct.c +TEST=ectest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rsa +ALL=Makefile rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c rsa_pmeth.c rsa_crpt.c rsa.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=rsa +EXHEADER=rsa.h +GENERAL=Makefile +HEADER=rsa.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o rsa_pss.o rsa_x931.o rsa_asn1.o rsa_depr.o rsa_ameth.o rsa_prn.o rsa_pmeth.o rsa_crpt.o +LIBSRC=rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c rsa_pmeth.c rsa_crpt.c +MAKEFILE=Makefile +SRC=rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c rsa_pmeth.c rsa_crpt.c +TEST=rsa_test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/dsa +ALL=Makefile dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c dsa_locl.h dsa.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=dsa +EXHEADER=dsa.h +GENERAL=Makefile +HEADER=dsa_locl.h dsa.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o dsa_err.o dsa_ossl.o dsa_depr.o dsa_ameth.o dsa_pmeth.o dsa_prn.o +LIBSRC=dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c +MAKEFILE=Makefile +SRC=dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c +TEST=dsatest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ecdsa +ALL=Makefile ecs_lib.c ecs_asn1.c ecs_ossl.c ecs_sign.c ecs_vrf.c ecs_err.c ecs_locl.h ecdsa.h +APPS= +AR=ar r +CC=cc +CFLAG=-g -Wall +CFLAGS=-I.. -I../.. -I../../include -g -Wall +DIR=ecdsa +EXHEADER=ecdsa.h +GENERAL=Makefile +HEADER=ecs_locl.h ecdsa.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=ecs_lib.o ecs_asn1.o ecs_ossl.o ecs_sign.o ecs_vrf.o ecs_err.o +LIBSRC=ecs_lib.c ecs_asn1.c ecs_ossl.c ecs_sign.c ecs_vrf.c ecs_err.c +MAKEFILE=Makefile +SRC=ecs_lib.c ecs_asn1.c ecs_ossl.c ecs_sign.c ecs_vrf.c ecs_err.c +TEST=ecdsatest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/dh +ALL=Makefile dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c dh_ameth.c dh_pmeth.c dh_prn.c dh_rfc5114.c dh_kdf.c dh.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=dh +EXHEADER=dh.h +GENERAL=Makefile +HEADER=dh.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=dh_asn1.o dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o dh_depr.o dh_ameth.o dh_pmeth.o dh_prn.o dh_rfc5114.o dh_kdf.o +LIBSRC=dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c dh_ameth.c dh_pmeth.c dh_prn.c dh_rfc5114.c dh_kdf.c +MAKEFILE=Makefile +SRC=dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c dh_ameth.c dh_pmeth.c dh_prn.c dh_rfc5114.c dh_kdf.c +TEST=dhtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ecdh +ALL=Makefile ech_lib.c ech_ossl.c ech_key.c ech_err.c ech_kdf.c ech_locl.h ecdh.h +APPS= +AR=ar r +CC=cc +CFLAG=-g -Wall +CFLAGS=-I.. -I../.. -I../../include -g -Wall +DIR=ecdh +EXHEADER=ecdh.h +GENERAL=Makefile +HEADER=ech_locl.h ecdh.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=ech_lib.o ech_ossl.o ech_key.o ech_err.o ech_kdf.o +LIBSRC=ech_lib.c ech_ossl.c ech_key.c ech_err.c ech_kdf.c +MAKEFILE=Makefile +SRC=ech_lib.c ech_ossl.c ech_key.c ech_err.c ech_kdf.c +TEST=ecdhtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ecies +ALL=Makefile ecies_lib.c ecies_asn1.c ecies_err.c kdf_x9_63.c ecies_locl.h ecies.h kdf.h +APPS= +AR=ar r +CC=cc +CFLAG=-g -Wall +CFLAGS=-I.. -I../.. -I../../include -g -Wall +DIR=ecies +EXHEADER=ecies.h kdf.h +GENERAL=Makefile +HEADER=ecies_locl.h ecies.h kdf.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=ecies_lib.o ecies_asn1.o ecies_err.o kdf_x9_63.o +LIBSRC=ecies_lib.c ecies_asn1.c ecies_err.c kdf_x9_63.c +MAKEFILE=Makefile +SRC=ecies_lib.c ecies_asn1.c ecies_err.c kdf_x9_63.c +TEST=eciestest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/dso +ALL=Makefile dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c dso_openssl.c dso_win32.c dso_vms.c dso_beos.c dso.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=dso +EXHEADER=dso.h +GENERAL=Makefile +HEADER=dso.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=dso_dl.o dso_dlfcn.o dso_err.o dso_lib.o dso_null.o dso_openssl.o dso_win32.o dso_vms.o dso_beos.o +LIBSRC=dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c dso_openssl.c dso_win32.c dso_vms.c dso_beos.c +MAKEFILE=Makefile +SRC=dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c dso_openssl.c dso_win32.c dso_vms.c dso_beos.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/engine +ALL=Makefile eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c eng_table.c eng_pkey.c eng_fat.c eng_all.c tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c eng_rdrand.c engine.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=engine +EXHEADER=engine.h +GENERAL=Makefile +HEADER=engine.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o eng_table.o eng_pkey.o eng_fat.o eng_all.o tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o tb_cipher.o tb_digest.o tb_pkmeth.o tb_asnmth.o eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o eng_rdrand.o +LIBSRC=eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c eng_table.c eng_pkey.c eng_fat.c eng_all.c tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c eng_rdrand.c +MAKEFILE=Makefile +SRC=eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c eng_table.c eng_pkey.c eng_fat.c eng_all.c tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c eng_rdrand.c +TEST=enginetest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/buffer +ALL=Makefile buffer.c buf_str.c buf_err.c buffer.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=buffer +EXHEADER=buffer.h +GENERAL=Makefile +HEADER=buffer.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=buffer.o buf_str.o buf_err.o +LIBSRC=buffer.c buf_str.c buf_err.c +MAKEFILE=Makefile +SRC=buffer.c buf_str.c buf_err.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/bio +ALL=Makefile bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c bss_dgram.c bio_lcl.h bio.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=bio +EXHEADER=bio.h +GENERAL=Makefile +HEADER=bio_lcl.h bio.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=bio_lib.o bio_cb.o bio_err.o bss_mem.o bss_null.o bss_fd.o bss_file.o bss_sock.o bss_conn.o bf_null.o bf_buff.o b_print.o b_dump.o b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o bss_dgram.o +LIBSRC=bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c bss_dgram.c +MAKEFILE=Makefile +SRC=bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c bss_dgram.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/stack +ALL=Makefile stack.c stack.h safestack.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=stack +EXHEADER=stack.h safestack.h +GENERAL=Makefile +HEADER=stack.h safestack.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=stack.o +LIBSRC=stack.c +MAKEFILE=Makefile +SRC=stack.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/lhash +ALL=Makefile lhash.c lh_stats.c lhash.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=lhash +EXHEADER=lhash.h +GENERAL=Makefile +HEADER=lhash.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=lhash.o lh_stats.o +LIBSRC=lhash.c lh_stats.c +MAKEFILE=Makefile +SRC=lhash.c lh_stats.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rand +ALL=Makefile md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c rand_win.c rand_unix.c rand_os2.c rand_nw.c rand.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=rand +EXHEADER=rand.h +GENERAL=Makefile +HEADER=rand.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o rand_win.o rand_unix.o rand_os2.o rand_nw.o +LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c rand_win.c rand_unix.c rand_os2.c rand_nw.c +MAKEFILE=Makefile +SRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c rand_win.c rand_unix.c rand_os2.c rand_nw.c +TEST=randtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/err +ALL=Makefile err.c err_all.c err_prn.c err.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=err +EXHEADER=err.h +GENERAL=Makefile +HEADER=err.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=err.o err_all.o err_prn.o +LIBSRC=err.c err_all.c err_prn.c +MAKEFILE=Makefile +SRC=err.c err_all.c err_prn.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/evp +ALL=Makefile encode.c digest.c evp_enc.c evp_key.c evp_acnf.c evp_cnf.c e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c e_rc4.c e_aes.c names.c e_seed.c e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c m_wp.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c m_sm3.c e_sms4.c e_zuc.c evp_locl.h evp.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=evp +EXHEADER=evp.h +GENERAL=Makefile +HEADER=evp_locl.h evp.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=encode.o digest.o evp_enc.o evp_key.o evp_acnf.o evp_cnf.o e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o e_rc4.o e_aes.o names.o e_seed.o e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o m_wp.o m_dss.o m_dss1.o m_mdc2.o m_ripemd.o m_ecdsa.o p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o e_old.o pmeth_lib.o pmeth_fn.o pmeth_gn.o m_sigver.o e_aes_cbc_hmac_sha1.o e_aes_cbc_hmac_sha256.o e_rc4_hmac_md5.o m_sm3.o e_sms4.o e_zuc.o +LIBSRC=encode.c digest.c evp_enc.c evp_key.c evp_acnf.c evp_cnf.c e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c e_rc4.c e_aes.c names.c e_seed.c e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c m_wp.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c m_sm3.c e_sms4.c e_zuc.c +MAKEFILE=Makefile +SRC=encode.c digest.c evp_enc.c evp_key.c evp_acnf.c evp_cnf.c e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c e_rc4.c e_aes.c names.c e_seed.c e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c m_wp.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c m_sm3.c e_sms4.c e_zuc.c +TEST=evp_test.c evp_extra_test.c +TESTDATA=evptests.txt +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/asn1 +ALL=Makefile README a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_enum.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_bignum.c x_long.c x_name.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.c x_nx509.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c tasn_new.c tasn_fre.c tasn_enc.c tasn_dec.c tasn_utl.c tasn_typ.c tasn_prn.c ameth_lib.c f_int.c f_string.c n_pkey.c f_enum.c x_pkey.c a_bool.c x_exten.c bio_asn1.c bio_ndef.c asn_mime.c asn1_gen.c asn1_par.c asn1_lib.c asn1_err.c a_bytes.c a_strnid.c evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c asn_moid.c asn1.h asn1_mac.h asn1t.h asn1_locl.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=asn1 +EXHEADER=asn1.h asn1_mac.h asn1t.h +GENERAL=Makefile README +HEADER=asn1.h asn1_mac.h asn1t.h asn1_locl.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_enum.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o a_strex.o x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_bignum.o x_long.o x_name.o x_x509.o x_x509a.o x_crl.o x_info.o x_spki.o nsseq.o x_nx509.o d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o t_req.o t_x509.o t_x509a.o t_crl.o t_pkey.o t_spki.o t_bitst.o tasn_new.o tasn_fre.o tasn_enc.o tasn_dec.o tasn_utl.o tasn_typ.o tasn_prn.o ameth_lib.o f_int.o f_string.o n_pkey.o f_enum.o x_pkey.o a_bool.o x_exten.o bio_asn1.o bio_ndef.o asn_mime.o asn1_gen.o asn1_par.o asn1_lib.o asn1_err.o a_bytes.o a_strnid.o evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o asn_moid.o +LIBSRC=a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_enum.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_bignum.c x_long.c x_name.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.c x_nx509.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c tasn_new.c tasn_fre.c tasn_enc.c tasn_dec.c tasn_utl.c tasn_typ.c tasn_prn.c ameth_lib.c f_int.c f_string.c n_pkey.c f_enum.c x_pkey.c a_bool.c x_exten.c bio_asn1.c bio_ndef.c asn_mime.c asn1_gen.c asn1_par.c asn1_lib.c asn1_err.c a_bytes.c a_strnid.c evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c asn_moid.c +MAKEFILE=Makefile +SRC=a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_enum.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_bignum.c x_long.c x_name.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.c x_nx509.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c tasn_new.c tasn_fre.c tasn_enc.c tasn_dec.c tasn_utl.c tasn_typ.c tasn_prn.c ameth_lib.c f_int.c f_string.c n_pkey.c f_enum.c x_pkey.c a_bool.c x_exten.c bio_asn1.c bio_ndef.c asn_mime.c asn1_gen.c asn1_par.c asn1_lib.c asn1_err.c a_bytes.c a_strnid.c evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c asn_moid.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/pem +ALL=Makefile pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c pvkfmt.c pem.h pem2.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=pem +EXHEADER=pem.h pem2.h +GENERAL=Makefile +HEADER=pem.h pem2.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o pem_x509.o pem_xaux.o pem_oth.o pem_pk8.o pem_pkey.o pvkfmt.o +LIBSRC=pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c pvkfmt.c +MAKEFILE=Makefile +SRC=pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c pvkfmt.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/x509 +ALL=Makefile README x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509spki.c x509_vfy.c x509_set.c x509cset.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509_att.c x509type.c x509_lu.c x_all.c x509_txt.c x509_trs.c by_file.c by_dir.c x509_vpm.c x509.h x509_vfy.h vpm_int.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=x509 +EXHEADER=x509.h x509_vfy.h +GENERAL=Makefile README +HEADER=x509.h x509_vfy.h vpm_int.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=x509_def.o x509_d2.o x509_r2x.o x509_cmp.o x509_obj.o x509_req.o x509spki.o x509_vfy.o x509_set.o x509cset.o x509rset.o x509_err.o x509name.o x509_v3.o x509_ext.o x509_att.o x509type.o x509_lu.o x_all.o x509_txt.o x509_trs.o by_file.o by_dir.o x509_vpm.o +LIBSRC=x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509spki.c x509_vfy.c x509_set.c x509cset.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509_att.c x509type.c x509_lu.c x_all.c x509_txt.c x509_trs.c by_file.c by_dir.c x509_vpm.c +MAKEFILE=Makefile +SRC=x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509spki.c x509_vfy.c x509_set.c x509cset.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509_att.c x509type.c x509_lu.c x_all.c x509_txt.c x509_trs.c by_file.c by_dir.c x509_vpm.c +TEST=verify_extra_test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/x509v3 +ALL=Makefile README v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c v3_ocsp.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c v3_asid.c v3_addr.c v3_scts.c x509v3.h pcy_int.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=x509v3 +EXHEADER=x509v3.h +GENERAL=Makefile README +HEADER=x509v3.h pcy_int.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o v3_pku.o v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o v3_ocsp.o v3_akeya.o v3_pmaps.o v3_pcons.o v3_ncons.o v3_pcia.o v3_pci.o pcy_cache.o pcy_node.o pcy_data.o pcy_map.o pcy_tree.o pcy_lib.o v3_asid.o v3_addr.o v3_scts.o +LIBSRC=v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c v3_ocsp.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c v3_asid.c v3_addr.c v3_scts.c +MAKEFILE=Makefile +SRC=v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c v3_ocsp.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c v3_asid.c v3_addr.c v3_scts.c +TEST=v3nametest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/conf +ALL=Makefile conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c conf_mall.c conf_sap.c conf_def.h conf.h conf_api.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=conf +EXHEADER=conf.h conf_api.h +GENERAL=Makefile +HEADER=conf_def.h conf.h conf_api.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=conf_err.o conf_lib.o conf_api.o conf_def.o conf_mod.o conf_mall.o conf_sap.o +LIBSRC=conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c conf_mall.c conf_sap.c +MAKEFILE=Makefile +SRC=conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c conf_mall.c conf_sap.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/txt_db +ALL=Makefile txt_db.c txt_db.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=txt_db +EXHEADER=txt_db.h +GENERAL=Makefile +HEADER=txt_db.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=txt_db.o +LIBSRC=txt_db.c +MAKEFILE=Makefile +SRC=txt_db.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/pkcs7 +ALL=Makefile README pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c pk7_mime.c bio_pk7.c pkcs7.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=pkcs7 +EXHEADER=pkcs7.h +EX_LIBS= +GENERAL=Makefile README +HEADER=pkcs7.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=pk7_asn1.o pk7_lib.o pkcs7err.o pk7_doit.o pk7_smime.o pk7_attr.o pk7_mime.o bio_pk7.o +LIBSRC=pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c pk7_mime.c bio_pk7.c +MAKEFILE=Makefile +PEX_LIBS= +SRC=pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c pk7_mime.c bio_pk7.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/pkcs12 +ALL=Makefile p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_mutl.c p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c pkcs12.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=pkcs12 +EXHEADER=pkcs12.h +GENERAL=Makefile +HEADER=pkcs12.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=p12_add.o p12_asn.o p12_attr.o p12_crpt.o p12_crt.o p12_decr.o p12_init.o p12_key.o p12_kiss.o p12_mutl.o p12_utl.o p12_npas.o pk12err.o p12_p8d.o p12_p8e.o +LIBSRC=p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_mutl.c p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c +MAKEFILE=Makefile +SRC=p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_mutl.c p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/comp +ALL=Makefile comp_lib.c comp_err.c c_rle.c c_zlib.c comp.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=comp +EXHEADER=comp.h +GENERAL=Makefile +HEADER=comp.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=comp_lib.o comp_err.o c_rle.o c_zlib.o +LIBSRC=comp_lib.c comp_err.c c_rle.c c_zlib.c +MAKEFILE=Makefile +SRC=comp_lib.c comp_err.c c_rle.c c_zlib.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ocsp +ALL=Makefile README ocsp_asn.c ocsp_ext.c ocsp_ht.c ocsp_lib.c ocsp_cl.c ocsp_srv.c ocsp_prn.c ocsp_vfy.c ocsp_err.c ocsp.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=ocsp +EXHEADER=ocsp.h +GENERAL=Makefile README +HEADER=ocsp.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=ocsp_asn.o ocsp_ext.o ocsp_ht.o ocsp_lib.o ocsp_cl.o ocsp_srv.o ocsp_prn.o ocsp_vfy.o ocsp_err.o +LIBSRC=ocsp_asn.c ocsp_ext.c ocsp_ht.c ocsp_lib.c ocsp_cl.c ocsp_srv.c ocsp_prn.c ocsp_vfy.c ocsp_err.c +MAKEFILE=Makefile +SRC=ocsp_asn.c ocsp_ext.c ocsp_ht.c ocsp_lib.c ocsp_cl.c ocsp_srv.c ocsp_prn.c ocsp_vfy.c ocsp_err.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ui +ALL=Makefile ui_err.c ui_lib.c ui_openssl.c ui_util.c ui_compat.c ui.h ui_compat.h ui_locl.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +COMPATOBJ=ui_compat.o +COMPATSRC=ui_compat.c +DIR=ui +EXHEADER=ui.h ui_compat.h +GENERAL=Makefile +HEADER=ui.h ui_compat.h ui_locl.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=ui_err.o ui_lib.o ui_openssl.o ui_util.o ui_compat.o +LIBSRC=ui_err.c ui_lib.c ui_openssl.c ui_util.c ui_compat.c +MAKEFILE=Makefile +SRC=ui_err.c ui_lib.c ui_openssl.c ui_util.c ui_compat.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/krb5 +ALL=Makefile README krb5_asn.c krb5_asn.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=krb5 +EXHEADER=krb5_asn.h +GENERAL=Makefile README +HEADER=krb5_asn.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=krb5_asn.o +LIBSRC=krb5_asn.c +MAKEFILE=Makefile +SRC=krb5_asn.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/cms +ALL=Makefile cms_lib.c cms_asn1.c cms_att.c cms_io.c cms_smime.c cms_err.c cms_sd.c cms_dd.c cms_cd.c cms_env.c cms_enc.c cms_ess.c cms_pwri.c cms_kari.c cms_lcl.h cms.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=cms +EXHEADER=cms.h +GENERAL=Makefile +HEADER=cms_lcl.h cms.h +INCLUDES=-I.. -I../.. -I../../include +LIB=../../libcrypto.a +LIBOBJ=cms_lib.o cms_asn1.o cms_att.o cms_io.o cms_smime.o cms_err.o cms_sd.o cms_dd.o cms_cd.o cms_env.o cms_enc.o cms_ess.o cms_pwri.o cms_kari.o +LIBSRC=cms_lib.c cms_asn1.c cms_att.c cms_io.c cms_smime.c cms_err.c cms_sd.c cms_dd.c cms_cd.c cms_env.c cms_enc.c cms_ess.c cms_pwri.c cms_kari.c +MAKEFILE=Makefile +SRC=cms_lib.c cms_asn1.c cms_att.c cms_io.c cms_smime.c cms_err.c cms_sd.c cms_dd.c cms_cd.c cms_env.c cms_enc.c cms_ess.c cms_pwri.c cms_kari.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/pqueue +ALL=Makefile pqueue.c pqueue.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=pqueue +EXHEADER=pqueue.h +GENERAL=Makefile +HEADER=pqueue.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=pqueue.o +LIBSRC=pqueue.c +MAKEFILE=Makefile +SRC=pqueue.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ts +ALL=Makefile ts_err.c ts_req_utils.c ts_req_print.c ts_rsp_utils.c ts_rsp_print.c ts_rsp_sign.c ts_rsp_verify.c ts_verify_ctx.c ts_lib.c ts_conf.c ts_asn1.c ts.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=ts +EXHEADER=ts.h +EX_LIBS= +GENERAL=Makefile +HEADER=ts.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +INSTALL_PREFIX= +LIB=../../libcrypto.a +LIBOBJ=ts_err.o ts_req_utils.o ts_req_print.o ts_rsp_utils.o ts_rsp_print.o ts_rsp_sign.o ts_rsp_verify.o ts_verify_ctx.o ts_lib.o ts_conf.o ts_asn1.o +LIBSRC=ts_err.c ts_req_utils.c ts_req_print.c ts_rsp_utils.c ts_rsp_print.c ts_rsp_sign.c ts_rsp_verify.c ts_verify_ctx.c ts_lib.c ts_conf.c ts_asn1.c +MAKEDEPEND=../../util/domd ../.. -MD makedepend +MAKEDEPPROG=makedepend +MAKEFILE=Makefile +OPENSSLDIR=/usr/local/ssl +PEX_LIBS= +SRC=ts_err.c ts_req_utils.c ts_req_print.c ts_rsp_utils.c ts_rsp_print.c ts_rsp_sign.c ts_rsp_verify.c ts_verify_ctx.c ts_lib.c ts_conf.c ts_asn1.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/srp +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../.. -I../../include -g +DIR=srp +EXHEADER=srp.h +GENERAL=Makefile +HEADER=srp.h +INCLUDES=-I.. -I../.. -I../../include +INSTALLTOP=/usr/local/ssl +INSTALL_PREFIX= +LIB=../../libcrypto.a +LIBOBJ=srp_lib.o srp_vfy.o +LIBSRC=srp_lib.c srp_vfy.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=../../util/domd ../.. -MD makedepend +MAKEDEPPROG=makedepend +MAKEFILE=Makefile.ssl +OPENSSLDIR=/usr/local/ssl +SRC=srp_lib.c srp_vfy.c +TEST=srptest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/cmac +ALL=Makefile cmac.c cm_ameth.c cm_pmeth.c cmac.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=cmac +EXHEADER=cmac.h +GENERAL=Makefile +HEADER=cmac.h +INCLUDES= +LIB=../../libcrypto.a +LIBOBJ=cmac.o cm_ameth.o cm_pmeth.o +LIBSRC=cmac.c cm_ameth.c cm_pmeth.c +MAKEFILE=Makefile +SRC=cmac.c cm_ameth.c cm_pmeth.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=ssl +ALL=Makefile README ssl-lib.com install.com s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s3_cbc.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c d1_both.c d1_srtp.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c ssl_conf.c bio_ssl.c ssl_err.c kssl.c t1_reneg.c tls_srp.c t1_trce.c ssl_utst.c ssl.h ssl2.h ssl3.h ssl23.h tls1.h dtls1.h kssl.h srtp.h ssl_locl.h kssl_lcl.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I../crypto -I.. -I../include -g +DIR=ssl +EXHEADER=ssl.h ssl2.h ssl3.h ssl23.h tls1.h dtls1.h kssl.h srtp.h +GENERAL=Makefile README ssl-lib.com install.com +HEADER=ssl.h ssl2.h ssl3.h ssl23.h tls1.h dtls1.h kssl.h srtp.h ssl_locl.h kssl_lcl.h +INCLUDES=-I../crypto -I.. -I../include +KRB5_INCLUDES= +LIB=../libssl.a +LIBOBJ=s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o s3_cbc.o s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o t1_ext.o d1_meth.o d1_srvr.o d1_clnt.o d1_lib.o d1_pkt.o d1_both.o d1_srtp.o ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o ssl_ciph.o ssl_stat.o ssl_rsa.o ssl_asn1.o ssl_txt.o ssl_algs.o ssl_conf.o bio_ssl.o ssl_err.o kssl.o t1_reneg.o tls_srp.o t1_trce.o ssl_utst.o +LIBSRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s3_cbc.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c d1_both.c d1_srtp.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c ssl_conf.c bio_ssl.c ssl_err.c kssl.c t1_reneg.c tls_srp.c t1_trce.c ssl_utst.c +MAKEFILE=Makefile +SHARED_LIB=libssl +SRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s3_cbc.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c d1_both.c d1_srtp.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c ssl_conf.c bio_ssl.c ssl_err.c kssl.c t1_reneg.c tls_srp.c t1_trce.c ssl_utst.c +TEST=ssltest.c heartbeat_test.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=engines +ALL=Makefile engines.com install.com engine_vector.mar e_4758cca.c e_aep.c e_atalla.c e_cswift.c e_gmp.c e_chil.c e_nuron.c e_sureware.c e_ubsec.c e_padlock.c e_capi.c e_4758cca_err.c e_4758cca_err.h e_aep_err.c e_aep_err.h e_atalla_err.c e_atalla_err.h e_cswift_err.c e_cswift_err.h e_gmp_err.c e_gmp_err.h e_chil_err.c e_chil_err.h e_nuron_err.c e_nuron_err.h e_sureware_err.c e_sureware_err.h e_ubsec_err.c e_ubsec_err.h e_capi_err.c e_capi_err.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I../include -g +DIR=engines +ENGDIRS=ccgost +EXHEADER= +EX_LIBS= +GENERAL=Makefile engines.com install.com engine_vector.mar +HEADER=e_4758cca_err.c e_4758cca_err.h e_aep_err.c e_aep_err.h e_atalla_err.c e_atalla_err.h e_cswift_err.c e_cswift_err.h e_gmp_err.c e_gmp_err.h e_chil_err.c e_chil_err.h e_nuron_err.c e_nuron_err.h e_sureware_err.c e_sureware_err.h e_ubsec_err.c e_ubsec_err.h e_capi_err.c e_capi_err.h +INCLUDES=-I../include +LIB=../libcrypto.a +LIBNAMES=4758cca aep atalla cswift gmp chil nuron sureware ubsec padlock capi +LIBOBJ=e_4758cca.o e_aep.o e_atalla.o e_cswift.o e_gmp.o e_chil.o e_nuron.o e_sureware.o e_ubsec.o e_padlock.o e_capi.o +LIBSRC=e_4758cca.c e_aep.c e_atalla.c e_cswift.c e_gmp.c e_chil.c e_nuron.c e_sureware.c e_ubsec.c e_padlock.c e_capi.c +MAKEFILE=Makefile +PEX_LIBS= +RECURSIVE_MAKE=[ -z "ccgost" ] || for i in ccgost ; do (cd $$i && echo "making $$target in engines/$$i..." && -e TOP=../.. DIR=$$i $$target ) || exit 1; done; +SRC=e_4758cca.c e_aep.c e_atalla.c e_cswift.c e_gmp.c e_chil.c e_nuron.c e_sureware.c e_ubsec.c e_padlock.c e_capi.c +TEST= +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=engines/ccgost +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I../../include -g +DIR=ccgost +INCLUDES=-I../../include +LIB=../../libcrypto.a +LIBNAME=gost +LIBOBJ=e_gost_err.o gost2001_keyx.o gost2001.o gost89.o gost94_keyx.o gost_ameth.o gost_asn1.o gost_crypt.o gost_ctl.o gost_eng.o gosthash.o gost_keywrap.o gost_md.o gost_params.o gost_pmeth.o gost_sign.o +LIBSRC=gost2001.c gost2001_keyx.c gost89.c gost94_keyx.c gost_ameth.c gost_asn1.c gost_crypt.c gost_ctl.c gost_eng.c gosthash.c gost_keywrap.c gost_md.c gost_params.c gost_pmeth.c gost_sign.c +MAKEFILE=Makefile +SRC=gost2001.c gost2001_keyx.c gost89.c gost94_keyx.c gost_ameth.c gost_asn1.c gost_crypt.c gost_ctl.c gost_eng.c gosthash.c gost_keywrap.c gost_md.c gost_params.c gost_pmeth.c gost_sign.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=apps +ALL=Makefile makeapps.com install.com verify.c asn1pars.c req.c dgst.c dh.c enc.c passwd.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c rsautl.c dsa.c dsaparam.c ec.c ecparam.c x509.c genrsa.c gendsa.c genpkey.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c app_rand.c version.c sess_id.c ciphers.c nseq.c pkcs12.c pkcs8.c pkey.c pkeyparam.c pkeyutl.c spkac.c smime.c cms.c rand.c engine.c ocsp.c prime.c ts.c srp.c apps.h progs.h s_apps.h testdsa.h testrsa.h +A_OBJ=apps.o +A_SRC=apps.c +CC=cc +CFLAG=-g -static +CFLAGS=-DMONOLITH -I.. -I../include -g -static +DIR=apps +DLIBCRYPTO=../libcrypto.a +DLIBSSL=../libssl.a +EXE=gmssl +EXE_EXT= +EXHEADER= +EX_LIBS= +E_EXE=verify asn1pars req dgst dh dhparam enc passwd gendh errstr ca crl rsa rsautl dsa dsaparam ec ecparam x509 genrsa gendsa genpkey s_server s_client speed s_time version pkcs7 cms crl2pkcs7 sess_id ciphers nseq pkcs12 pkcs8 pkey pkeyparam pkeyutl spkac smime rand engine ocsp prime ts srp +E_OBJ=verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o +E_SRC=verify.c asn1pars.c req.c dgst.c dh.c enc.c passwd.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c rsautl.c dsa.c dsaparam.c ec.c ecparam.c x509.c genrsa.c gendsa.c genpkey.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c app_rand.c version.c sess_id.c ciphers.c nseq.c pkcs12.c pkcs8.c pkey.c pkeyparam.c pkeyutl.c spkac.c smime.c cms.c rand.c engine.c ocsp.c prime.c ts.c srp.c +GENERAL=Makefile makeapps.com install.com +HEADER=apps.h progs.h s_apps.h testdsa.h testrsa.h +INCLUDES=-I.. -I../include +KRB5_INCLUDES= +LIBCRYPTO=-L.. -lcrypto +LIBKRB5= +LIBSSL=-L.. -lssl +MAKEFILE=Makefile +PERL=perl +PEX_LIBS= +PROGRAM=gmssl +PROGS=gmssl.c +RAND_OBJ=app_rand.o +RAND_SRC=app_rand.c +RM=rm -f +SCRIPTS=CA.sh CA.pl tsget +SHLIB_TARGET= +SRC=verify.c asn1pars.c req.c dgst.c dh.c enc.c passwd.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c rsautl.c dsa.c dsaparam.c ec.c ecparam.c x509.c genrsa.c gendsa.c genpkey.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c app_rand.c version.c sess_id.c ciphers.c nseq.c pkcs12.c pkcs8.c pkey.c pkeyparam.c pkeyutl.c spkac.c smime.c cms.c rand.c engine.c ocsp.c prime.c ts.c srp.c +S_OBJ=s_cb.o s_socket.o +S_SRC=s_cb.c s_socket.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=test +ALL=Makefile maketests.com tests.com testenc.com tx509.com trsa.com tcrl.com tsid.com treq.com tpkcs7.com tpkcs7d.com tverify.com testgen.com testss.com testssl.com testca.com VMSca-response.1 VMSca-response.2 bntest.c ectest.c ecdsatest.c ecdhtest.c ideatest.c md2test.c md4test.c md5test.c hmactest.c wp_test.c rc2test.c rc4test.c rc5test.c destest.c shatest.c sha1test.c mdc2test.c rmdtest.c randtest.c dhtest.c enginetest.c casttest.c bftest.c ssltest.c dsatest.c exptest.c rsa_test.c evp_test.c evp_extra_test.c igetest.c jpaketest.c srptest.c asn1test.c v3nametest.c heartbeat_test.c constant_time_test.c verify_extra_test.c testutil.h +ASN1TEST=asn1test +BFTEST=bftest +BNTEST=bntest +BUILD_CMD=shlib_target=; if [ -n "" ]; then shlib_target=""; fi; LIBRARIES="-L.. -lssl -L.. -lcrypto "; -f ../Makefile.shared -e CC="$cc" APPNAME=$$target OBJECTS="$$target.o" LIBDEPS=" $$LIBRARIES " link_app.$ +BUILD_CMD_STATIC=shlib_target=; LIBRARIES="../libssl.a ../libcrypto.a "; -f ../Makefile.shared -e APPNAME=$$target OBJECTS="$$target.o" LIBDEPS=" $$LIBRARIES " link_app.$ +CASTTEST=casttest +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../include -g +CONSTTIMETEST=constant_time_test +DESTEST=destest +DHTEST=dhtest +DIR=test +DLIBCRYPTO=../libcrypto.a +DLIBSSL=../libssl.a +DSATEST=dsatest +ECDHTEST=ecdhtest +ECDSATEST=ecdsatest +ECTEST=ectest +ENGINETEST=enginetest +EVPEXTRATEST=evp_extra_test +EVPTEST=evp_test +EXE=bntest ectest ecdsatest ecdhtest ideatest md2test md4test md5test hmactest wp_test rc2test rc4test rc5test destest shatest sha1test sha256t sha512t mdc2test rmdtest randtest dhtest enginetest bftest casttest ssltest exptest dsatest rsa_test evp_test evp_extra_test igetest jpaketest srptest asn1test v3nametest heartbeat_test constant_time_test verify_extra_test +EXHEADER= +EXPTEST=exptest +EX_LIBS= +FIPS_BUILD_CMD=shlib_target=; if [ -n "" ]; then shlib_target=""; fi; LIBRARIES="-L.. -lssl -L.. -lcrypto "; if [ -z "" -a -n "" ] ; then FIPSLD_CC="cc"; CC=/bin/fipsld; export CC FIPSLD_CC; fi; -f ../Makefile.shared -e CC="$cc" APPNAME=$$target OBJECTS="$$target.o" LIBDEPS=" $$LIBRARIES " link_app.$ +GENERAL=Makefile maketests.com tests.com testenc.com tx509.com trsa.com tcrl.com tsid.com treq.com tpkcs7.com tpkcs7d.com tverify.com testgen.com testss.com testssl.com testca.com VMSca-response.1 VMSca-response.2 +HEADER=testutil.h +HEARTBEATTEST=heartbeat_test +HMACTEST=hmactest +IDEATEST=ideatest +IGETEST=igetest +INCLUDES=-I.. -I../include +JPAKETEST=jpaketest +KRB5_INCLUDES= +LIBCRYPTO=-L.. -lcrypto +LIBKRB5= +LIBSSL=-L.. -lssl +MAKEDEPEND=../util/domd .. -MD +MD2TEST=md2test +MD4TEST=md4test +MD5TEST=md5test +MDC2TEST=mdc2test +METHTEST=methtest +OBJ=bntest.o ectest.o ecdsatest.o ecdhtest.o ideatest.o md2test.o md4test.o md5test.o hmactest.o wp_test.o rc2test.o rc4test.o rc5test.o destest.o shatest.o sha1test.o sha256t.o sha512t.o mdc2test.o rmdtest.o randtest.o dhtest.o enginetest.o casttest.o bftest.o ssltest.o dsatest.o exptest.o rsa_test.o evp_test.o evp_extra_test.o igetest.o jpaketest.o asn1test.o v3nametest.o heartbeat_test.o constant_time_test.o verify_extra_test.o +PERL=perl +PEX_LIBS= +RANDTEST=randtest +RC2TEST=rc2test +RC4TEST=rc4test +RC5TEST=rc5test +RMDTEST=rmdtest +RSATEST=rsa_test +SHA1TEST=sha1test +SHA256TEST=sha256t +SHA512TEST=sha512t +SHATEST=shatest +SRC=bntest.c ectest.c ecdsatest.c ecdhtest.c ideatest.c md2test.c md4test.c md5test.c hmactest.c wp_test.c rc2test.c rc4test.c rc5test.c destest.c shatest.c sha1test.c mdc2test.c rmdtest.c randtest.c dhtest.c enginetest.c casttest.c bftest.c ssltest.c dsatest.c exptest.c rsa_test.c evp_test.c evp_extra_test.c igetest.c jpaketest.c srptest.c asn1test.c v3nametest.c heartbeat_test.c constant_time_test.c verify_extra_test.c +SRPTEST=srptest +SSLTEST=ssltest +TEST=igetest.c +TESTS=alltests +TOP=.. +V3NAMETEST=v3nametest +VERIFYEXTRATEST=verify_extra_test +WPTEST=wp_test +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=tools +APPS=c_rehash +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=tools +GENERAL=Makefile +INCLUDES=-I.. -I../../include +MAKEFILE=Makefile +MISC_APPS=c_hash c_info c_issuer c_name +TEST= +TOP=.. +RELATIVE_DIRECTORY= diff --git a/Makefile b/Makefile index 6038307e..c641504a 100644 --- a/Makefile +++ b/Makefile @@ -145,12 +145,13 @@ SHLIBDIRS= crypto ssl # dirs in crypto to build SDIRS= \ objects \ - md4 md5 sha mdc2 hmac sm3 sms4 ripemd whrlpool \ - des aes rc2 rc4 idea bf cast camellia seed modes \ + md4 md5 sha mdc2 hmac ripemd whrlpool sm3 \ + des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc \ bn ec rsa dsa ecdsa dh ecdh ecies dso engine \ buffer bio stack lhash rand err \ evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \ cms pqueue ts srp cmac + # keep in mind that the above list is adjusted by ./Configure # according to no-xxx arguments... diff --git a/Makefile.bak b/Makefile.bak index 6038307e..d4bb6e63 100644 --- a/Makefile.bak +++ b/Makefile.bak @@ -145,8 +145,8 @@ SHLIBDIRS= crypto ssl # dirs in crypto to build SDIRS= \ objects \ - md4 md5 sha mdc2 hmac sm3 sms4 ripemd whrlpool \ - des aes rc2 rc4 idea bf cast camellia seed modes \ + md4 md5 sha mdc2 hmac ripemd whrlpool sm3 \ + des aes rc2 rc4 idea bf cast camellia seed modes sms4 zuc \ bn ec rsa dsa ecdsa dh ecdh ecies dso engine \ buffer bio stack lhash rand err \ evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \ diff --git a/Makefile.org b/Makefile.org index 33483667..97cab7ed 100644 --- a/Makefile.org +++ b/Makefile.org @@ -143,8 +143,8 @@ SHLIBDIRS= crypto ssl # dirs in crypto to build SDIRS= \ objects \ - md2 md4 md5 sha mdc2 hmac sm3 sms4 ripemd whrlpool \ - des aes rc2 rc4 rc5 idea bf cast camellia seed modes \ + md2 md4 md5 sha mdc2 hmac ripemd whrlpool sm3 \ + des aes rc2 rc4 rc5 idea bf cast camellia seed modes sms4 zuc \ bn ec rsa dsa ecdsa dh ecdh ecies dso engine \ buffer bio stack lhash rand err \ evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \ diff --git a/README.md b/README.md index bc89dedc..9b381781 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,64 @@ -OpenSSL-SM -========== +# GmSSL -The OpenSSL integrated with Chinese national cryptography standard: +GmSSL(国密SSL)是支持国密算法和标准的OpenSSL分支,增加了对国密SM2/SM3/SM4算法和ECIES、CPK、ZUC算法的支持,实现了这些算法与EVP API和命令行工具的集成。 - * SM2: Elliptic curve cryptography, including signature scheme, encryption and key agreement, use the modified `ECDSA` module. - * SM3: Hash algorithm with 256-bit digest length, use `EVP_sm3()` - * SM4: or SMS4, a Feistel-style block cipher with 128-bit key length and 128-bit block size, use `EVP_sms4_ecb()`, `EVP_sms4_cbc()`, `EVP_sms4_cfb()`, `EVP_sms4_ofb()`. +GmSSL的`libcrypto`密码库增加的密码算法包括: -Also SECG algoirthms: +- SM2是国密椭圆曲线公钥密码标准,其中包含数字签名、公钥加密和密钥交换三个具体方案,以及一个256比特素域上的推荐椭圆曲线参数。GmSSL内置了SM2的推荐曲线参数,实现了SM2的签名算法和公钥加密算法。 +- SM3是国密密码杂凑算法标准,输出的杂凑值长度为256比特。 +- SM4是国密分组密码标准,又名SMS4,其分组长度和密钥长度均为128比特。GmSSL实现了SMS4密码及SMS4的ECB、CBC、CFB、OFB等工作模式。 +- X9.63 KDF是密钥派生函数国际标准之一,ECIES和SM2公钥加密方案依赖该算法,GmSSL实现了X9.63 KDF,并用于支持ECIES和SM2公钥加密。 +- ECIES (Elliptic Curve Integrated Encryption Scheme)是椭圆曲线公钥加密的国际标准,可用于加密数据。 +- CPK是由南相浩和陈钟设计的基于身份的密码。GmSSL实现了CPK的系统建立和密钥生成算法,生成的密钥可以用于DSA、ECDH、ECDSA、ECIES、SM2等公钥密码算法。 +- ZUC(祖冲之算法)是由我国设计的序列密码,以32位字为单位输出密钥流,其密钥长度和IV长度均为128比特。GmSSL的ZUC算法处于开发中。 + +GmSSL提供命令行工具`gmssl`,可用于生成SM2签名、SM3摘要、HMAC-SM3消息认证码,支持SM4和ZUC数据加解密。 + +``` bash +$ echo -n abc | gmssl dgst -sm3 +66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 +``` + +GmSSL新增的EVP对象包括`EVP_sm3()`、`EVP_sm4_ecb()`、`EVP_sm4_cbc()`、`EVP_sm4_ofb()`、`EVP_sm4_cfb()`和`EVP_zuc()`。 + +## 安装 + +``` bash +./Configure darwin64-x86_64-cc --prefix=/usr/local --openssldir=/usr/local/openssl +make +sudo make install +``` + + + +## 注意事项 + +### SM2签名中的摘要生成 + +SM2数字签名方案中被签名的杂凑值不仅仅是消息的杂凑值,而是签名者身份信息串联上消息的杂凑值,其中签名者身份信息是签名者的可辨别标识字串、椭圆曲线方程系数、生成元和签名者公钥串联后字串的杂凑值。SM2标准中并未说明签名者的可辨别标识字串格式及获得方式,应用可以采用X.509证书中的Subject字段、CN (CommonName)或自行规定。 + +### SM2参数选择 + +SM2标准中规定采用256比特的椭圆曲线域参数,并采用256比特的密码杂凑算法,并规定某些步骤中须采用SM3。GmSSL的实现支持灵活的参数设定,并支持内置的所有密码杂凑算法,因此应用可以选择安全程度更高的椭圆曲线域参数和密码杂凑算法,如521比特的域参数和SHA-512算法。 + +### 国密对SSL/TLS的扩展 + +国密《中华人民共和国密码行业标准(GM/T 0024-2014) SSL VPN技术规范》在RFC 4346 (TLS 1.1)的握手协议基础上增加了基于ECC和IBC的认证模式和密钥交换模式,增加的相关密码套件包括: + +1. ECDHE_SM4_SM3 {0xe0,0x11} +2. ECC_SM4_SM3 {0xe0,0x13} +3. IBSDH_SM4_SM3 {0xe0,0x15} +4. IBC_SM4_SM3 {0xe0,0x17} +5. RSA_SM4_SM3 {0xe0,0x19} +6. RSA_SM4_SHA1 {0xe0,0x1a} + +## 开发计划 + +- 版本号的定义 +- 在EVP_PKEY中增加对ECIES和SM2的支持 +- 增加对Pairing、IBE和SM9的支持 +- 增加对SSL的支持 +- 通过ENGINE机制增加对密码硬件设备的支持 - * ECIES: Elliptic Curve Integrated Encryption Scheme diff --git a/apps/Makefile b/apps/Makefile index 2c8f90ca..d5f5bc97 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -29,7 +29,7 @@ DLIBSSL=../libssl.a LIBCRYPTO=-L.. -lcrypto LIBSSL=-L.. -lssl -PROGRAM= openssl +PROGRAM= gmssl SCRIPTS=CA.sh CA.pl tsget @@ -945,6 +945,7 @@ speed.o: ../include/openssl/hmac.h ../include/openssl/idea.h speed.o: ../include/openssl/lhash.h ../include/openssl/md4.h speed.o: ../include/openssl/md5.h ../include/openssl/mdc2.h speed.o: ../include/openssl/sm3.h ../include/openssl/sms4.h +speed.o: ../include/openssl/zuc.h speed.o: ../include/openssl/modes.h ../include/openssl/obj_mac.h speed.o: ../include/openssl/objects.h ../include/openssl/ocsp.h speed.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h diff --git a/apps/openssl.c b/apps/gmssl.c similarity index 99% rename from apps/openssl.c rename to apps/gmssl.c index 68731452..32668f4d 100644 --- a/apps/openssl.c +++ b/apps/gmssl.c @@ -386,7 +386,7 @@ int main(int Argc, char *ARGV[]) if (i++) prompt = ">"; else - prompt = "OpenSSL> "; + prompt = "GmSSL> "; fputs(prompt, stdout); fflush(stdout); if (!fgets(p, n, stdin)) diff --git a/apps/openssl b/apps/openssl new file mode 100755 index 00000000..9c0b7781 Binary files /dev/null and b/apps/openssl differ diff --git a/apps/progs.h b/apps/progs.h index 03af13b0..b88a3b92 100644 --- a/apps/progs.h +++ b/apps/progs.h @@ -1,52 +1,6 @@ /* apps/progs.h */ /* automatically generated by progs.pl for openssl.c */ -extern int verify_main(int argc,char *argv[]); -extern int asn1parse_main(int argc,char *argv[]); -extern int req_main(int argc,char *argv[]); -extern int dgst_main(int argc,char *argv[]); -extern int dh_main(int argc,char *argv[]); -extern int dhparam_main(int argc,char *argv[]); -extern int enc_main(int argc,char *argv[]); -extern int passwd_main(int argc,char *argv[]); -extern int gendh_main(int argc,char *argv[]); -extern int errstr_main(int argc,char *argv[]); -extern int ca_main(int argc,char *argv[]); -extern int crl_main(int argc,char *argv[]); -extern int rsa_main(int argc,char *argv[]); -extern int rsautl_main(int argc,char *argv[]); -extern int dsa_main(int argc,char *argv[]); -extern int dsaparam_main(int argc,char *argv[]); -extern int ec_main(int argc,char *argv[]); -extern int ecparam_main(int argc,char *argv[]); -extern int x509_main(int argc,char *argv[]); -extern int genrsa_main(int argc,char *argv[]); -extern int gendsa_main(int argc,char *argv[]); -extern int genpkey_main(int argc,char *argv[]); -extern int s_server_main(int argc,char *argv[]); -extern int s_client_main(int argc,char *argv[]); -extern int speed_main(int argc,char *argv[]); -extern int s_time_main(int argc,char *argv[]); -extern int version_main(int argc,char *argv[]); -extern int pkcs7_main(int argc,char *argv[]); -extern int cms_main(int argc,char *argv[]); -extern int crl2pkcs7_main(int argc,char *argv[]); -extern int sess_id_main(int argc,char *argv[]); -extern int ciphers_main(int argc,char *argv[]); -extern int nseq_main(int argc,char *argv[]); -extern int pkcs12_main(int argc,char *argv[]); -extern int pkcs8_main(int argc,char *argv[]); -extern int pkey_main(int argc,char *argv[]); -extern int pkeyparam_main(int argc,char *argv[]); -extern int pkeyutl_main(int argc,char *argv[]); -extern int spkac_main(int argc,char *argv[]); -extern int smime_main(int argc,char *argv[]); -extern int rand_main(int argc,char *argv[]); -extern int engine_main(int argc,char *argv[]); -extern int ocsp_main(int argc,char *argv[]); -extern int prime_main(int argc,char *argv[]); -extern int ts_main(int argc,char *argv[]); -extern int srp_main(int argc,char *argv[]); #define FUNC_TYPE_GENERAL 1 #define FUNC_TYPE_MD 2 @@ -63,94 +17,6 @@ typedef struct { DECLARE_LHASH_OF(FUNCTION); FUNCTION functions[] = { - {FUNC_TYPE_GENERAL,"verify",verify_main}, - {FUNC_TYPE_GENERAL,"asn1parse",asn1parse_main}, - {FUNC_TYPE_GENERAL,"req",req_main}, - {FUNC_TYPE_GENERAL,"dgst",dgst_main}, -#ifndef OPENSSL_NO_DH - {FUNC_TYPE_GENERAL,"dh",dh_main}, -#endif -#ifndef OPENSSL_NO_DH - {FUNC_TYPE_GENERAL,"dhparam",dhparam_main}, -#endif - {FUNC_TYPE_GENERAL,"enc",enc_main}, - {FUNC_TYPE_GENERAL,"passwd",passwd_main}, -#ifndef OPENSSL_NO_DH - {FUNC_TYPE_GENERAL,"gendh",gendh_main}, -#endif - {FUNC_TYPE_GENERAL,"errstr",errstr_main}, - {FUNC_TYPE_GENERAL,"ca",ca_main}, - {FUNC_TYPE_GENERAL,"crl",crl_main}, -#ifndef OPENSSL_NO_RSA - {FUNC_TYPE_GENERAL,"rsa",rsa_main}, -#endif -#ifndef OPENSSL_NO_RSA - {FUNC_TYPE_GENERAL,"rsautl",rsautl_main}, -#endif -#ifndef OPENSSL_NO_DSA - {FUNC_TYPE_GENERAL,"dsa",dsa_main}, -#endif -#ifndef OPENSSL_NO_DSA - {FUNC_TYPE_GENERAL,"dsaparam",dsaparam_main}, -#endif -#ifndef OPENSSL_NO_EC - {FUNC_TYPE_GENERAL,"ec",ec_main}, -#endif -#ifndef OPENSSL_NO_EC - {FUNC_TYPE_GENERAL,"ecparam",ecparam_main}, -#endif - {FUNC_TYPE_GENERAL,"x509",x509_main}, -#ifndef OPENSSL_NO_RSA - {FUNC_TYPE_GENERAL,"genrsa",genrsa_main}, -#endif -#ifndef OPENSSL_NO_DSA - {FUNC_TYPE_GENERAL,"gendsa",gendsa_main}, -#endif - {FUNC_TYPE_GENERAL,"genpkey",genpkey_main}, -#if !defined(OPENSSL_NO_SOCK) - {FUNC_TYPE_GENERAL,"s_server",s_server_main}, -#endif -#if !defined(OPENSSL_NO_SOCK) - {FUNC_TYPE_GENERAL,"s_client",s_client_main}, -#endif -#ifndef OPENSSL_NO_SPEED - {FUNC_TYPE_GENERAL,"speed",speed_main}, -#endif -#if !defined(OPENSSL_NO_SOCK) - {FUNC_TYPE_GENERAL,"s_time",s_time_main}, -#endif - {FUNC_TYPE_GENERAL,"version",version_main}, - {FUNC_TYPE_GENERAL,"pkcs7",pkcs7_main}, -#ifndef OPENSSL_NO_CMS - {FUNC_TYPE_GENERAL,"cms",cms_main}, -#endif - {FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main}, - {FUNC_TYPE_GENERAL,"sess_id",sess_id_main}, -#if !defined(OPENSSL_NO_SOCK) - {FUNC_TYPE_GENERAL,"ciphers",ciphers_main}, -#endif - {FUNC_TYPE_GENERAL,"nseq",nseq_main}, -#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1) - {FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main}, -#endif - {FUNC_TYPE_GENERAL,"pkcs8",pkcs8_main}, - {FUNC_TYPE_GENERAL,"pkey",pkey_main}, - {FUNC_TYPE_GENERAL,"pkeyparam",pkeyparam_main}, - {FUNC_TYPE_GENERAL,"pkeyutl",pkeyutl_main}, - {FUNC_TYPE_GENERAL,"spkac",spkac_main}, - {FUNC_TYPE_GENERAL,"smime",smime_main}, - {FUNC_TYPE_GENERAL,"rand",rand_main}, -#ifndef OPENSSL_NO_ENGINE - {FUNC_TYPE_GENERAL,"engine",engine_main}, -#endif -#ifndef OPENSSL_NO_OCSP - {FUNC_TYPE_GENERAL,"ocsp",ocsp_main}, -#endif - {FUNC_TYPE_GENERAL,"prime",prime_main}, - {FUNC_TYPE_GENERAL,"ts",ts_main}, -#ifndef OPENSSL_NO_SRP - {FUNC_TYPE_GENERAL,"srp",srp_main}, -#endif #ifndef OPENSSL_NO_MD2 {FUNC_TYPE_MD,"md2",dgst_main}, #endif @@ -172,6 +38,9 @@ FUNCTION functions[] = { #ifndef OPENSSL_NO_RMD160 {FUNC_TYPE_MD,"rmd160",dgst_main}, #endif +#ifndef OPENSSL_NO_SM3 + {FUNC_TYPE_MD,"sm3",dgst_main}, +#endif #ifndef OPENSSL_NO_AES {FUNC_TYPE_CIPHER,"aes-128-cbc",enc_main}, #endif @@ -376,6 +245,9 @@ FUNCTION functions[] = { #endif #ifndef OPENSSL_NO_SMS4 {FUNC_TYPE_CIPHER,"sms4-ofb",enc_main}, +#endif +#ifndef OPENSSL_NO_ZUC + {FUNC_TYPE_CIPHER,"zuc",enc_main}, #endif {0,NULL,NULL} }; diff --git a/apps/progs.pl b/apps/progs.pl index 09be1339..b2dc3706 100644 --- a/apps/progs.pl +++ b/apps/progs.pl @@ -57,7 +57,7 @@ foreach (@ARGV) { print $str; } } -foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160") +foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160","sm3") { push(@files,$_); printf "#ifndef OPENSSL_NO_".uc($_)."\n\t{FUNC_TYPE_MD,\"".$_."\",dgst_main},\n#endif\n"; @@ -83,7 +83,7 @@ foreach ( "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb", "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb", "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb", - "sms4-cbc", "sms4-ecb", "sms4-cfb", "sms4-ofb") + "sms4-cbc", "sms4-ecb", "sms4-cfb", "sms4-ofb", "zuc") { push(@files,$_); @@ -99,6 +99,7 @@ foreach ( elsif ($_ =~ /cast/) { $t="#ifndef OPENSSL_NO_CAST\n${t}#endif\n"; } elsif ($_ =~ /rc5/) { $t="#ifndef OPENSSL_NO_RC5\n${t}#endif\n"; } elsif ($_ =~ /sms4/) { $t="#ifndef OPENSSL_NO_SMS4\n${t}#endif\n"; } + elsif ($_ =~ /zuc/) { $t="#ifndef OPENSSL_NO_ZUC\n${t}#endif\n"; } elsif ($_ =~ /zlib/) { $t="#ifdef ZLIB\n${t}#endif\n"; } print $t; } diff --git a/crypto/cpk/cpk.h b/crypto/cpk/cpk.h new file mode 100644 index 00000000..40896cd8 --- /dev/null +++ b/crypto/cpk/cpk.h @@ -0,0 +1,539 @@ +#ifndef HEADER_CPK_H +#define HEADER_CPK_H + +#include +#include +#include +#include "ecies.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define CPK_LIB_VERSION "0.9" +#define CPK_MAX_ID_LENGTH 64 + + +/** + * @struct CPK_MASTER_SECRET + * @brief The in-memory structure to represent a cpk master secret. + */ +typedef struct cpk_master_secret_st { + long version; /**< The version of the master secret.*/ + X509_NAME *id; /**< The id of the master secret.*/ + X509_ALGOR *pkey_algor; /**< The public key algorithm used in the master secret.*/ + X509_ALGOR *map_algor; /**< The map algorithm used in the master secret.*/ + ASN1_OCTET_STRING *secret_factors; /**< The secret factors of the master secret.*/ +} CPK_MASTER_SECRET; +/** + * @def + * @brief Declare 4 basic ASN1 functions of CPK_MASTER_SECRET and a pointer + * to an ASN1_ITEM with detail information of the fields of + * CPK_MASTER_SECRET in it. + * + * The macro would generate following 4 function declarations and 1 pointer:\n + * CPK_MASTER_SECRET *CPK_MASTER_SECRET_new(void): alloc a new instance of CPK_MASTER_SECRET.\n + * void CPK_MASTER_SECRET_free(CPK_MASTER_SECRET* a): free the instance a.\n + * CPK_MASTER_SECRET *d2i_CPK_MASTER_SECRET(CPK_MASTER_SECRET **a, const unsigned char **in, long len): + * convert the CPK_MASTER_SECRET instance from the DER format to the internal format.\n + * int i2d_CPK_MASTER_SECRET(CPK_MASTER_SECRET *a, unsigned char* out): convert an CPK_MASTER_SECRET + * to the DER format.\n + * ASN1_ITEM* CPK_MASTER_SECRET_it: a pointer to a instance of ASN1_ITEM struct which contains + * information on the conversion between DER and internal.\n + */ +DECLARE_ASN1_FUNCTIONS(CPK_MASTER_SECRET) + + +/** + * @struct CPK_PUBLIC_PARAMS + * @brief The in-memory structure to represent a set of cpk public parameters. + */ +typedef struct cpk_public_params_st { + long version; /**< The version of the public parameters.*/ + X509_NAME *id; /**< The id of the public parameters.*/ + X509_ALGOR *pkey_algor; /**< The public key algorithm used in the public parameters.*/ + X509_ALGOR *map_algor; /**< The map algorithm used in the public parameters.*/ + ASN1_OCTET_STRING *public_factors;/**< The public factors of the public parameters.*/ +} CPK_PUBLIC_PARAMS; +/** + * @brief Declare 4 basic ASN1 functions of CPK_PUBLIC_PARAMS and a pointer to an ASN1_ITEM + * with detail information of the fields of CPK_PUBLIC_PARAMS in it. + * + * The macro would generate following 4 function declarations and 1 pointer:\n + * CPK_PUBLIC_PARAMS *CPK_PUBLIC_PARAMS_new(void): alloc a new instance of CPK_PUBLIC_PARAMS.\n + * void CPK_PUBLIC_PARAMS_free(CPK_PUBLIC_PARAMS* a): free the instance a.\n + * CPK_PUBLIC_PARAMS *d2i_CPK_PUBLIC_PARAMS(CPK_PUBLIC_PARAMS **a, const unsigned char **in, long len): + * convert the CPK_PUBLIC_PARAMS instance from the DER format to the internal format.\n + * int i2d_CPK_PUBLIC_PARAMS(CPK_PUBLIC_PARAMS *a, unsigned char* out): convert a CPK_PUBLIC_PARAMS + * to the DER format.\n + * ASN1_ITEM* CPK_PUBLIC_PARAMS_it: a pointer to a instance of ASN1_ITEM struct which contains + * information on the conversion between DER and internal.\n + */ +DECLARE_ASN1_FUNCTIONS(CPK_PUBLIC_PARAMS) + +/** + * @brief Get a new default map algorithm. + * + * @return Returns a pointer to a new instance of the default map algorithm of the type X509_ALGOR. + */ +X509_ALGOR *CPK_MAP_new_default(); + +/** + * @brief Check if the given map algorithm is valid. + * + * @param[in] algor The pointer to the algorithm to check. + * @return Returns 1 if the given algorithm is valid. + */ +int CPK_MAP_is_valid(const X509_ALGOR *algor); + +/** + * @brief Get the number of factors of the given algorithm. + * + * @param[in] algor The pointer to the algorithm. + * @return Returns the number of factors of the algorithm. + */ +int CPK_MAP_num_factors(const X509_ALGOR *algor); + +/** + * @brief Get the number of indexes of the given algorithm. + * + * @param[in] algor The pointer to the algorithm. + * @return Returns the number of indexes of the algorithm. + */ +int CPK_MAP_num_indexes(const X509_ALGOR *algor); + +/** + * @brief Convert the string to the index vector. + * + * @param[in] algor The pointer to the algorithm to do the map function. + * @param[in] str The pointer to a string in the memory, ended by '\0'. + * @param[out] index The pointer to a array which will receive the index. + * @return Returns 1 on success. + */ +int CPK_MAP_str2index(const X509_ALGOR *algor, const char *str, int *index); + +/** + * @brief Print the parameters of the map algortihm. + * + * @param[out] out A IO abstraction to receive the output stream. + * @param[in] indent The amount of the indentation in the output stream. + * @param[in] flags The flag set to control the ouput. + * @return Returns 1 on success. + */ +int CPK_MAP_print(BIO *out, X509_ALGOR *map, int indent, unsigned long flags); + +/** + * @brief Create a master secret with the given domain id, public key algorithm and map algorithm. + * + * @param[in] domain_id The domain identifier of the master secret. + * @param[in] pkey The pointer to the public key algorithm of the master secret. + * @param[in] map_algor The pointer to the map algorithm of the master secret. + * @return Returns a poniter to the created master secret on success, or NULL on failure. + */ +CPK_MASTER_SECRET *CPK_MASTER_SECRET_create(const char *domain_id, EVP_PKEY *pkey, X509_ALGOR *map_algor); + +/** + * @brief Extract the public parameters from the master secret. + * + * @param[in] master The master secret to extract from. + * @return Returns the pointer to the extracted public parameters on success, or NULL on failure. + */ +CPK_PUBLIC_PARAMS *CPK_MASTER_SECRET_extract_public_params(CPK_MASTER_SECRET *master); + +/** + * @brief Extract the private key of a given identifier from the master secret. + * + * @param[in] master The master secret to extract from. + * @param[in] id The identifier which is used to maps to the private key. + * @return Returns the pointer to the extracted private key on success, or NULL on failure. + */ +EVP_PKEY *CPK_MASTER_SECRET_extract_private_key(CPK_MASTER_SECRET *master, const char *id); + +/** + * @brief Extract the public key of a given identifier from the public parameters. + * + * @param[in] params The public parameters to extract from. + * @param[in] id The identifier which is used to maps to the public key. + * @return Returns the pointer to the extracted public key EVP_PKEY on success, or NULL on failure. + */ +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); + +/** + * @brief Generate the message digest of the given master secret with the given parameters. + * + * This function takes the secret_factors field of the given parameter of CPK_MASTER_SECRET as + * the input and the parameter type of EVP_MD as the message digest + * algorithm to compute the message digest, and put the result in the parameter md, the length + * of the result in the paramter len. + * @param[in] master The master secret to compute the digest. + * @param[in] type The message digest algorithm to use to comput the digest. + * @param[out] md The buffer to receive the result of the computation of message digest. + * @param[out] len If len is not null, the variable it point to will be assigned the length of + * the message digest. + * @return Returns 1 on success, 0 on failure. + */ +int CPK_MASTER_SECRET_digest(CPK_MASTER_SECRET *master, const EVP_MD *type, unsigned char *md, unsigned int *len); + +/** + * @brief Generate the message digest of the given public parameters with the given parameters. + * + * This function takes the secret_factors field of the given parameter of CPK_PUBLIC_PARAMS as + * the input and the parameter type of EVP_MD as the message digest + * algorithm to compute the message digest, and put the result in the parameter md, the length + * of the result in the paramter len. + * @param[in] params The public parameters to compute the digest. + * @param[in] type The message digest algorithm to use to comput the digest. + * @param[out] md The buffer to receive the result of the computation of message digest. + * @param[out] len If len is not null, the variable it point to will be assigned the length of + * the message digest. + * @return Returns 1 on success, 0 on failure. + */ +int CPK_PUBLIC_PARAMS_digest(CPK_PUBLIC_PARAMS *params, const EVP_MD *type, unsigned char *md, unsigned int *len); + +/** + * @brief Print the master secret to a BIO, including the version, the domain uri, the public + * algorithm and the map algorithm. + * + * @param[out] out A IO abstraction to receive the output stream. + * @param[in] master The CPK_MASTER_SECRET instance to print. + * @param[in] indent The amount of the indentation. + * @param[in] flags The flag set to control the ouput. + * @return Returns 1 on success, 0 on failure. + */ +int CPK_MASTER_SECRET_print(BIO *out, CPK_MASTER_SECRET *master, int indent, unsigned long flags); + +/** + * @brief Print the public parameters to a BIO. + * + * @param[out] out A IO abstraction to receive the output stream. + * @param[in] params The CPK_PUBLIC_PARAMS instance to print. + * @param[in] indent The amount of the indentation. + * @param[in] flags The flag set to control the ouput. + * @return Returns 1 on success, 0 on failure. + */ +int CPK_PUBLIC_PARAMS_print(BIO *out, CPK_PUBLIC_PARAMS *params, int indent, unsigned long flags); + +/** + * @brief Validate the public parameters with the given master secret. + * + * @param[in] master The master secret used for the validation. + * @param[in] params The public parameters to validate. + * @return Returns 1 if the public parameter is valid, returns 0 otherwise. + */ +int CPK_MASTER_SECRET_validate_public_params(CPK_MASTER_SECRET *master, CPK_PUBLIC_PARAMS *params); + +/** + * @brief Validate the private key with the given public parameters. + * + * @param[in] params The public parameter used for the validation. + * @param[in] id the identifier of the private key owner. + * @param[in] pkey pkey The private key to validate. + * @return Returns 1 if the private key is valid, returns a integer less or equal than 0 otherwise. + */ +int CPK_PUBLIC_PARAMS_validate_private_key(CPK_PUBLIC_PARAMS *params, const char *id, const EVP_PKEY *pkey); + +/** + * @brief Convert the master secret in DER format in the IO abstraction to an instance of CPK_MASTER_SECRET. + * + * @param[in] bp A pointer to the IO abstraction which ocntaints the master secret in DER format. + * @param[out] master A pointer to receive the pointer to the converted master secret of the type CPK_MASTER_SECRET. + * @return Returns the pointer to the converted master secret of the type CPK_MASTER_SECRET on success, + * or null on failure. + */ +CPK_MASTER_SECRET *d2i_CPK_MASTER_SECRET_bio(BIO *bp, CPK_MASTER_SECRET **master); + +/** + * @brief Convert the master key from CPK_MASTER_SECRET to a byte stream in DER format, and write + * the stream to an IO abstraction. + * + * @param[out] bp A pointer to the IO abstraction which receives the stream. + * @param[in] master A pointer to the master key of the type CPK_MASTER_SECRET. + * @return Returns the size of the output stream on success, of an integer less or equal than 0 + * indicating an error. + */ +int i2d_CPK_MASTER_SECRET_bio(BIO *bp, CPK_MASTER_SECRET *master); + +/** + * @brief Convert the public parameters in DER format in the IO abstraction to an instance of CPK_PUBLIC_PARAMS. + * + * @param[in] bp A pointer to the IO abstraction which ocntaints the public parameters in DER format. + * @param[out] params A pointer to receive the pointer to the converted public parameters of the type CPK_PUBLIC_PARAMS. + * @return Returns the pointer to the converted public parameters of the type CPK_PUBLIC_PARAMS on success, + * or null on failure. + */ +CPK_PUBLIC_PARAMS *d2i_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS **params); + +/** + * @brief Convert the public parameters from CPK_PUBLIC_PARAMS to a byte stream in DER format, + * and write the stream to an IO abstraction. + * + * @param[out] bp A pointer to the IO abstraction which receives the stream. + * @param[in] master A pointer to the public parameters of the type CPK_PUBLIC_PARAMS. + * @return Returns the size of the output stream on success, of an integer less or equal than 0 + * indicating an error. + */ +int i2d_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS *params); + + +/* + * SignerInfo ::= SEQUENCE { + * version INTEGER {1}, + * signer IssuerAndSerialNumber, + * digestAlgor DigestAlgorithmIdentifier, + * signedAttrs [0] IMPLICIT Attributes OPTIONAL, + * signingAlgor SigningAlgorithmIdentifier, + * signature OCTET STRING {{ECDSASigValue}}, + * unsignedAttrs [1] IMPLICIT Attributes OPTIONAL + * } + */ +typedef struct cpk_signer_info_st { + long version; + X509_NAME *signer; + X509_ALGOR *digest_algor; + STACK_OF(X509_ATTRIBUTE) *signed_attr; + X509_ALGOR *sign_algor; + ASN1_OCTET_STRING *signature; + STACK_OF(X509_ATTRIBTE) *unsigned_attr; + EVP_PKEY *_privkey; /* private member */ +} CPK_SIGNER_INFO; +DECLARE_STACK_OF(CPK_SIGNER_INFO) +DECLARE_ASN1_SET_OF(CPK_SIGNER_INFO) +DECLARE_ASN1_FUNCTIONS(CPK_SIGNER_INFO) + +int CPK_SIGNER_INFO_set(CPK_SIGNER_INFO *si, const EVP_MD *sign_alg, const EVP_PKEY *sign_key); +int CPK_SIGNER_INFO_add_attr(CPK_SIGNER_INFO *si, int nid, int atrtype, void *value); +int CPK_SIGNER_INFO_add_signed_attr(CPK_SIGNER_INFO *si, int nid, int atrtype, void *value); +int CPK_SIGNER_INFO_add_signed_time(CPK_SIGNER_INFO *si); +int CPK_SIGNER_INFO_add_signed_digest(CPK_SIGNER_INFO *si, const EVP_MD_CTX *ctx); +ASN1_TYPE *CPK_SIGNER_INFO_get_attr(CPK_SIGNER_INFO *si, int nid); +ASN1_TYPE *CPK_SIGNER_INFO_get_signed_attr(CPK_SIGNER_INFO *si, int nid); +ASN1_UTCTIME *CPK_SIGNER_INFO_get_signed_time(CPK_SIGNER_INFO *si); + +int CPK_SIGNER_INFO_do_sign(CPK_SIGNER_INFO *si, EVP_MD_CTX *md_ctx); +int CPK_SIGNER_INFO_do_verify(const CPK_SIGNER_INFO *si, EVP_MD_CTX *ctx, const CPK_PUBLIC_PARAMS *params); + +/* + * RecipientInfo ::= SEQUENCE { + * version INTEGER {0}, + * recipient IssuerAndSerialNumber, + * keyEncryptionAlgor EncryptionAlgorithmIdentifier, + * encryptedKey OCTET STRING + * } + * RecipientInfos ::= SET OF RecipientInfo + */ +typedef struct cpk_recip_info_st { + long version; + X509_NAME *recipient; + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_data; + /* private */ + EVP_PKEY *_pubkey; +} CPK_RECIP_INFO; +DECLARE_STACK_OF(CPK_RECIP_INFO) +DECLARE_ASN1_SET_OF(CPK_RECIP_INFO) +DECLARE_ASN1_FUNCTIONS(CPK_RECIP_INFO) + +int CPK_RECIP_INFO_set(CPK_RECIP_INFO *ri, const X509_NAME *recipient, const ECIES_PARAMS *ecies); +int CPK_RECIP_INFO_do_encrypt(CPK_RECIP_INFO *ri, const unsigned char *in, size_t inlen); +int CPK_RECIP_INFO_do_decrypt(CPK_RECIP_INFO *ri, const EVP_PKEY *pkey, unsigned char *out, size_t *outlen); + + +/* + * SingerInfos ::= SET OF SignerInfo + * + * SignedData ::= SEQUENCE { + * version INTEGER, + * digestAlgors DigestAlgorithmIdentifiers, + * contentInfo ContentInfo, + * signerInfos SignerInfos, + * } + */ +typedef struct cpk_signed_st { + long version; + STACK_OF(X509_ALGOR) *digest_algors; + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(CPK_SIGINFO) *signer_infos; + struct CPK_CMS_st *contents; +} CPK_SIGNED; +DECLARE_ASN1_FUNCTIONS(CPK_SIGNED) + +typedef struct cpk_enc_content_st { + ASN1_OBJECT *content_type; + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + /* private */ + const EVP_CIPHER *cipher; +} CPK_ENC_CONTENT; +DECLARE_ASN1_FUNCTIONS(CPK_ENC_CONTENT) + +typedef struct cpk_envelope_st { + long version; + STACK_OF(CPK_RECIP_INFO) *recip_infos; + CPK_ENC_CONTENT *enc_data; +} CPK_ENVELOPE; +DECLARE_ASN1_FUNCTIONS(CPK_ENVELOPE) + +typedef struct cpk_sign_envelope_st { + long version; + STACK_OF(X509_ALGOR) *digest_algors; + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(CPK_SIGNER_INFO) *signer_infos; + CPK_ENC_CONTENT *enc_data; + STACK_OF(CPK_RECIP_INFO) *recip_infos; +} CPK_SIGN_ENVELOPE; +DECLARE_ASN1_FUNCTIONS(CPK_SIGN_ENVELOPE) + +typedef struct cpk_cms_st { + int state; /* used during processing */ + int detached; + + ASN1_OBJECT *type; + union { + char *ptr; + + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + + /* NID_pkcs7_signed */ + CPK_SIGNED *sign; + + /* NID_pkcs7_enveloped */ + CPK_ENVELOPE *enveloped; + + /* NID_pkcs7_signedAndEnveloped */ + CPK_SIGN_ENVELOPE *signed_and_enveloped; + + /* Anything else */ + ASN1_TYPE *other; + } d; +} CPK_CMS; +DECLARE_STACK_OF(CPK_CMS) +DECLARE_ASN1_SET_OF(CPK_CMS) +DECLARE_PKCS12_STACK_OF(CPK_CMS) +DECLARE_ASN1_FUNCTIONS(CPK_CMS) + +DECLARE_ASN1_ITEM(CPK_CMS_ATTR_SIGN) +DECLARE_ASN1_ITEM(CPK_CMS_ATTR_VERIFY) +DECLARE_ASN1_NDEF_FUNCTION(CPK_CMS) + + + +#define CPK_CMS_OP_SET_DETACHED_SIGNATURE 1 +#define CPK_CMS_OP_GET_DETACHED_SIGNATURE 2 + +#define CPK_CMS_get_signed_attributes(si) ((si)->auth_attr) +#define CPK_CMS_get_attributes(si) ((si)->unauth_attr) + +#define CPK_CMS_type_is_signed(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) +#define CPK_CMS_type_is_enveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +#define CPK_CMS_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +#define CPK_CMS_type_is_data(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_data) +#define CPK_CMS_set_detached(p,v) \ + CPK_CMS_ctrl(p,CPK_CMS_OP_SET_DETACHED_SIGNATURE,v,NULL) +#define CPK_CMS_get_detached(p) \ + CPK_CMS_ctrl(p,CPK_CMS_OP_GET_DETACHED_SIGNATURE,0,NULL) +#define CPK_CMS_is_detached(p7) \ + (CPK_CMS_type_is_signed(p7) && CPK_CMS_get_detached(p7)) + +long CPK_CMS_ctrl(CPK_CMS *p7, int cmd, long larg, char *parg); +int CPK_CMS_set_type(CPK_CMS *p7, int type); +int CPK_CMS_set_cipher(CPK_CMS *p7, const EVP_CIPHER *cipher); +int CPK_CMS_set_content(CPK_CMS *p7, CPK_CMS *p7_data); +int CPK_CMS_content_new(CPK_CMS *p7, int type); +int CPK_CMS_add_signer(CPK_CMS *p7, const EVP_MD *sign_alg, const EVP_PKEY *sign_key); +int CPK_CMS_add_recipient(CPK_CMS *p7, const X509_NAME *id, const ECIES_PARAMS *params); + + +BIO *CPK_CMS_dataInit(CPK_CMS *p7, BIO *bio); +BIO *CPK_CMS_dataDecode(CPK_CMS *p7, BIO *in_bio, const EVP_PKEY *keyinfo); +int CPK_CMS_dataUpdate(CPK_CMS *p7, BIO *bio, const unsigned char *data, int len); +int CPK_CMS_dataFinal(CPK_CMS *p7, BIO *bio); +STACK_OF(CPK_SIGNER_INFO) *CPK_CMS_get_signer_infos(CPK_CMS *p7); +int CPK_CMS_dataVerify(CPK_PUBLIC_PARAMS *params, BIO *bio, CPK_CMS *p7, CPK_SIGNER_INFO *si); + + + +/* ERR function (should in openssl/err.h) begin */ +#define ERR_LIB_CPK 130 +#define ERR_R_CPK_LIB ERR_LIB_CPK +#define CPKerr(f,r) ERR_PUT_error(ERR_LIB_CPK,(f),(r),__FILE__,__LINE__) +/* end */ + + +void ERR_load_CPK_strings(void); + +/** + * @defgroup error_cpk Definations to handle errors of cpk runtime. + * @{ + */ +/* Error codes for the ECIES functions. */ + +/* Function codes. */ +#define CPK_F_CPK_MASTER_SECRET_CREATE 100 +#define CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS 101 +#define CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY 102 +#define CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY 103 +#define CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY 116 +#define CPK_F_CPK_MASTER_SECRET_DIGEST 104 +#define CPK_F_CPK_PUBLIC_PARAMS_DIGEST 105 +#define CPK_F_CPK_MASTER_SECRET_PRINT 106 +#define CPK_F_CPK_PUBLIC_PARAMS_PRINT 107 +#define CPK_F_CPK_MASTER_SECRET_VALIDATE_PUBLIC_PARAMS 108 +#define CPK_F_CPK_PUBLIC_PARAMS_VALIDATE_PRIVATE_KEY 109 +#define CPK_F_CPK_MAP_NEW_DEFAULT 110 +#define CPK_F_CPK_MAP_NUM_FACTORS 111 +#define CPK_F_CPK_MAP_NUM_INDEXES 112 +#define CPK_F_CPK_MAP_STR2INDEX 113 +#define CPK_F_X509_ALGOR_GET1_EC_KEY 114 +#define CPK_F_X509_ALGOR_GET1_DSA 115 + +/* Reason codes. */ +#define CPK_R_BAD_ARGUMENT 100 +#define CPK_R_UNKNOWN_DIGEST_TYPE 101 +#define CPK_R_UNKNOWN_CIPHER_TYPE 102 +#define CPK_R_UNKNOWN_MAP_TYPE 103 +#define CPK_R_UNKNOWN_CURVE 104 +#define CPK_R_STACK_ERROR 105 +#define CPK_R_DERIVE_KEY_FAILED 106 +#define CPK_R_ECIES_ENCRYPT_FAILED 107 +#define CPK_R_ECIES_DECRYPT_FAILED 108 +#define CPK_R_DER_DECODE_FAILED 109 +#define CPK_R_UNSUPPORTED_PKCS7_CONTENT_TYPE 110 +#define CPK_R_SET_SIGNER 111 +#define CPK_R_SET_RECIP_INFO 112 +#define CPK_R_UNABLE_TO_FIND_MESSAGE_DIGEST 113 +#define CPK_R_BAD_DATA 114 +#define CPK_R_MAP_FAILED 115 +#define CPK_R_ADD_SIGNING_TIME 116 +#define CPK_R_VERIFY_FAILED 117 +#define CPK_R_UNKNOWN_ECDH_TYPE 118 +#define CPK_R_DIGEST_FAILED 119 +#define CPK_R_WITHOUT_DECRYPT_KEY 120 +#define CPK_R_UNKNOWN_PKCS7_TYPE 121 +#define CPK_R_INVALID_ID_LENGTH 122 +#define CPK_R_INVALID_PKEY_TYPE 123 +#define CPK_R_INVALID_MAP_ALGOR 124 +#define CPK_R_PKEY_TYPE_NOT_MATCH 125 + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crypto/cpk/cpk_asn1.c b/crypto/cpk/cpk_asn1.c new file mode 100644 index 00000000..a4b54f79 --- /dev/null +++ b/crypto/cpk/cpk_asn1.c @@ -0,0 +1,124 @@ +#include +#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); +} + + + +/* This is the ANY DEFINED BY table for the top level PKCS#7 structure */ +ASN1_ADB_TEMPLATE(cpkcmsdefault) = ASN1_EXP_OPT(CPK_CMS, d.other, ASN1_ANY, 0); + +ASN1_ADB(CPK_CMS) = { + ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP_OPT(CPK_CMS, d.data, ASN1_OCTET_STRING_NDEF, 0)), + ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP_OPT(CPK_CMS, d.sign, CPK_SIGNED, 0)), + ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP_OPT(CPK_CMS, d.enveloped, CPK_ENVELOPE, 0)), + ADB_ENTRY(NID_pkcs7_signedAndEnveloped, + ASN1_NDEF_EXP_OPT(CPK_CMS, d.signed_and_enveloped, CPK_SIGN_ENVELOPE, 0)), +} ASN1_ADB_END(CPK_CMS, 0, type, 0, &cpkcmsdefault_tt, NULL); + + +ASN1_NDEF_SEQUENCE(CPK_CMS) = { + ASN1_SIMPLE(CPK_CMS, type, ASN1_OBJECT), + ASN1_ADB_OBJECT(CPK_CMS) +}ASN1_NDEF_SEQUENCE_END(CPK_CMS) +IMPLEMENT_ASN1_FUNCTIONS(CPK_CMS) +IMPLEMENT_ASN1_NDEF_FUNCTION(CPK_CMS) +IMPLEMENT_ASN1_DUP_FUNCTION(CPK_CMS) + + +ASN1_NDEF_SEQUENCE(CPK_SIGNED) = { + ASN1_SIMPLE(CPK_SIGNED, version, LONG), + ASN1_SET_OF(CPK_SIGNED, digest_algors, X509_ALGOR), + ASN1_SIMPLE(CPK_SIGNED, contents, CPK_CMS), + ASN1_IMP_SEQUENCE_OF_OPT(CPK_SIGNED, cert, X509, 0), + ASN1_IMP_SET_OF_OPT(CPK_SIGNED, crl, X509_CRL, 1), + ASN1_SET_OF(CPK_SIGNED, signer_infos, CPK_SIGNER_INFO) +} ASN1_NDEF_SEQUENCE_END(CPK_SIGNED) +IMPLEMENT_ASN1_FUNCTIONS(CPK_SIGNED) + + +ASN1_SEQUENCE(CPK_SIGNER_INFO) = { + ASN1_SIMPLE(CPK_SIGNER_INFO, version, LONG), + ASN1_SIMPLE(CPK_SIGNER_INFO, signer, X509_NAME), + ASN1_SIMPLE(CPK_SIGNER_INFO, digest_algor, X509_ALGOR), + ASN1_IMP_SEQUENCE_OF_OPT(CPK_SIGNER_INFO, signed_attr, X509_ATTRIBUTE, 0), + ASN1_SIMPLE(CPK_SIGNER_INFO, sign_algor, X509_ALGOR), + ASN1_SIMPLE(CPK_SIGNER_INFO, signature, ASN1_OCTET_STRING), + ASN1_IMP_SET_OF_OPT(CPK_SIGNER_INFO, unsigned_attr, X509_ATTRIBUTE, 1) +} ASN1_SEQUENCE_END(CPK_SIGNER_INFO) +IMPLEMENT_ASN1_FUNCTIONS(CPK_SIGNER_INFO) +IMPLEMENT_ASN1_DUP_FUNCTION(CPK_SIGNER_INFO) + + +ASN1_NDEF_SEQUENCE(CPK_ENVELOPE) = { + ASN1_SIMPLE(CPK_ENVELOPE, version, LONG), + ASN1_SET_OF(CPK_ENVELOPE, recip_infos, CPK_RECIP_INFO), + ASN1_SIMPLE(CPK_ENVELOPE, enc_data, CPK_ENC_CONTENT) +} ASN1_NDEF_SEQUENCE_END(CPK_ENVELOPE) +IMPLEMENT_ASN1_FUNCTIONS(CPK_ENVELOPE) + + +ASN1_SEQUENCE(CPK_RECIP_INFO) = { + ASN1_SIMPLE(CPK_RECIP_INFO, version, LONG), + ASN1_SIMPLE(CPK_RECIP_INFO, recipient, X509_NAME), + ASN1_SIMPLE(CPK_RECIP_INFO, enc_algor, X509_ALGOR), + ASN1_SIMPLE(CPK_RECIP_INFO, enc_data, ASN1_OCTET_STRING) +} ASN1_SEQUENCE_END(CPK_RECIP_INFO) +IMPLEMENT_ASN1_FUNCTIONS(CPK_RECIP_INFO) +IMPLEMENT_ASN1_DUP_FUNCTION(CPK_RECIP_INFO) + + +ASN1_NDEF_SEQUENCE(CPK_ENC_CONTENT) = { + ASN1_SIMPLE(CPK_ENC_CONTENT, content_type, ASN1_OBJECT), + ASN1_SIMPLE(CPK_ENC_CONTENT, enc_algor, X509_ALGOR), + ASN1_IMP_OPT(CPK_ENC_CONTENT, enc_data, ASN1_OCTET_STRING, 0) +} ASN1_NDEF_SEQUENCE_END(CPK_ENC_CONTENT) +IMPLEMENT_ASN1_FUNCTIONS(CPK_ENC_CONTENT) + + +ASN1_NDEF_SEQUENCE(CPK_SIGN_ENVELOPE) = { + ASN1_SIMPLE(CPK_SIGN_ENVELOPE, version, LONG), + ASN1_SET_OF(CPK_SIGN_ENVELOPE, recip_infos, CPK_RECIP_INFO), + ASN1_SET_OF(CPK_SIGN_ENVELOPE, digest_algors, X509_ALGOR), + ASN1_SIMPLE(CPK_SIGN_ENVELOPE, enc_data, CPK_ENC_CONTENT), + ASN1_IMP_SET_OF_OPT(CPK_SIGN_ENVELOPE, cert, X509, 0), + ASN1_IMP_SET_OF_OPT(CPK_SIGN_ENVELOPE, crl, X509_CRL, 1), + ASN1_SET_OF(CPK_SIGN_ENVELOPE, signer_infos, CPK_SIGNER_INFO) +} ASN1_NDEF_SEQUENCE_END(CPK_SIGN_ENVELOPE) +IMPLEMENT_ASN1_FUNCTIONS(CPK_SIGN_ENVELOPE) + diff --git a/crypto/cpk/cpk_err.c b/crypto/cpk/cpk_err.c new file mode 100644 index 00000000..3412241c --- /dev/null +++ b/crypto/cpk/cpk_err.c @@ -0,0 +1,75 @@ +#include +#include "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_MASTER_SECRET_CREATE), "CPK_MASTER_SECRET_create"}, + {ERR_FUNC(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS), "CPK_MASTER_SECRET_extract_public_params"}, + {ERR_FUNC(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY), "CPK_MASTER_SECRET_extract_private_key"}, + {ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY), "CPK_PUBLIC_PARAMS_extract_public_key"}, + {ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY), "CPK_PUBLIC_PARAMS_compute_share_key"}, + {ERR_FUNC(CPK_F_CPK_MASTER_SECRET_DIGEST), "CPK_F_CPK_MASTER_SECRET_digest"}, + {ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_DIGEST), "CPK_F_CPK_PUBLIC_PARAMS_digest"}, + {ERR_FUNC(CPK_F_CPK_MASTER_SECRET_PRINT), "CPK_F_CPK_MASTER_SECRET_print"}, + {ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_PRINT), "CPK_F_CPK_PUBLIC_PARAMS_print"}, + {ERR_FUNC(CPK_F_CPK_MASTER_SECRET_VALIDATE_PUBLIC_PARAMS), "CPK_F_CPK_MASTER_SECRET_validate_public_params"}, + {ERR_FUNC(CPK_F_CPK_PUBLIC_PARAMS_VALIDATE_PRIVATE_KEY), "CPK_F_CPK_PUBLIC_PARAMS_validate_private_key"}, + {ERR_FUNC(CPK_F_CPK_MAP_NEW_DEFAULT), "CPK_F_CPK_MAP_new_default"}, + {ERR_FUNC(CPK_F_CPK_MAP_NUM_FACTORS), "CPK_F_CPK_MAP_num_factors"}, + {ERR_FUNC(CPK_F_CPK_MAP_NUM_INDEXES), "CPK_F_CPK_MAP_num_indexes"}, + {ERR_FUNC(CPK_F_CPK_MAP_STR2INDEX), "CPK_F_CPK_MAP_STR2INDEX"}, + {ERR_FUNC(CPK_F_X509_ALGOR_GET1_EC_KEY), "X509_ALGOR_get1_ec_key"}, + {ERR_FUNC(CPK_F_X509_ALGOR_GET1_DSA), "X509_ALGOR_get1_dsa"}, + {0, NULL} +}; + +static ERR_STRING_DATA CPK_str_reasons[] = +{ + {ERR_REASON(CPK_R_BAD_ARGUMENT), "bad argument"}, + {ERR_REASON(CPK_R_UNKNOWN_DIGEST_TYPE), "unknown digest algorithm"}, + {ERR_REASON(CPK_R_UNKNOWN_CIPHER_TYPE), "unknown cipher algorithm"}, + {ERR_REASON(CPK_R_UNKNOWN_MAP_TYPE), "unknown cpk map algorithm"}, + {ERR_REASON(CPK_R_UNKNOWN_CURVE), "unknown elliptic curve"}, + {ERR_REASON(CPK_R_STACK_ERROR), "stack error"}, + {ERR_REASON(CPK_R_DERIVE_KEY_FAILED), "derive key failed"}, + {ERR_REASON(CPK_R_ECIES_ENCRYPT_FAILED), "ecies encryption failed"}, + {ERR_REASON(CPK_R_ECIES_DECRYPT_FAILED), "ecies decryption failed"}, + {ERR_REASON(CPK_R_DER_DECODE_FAILED), "DER decode failed"}, + {ERR_REASON(CPK_R_UNSUPPORTED_PKCS7_CONTENT_TYPE),"CPK_R_UNSUPPORTED_PKCS7_CONTENT_TYPE"}, + {ERR_REASON(CPK_R_SET_SIGNER), "CPK_R_SET_SIGNER"}, + {ERR_REASON(CPK_R_SET_RECIP_INFO), "CPK_R_SET_RECIP_INFO"}, + {ERR_REASON(CPK_R_UNABLE_TO_FIND_MESSAGE_DIGEST),"CPK_R_UNABLE_TO_FIND_MESSAGE_DIGEST"}, + {ERR_REASON(CPK_R_BAD_DATA), "bad data"}, + {ERR_REASON(CPK_R_MAP_FAILED), "CPK_R_MAP_FAILED"}, + {ERR_REASON(CPK_R_ADD_SIGNING_TIME), "CPK_R_ADD_SIGNING_TIME"}, + {ERR_REASON(CPK_R_VERIFY_FAILED), "CPK_R_VERIFY_FAILED"}, + {ERR_REASON(CPK_R_UNKNOWN_ECDH_TYPE), "CPK_R_UNKNOWN_ECDH_TYPE"}, + {ERR_REASON(CPK_R_DIGEST_FAILED), "CPK_R_DIGEST_FAILED"}, + {ERR_REASON(CPK_R_WITHOUT_DECRYPT_KEY), "CPK_R_WITHOUT_DECRYPT_KEY"}, + {ERR_REASON(CPK_R_UNKNOWN_PKCS7_TYPE), "CPK_R_UNKNOWN_PKCS7_TYPE"}, + {ERR_REASON(CPK_R_INVALID_ID_LENGTH), "invalid identity length"}, + {ERR_REASON(CPK_R_INVALID_PKEY_TYPE), "invalid public key type"}, + {ERR_REASON(CPK_R_INVALID_MAP_ALGOR), "invalid map algorithm"}, + {ERR_REASON(CPK_R_PKEY_TYPE_NOT_MATCH), "public key type not match"}, + {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 +} diff --git a/crypto/cpk/cpk_kap.c b/crypto/cpk/cpk_kap.c new file mode 100644 index 00000000..65e52011 --- /dev/null +++ b/crypto/cpk/cpk_kap.c @@ -0,0 +1,46 @@ +#include +#include +#include +#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; +} + diff --git a/crypto/cpk/cpk_lib.c b/crypto/cpk/cpk_lib.c new file mode 100644 index 00000000..ec8cb5e5 --- /dev/null +++ b/crypto/cpk/cpk_lib.c @@ -0,0 +1,1097 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpk.h" + + +static DSA *X509_ALGOR_get1_DSA(X509_ALGOR *algor); +static int extract_dsa_params(CPK_MASTER_SECRET *master, CPK_PUBLIC_PARAMS *param); +static DSA *extract_dsa_priv_key(CPK_MASTER_SECRET *master, const char *id); +static DSA *extract_dsa_pub_key(CPK_PUBLIC_PARAMS *param, const char *id); + +static EC_KEY *X509_ALGOR_get1_EC_KEY(X509_ALGOR *algor); +static int extract_ec_params(CPK_MASTER_SECRET *master, CPK_PUBLIC_PARAMS *param); +static EC_KEY *extract_ec_priv_key(CPK_MASTER_SECRET *master, const char *id); +static EC_KEY *extract_ec_pub_key(CPK_PUBLIC_PARAMS *param, const char *id); + + + +CPK_MASTER_SECRET *CPK_MASTER_SECRET_create(const char *domain_id, + EVP_PKEY *pkey, X509_ALGOR *map_algor) +{ + int e = 1; + CPK_MASTER_SECRET *master = NULL; + BIGNUM *bn = NULL, *order = NULL; + X509_PUBKEY *pubkey = NULL; + int pkey_type; + int i, bn_size, num_factors; + unsigned char *bn_ptr; + + if (strlen(domain_id) <= 0 || strlen(domain_id) > CPK_MAX_ID_LENGTH) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, CPK_R_INVALID_ID_LENGTH); + goto err; + } + + pkey_type = EVP_PKEY_id(pkey); + if (pkey_type == EVP_PKEY_DSA) { + if (!(order = ((DSA *)EVP_PKEY_get0(pkey))->q)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, CPK_R_BAD_ARGUMENT); + goto err; + } + } else if (pkey_type == EVP_PKEY_EC) { + const EC_GROUP *ec_group; + if (!(order = BN_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_MALLOC_FAILURE); + goto err; + } + ec_group = EC_KEY_get0_group((EC_KEY *)EVP_PKEY_get0(pkey)); + if (!EC_GROUP_get_order(ec_group, order, NULL)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_X509_LIB); + goto err; + } + //FIXME OPENSSL_assert + assert(EC_KEY_get0_public_key((EC_KEY *)EVP_PKEY_get0(pkey)) != NULL); + } else { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, CPK_R_INVALID_PKEY_TYPE); + goto err; + } + + if (!(master = CPK_MASTER_SECRET_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_MALLOC_FAILURE); + goto err; + } + + master->version = 1; + if (!X509_NAME_add_entry_by_NID(master->id, NID_organizationName, + MBSTRING_UTF8, (unsigned char *)domain_id, -1, -1, 0)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_X509_LIB); + goto err; + } + + /* + * convert EVP_PKEY to X509_ALGOR through X509_PUBKEY_set + * X509_ALGOR_set0() is another choice but require more code + */ + // FIXME: X509_PUBKEY require pkey has a public key + if (!X509_PUBKEY_set(&pubkey, pkey)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_X509_LIB); + goto err; + } + X509_ALGOR_free(master->pkey_algor); + if (!(master->pkey_algor = X509_ALGOR_dup(pubkey->algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_X509_LIB); + goto err; + } + + //FIXME: check the validity of CPK_MAP + X509_ALGOR_free(master->map_algor); + if (!(master->map_algor = X509_ALGOR_dup(map_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_MALLOC_FAILURE); + goto err; + } + if ((num_factors = CPK_MAP_num_factors(map_algor)) <= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, CPK_R_INVALID_MAP_ALGOR); + goto err; + } + + /* + * create secret factors, for both DSA and EC, + * the private keys are both big integers, + */ + bn_size = BN_num_bytes(order); + if (!ASN1_STRING_set(master->secret_factors, NULL, bn_size * num_factors)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_ASN1_LIB); + goto err; + } + bn_ptr = M_ASN1_STRING_data(master->secret_factors); + memset(bn_ptr, 0, M_ASN1_STRING_length(master->secret_factors)); + + if (!(bn = BN_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_MALLOC_FAILURE); + goto err; + } + for (i = 0; i < num_factors; i++) { + do { + if (!BN_rand_range(bn, order)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, + ERR_R_RAND_LIB); + goto err; + } + } while (BN_is_zero(bn)); + + if (!BN_bn2bin(bn, bn_ptr + bn_size - BN_num_bytes(bn))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, ERR_R_BN_LIB); + goto err; + } + bn_ptr += bn_size; + } + + e = 0; +err: + if (e && master) { + CPK_MASTER_SECRET_free(master); + master = NULL; + } + if (pubkey) X509_PUBKEY_free(pubkey); + if (order && pkey_type == EVP_PKEY_EC) BN_free(order); + if (bn) BN_free(bn); + return master; +} + +CPK_PUBLIC_PARAMS *CPK_MASTER_SECRET_extract_public_params(CPK_MASTER_SECRET *master) +{ + CPK_PUBLIC_PARAMS *param = NULL; + int pkey_type; + pkey_type = OBJ_obj2nid(master->pkey_algor->algorithm); + + + if (!(param = CPK_PUBLIC_PARAMS_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + param->version = master->version; + + X509_NAME_free(param->id); + if (!(param->id = X509_NAME_dup(master->id))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + X509_ALGOR_free(param->pkey_algor); + if (!(param->pkey_algor = X509_ALGOR_dup(master->pkey_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + X509_ALGOR_free(param->map_algor); + if (!(param->map_algor = X509_ALGOR_dup(master->map_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + switch (pkey_type) { + case EVP_PKEY_DSA: + if (!extract_dsa_params(master, param)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_CPK_LIB); + goto err; + } + break; + + case EVP_PKEY_EC: + if (!extract_ec_params(master, param)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_CPK_LIB); + goto err; + } + break; + + default: + CPKerr(CPK_F_CPK_MASTER_SECRET_CREATE, CPK_R_INVALID_PKEY_TYPE); + goto err; + } + return param; + +err: + if (param) CPK_PUBLIC_PARAMS_free(param); + return NULL; +} + +EVP_PKEY *CPK_MASTER_SECRET_extract_private_key( + CPK_MASTER_SECRET *master, const char *id) +{ + EVP_PKEY *pkey = NULL; + int pkey_type; + + if (!(pkey = EVP_PKEY_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + pkey_type = OBJ_obj2nid(master->pkey_algor->algorithm); + + if (pkey_type == EVP_PKEY_DSA) { + DSA *dsa; + if (!(dsa = extract_dsa_priv_key(master, id))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_CPK_LIB); + goto err; + } + if (!EVP_PKEY_assign_DSA(pkey, dsa)) { + DSA_free(dsa); + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_EVP_LIB); + goto err; + } + + } else if (pkey_type == EVP_PKEY_EC) { + EC_KEY *ec_key; + if (!(ec_key = extract_ec_priv_key(master, id))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_CPK_LIB); + goto err; + } + if (!EVP_PKEY_assign_EC_KEY(pkey, ec_key)) { + EC_KEY_free(ec_key); + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_EVP_LIB); + goto err; + } + + } else { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_PKEY_TYPE); + goto err; + } + + /* + * add id to EVP_PKEY attributes + */ + /* + if(!X509_NAME_get_text_by_NID(master->id, NID_organizationName, + domain_id, sizeof(domain_id))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_X509_LIB); + goto err; + } + if (!EVP_PKEY_add1_attr_by_NID(pkey, NID_organizationName, V_ASN1_PRINTABLESTRING, + (const unsigned char *)domain_id, strlen(domain_id))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, ERR_R_EVP_LIB); + goto err; + } + if (!EVP_PKEY_add1_attr_by_NID(pkey, NID_commonName, V_ASN1_PRINTABLESTRING, + (const unsigned char *)id, strlen(id))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_EVP_LIB); + goto err; + } + */ + + return pkey; + +err: + if (pkey) EVP_PKEY_free(pkey); + return NULL; +} + +EVP_PKEY *CPK_PUBLIC_PARAMS_extract_public_key(CPK_PUBLIC_PARAMS *param, + const char *id) +{ + EVP_PKEY *pkey = NULL; + int pkey_type; + //char domain_id[CPK_MAX_ID_LENGTH + 1]; + + if (!(pkey = EVP_PKEY_new())) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + pkey_type = OBJ_obj2nid(param->pkey_algor->algorithm); + + if (pkey_type == EVP_PKEY_DSA) { + DSA *dsa = NULL; + if (!(dsa = extract_dsa_pub_key(param, id))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_CPK_LIB); + goto err; + } + if (!EVP_PKEY_assign_DSA(pkey, dsa)) { + DSA_free(dsa); + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_EVP_LIB); + goto err; + } + + } else if (pkey_type == EVP_PKEY_EC) { + EC_KEY *ec_key = NULL; + if (!(ec_key = extract_ec_pub_key(param, id))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_CPK_LIB); + goto err; + } + if (!EVP_PKEY_assign_EC_KEY(pkey, ec_key)) { + EC_KEY_free(ec_key); + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_EVP_LIB); + goto err; + } + + } else { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_PKEY_TYPE); + goto err; + } + + /* + * add id to EVP_PKEY attributes + */ + /* + if(!X509_NAME_get_text_by_NID(param->id, NID_organizationName, + domain_id, sizeof(domain_id) - 1)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_X509_LIB); + goto err; + } + if (!EVP_PKEY_add1_attr_by_NID(pkey, NID_organizationName, MBSTRING_UTF8, + (const unsigned char *)domain_id, strlen(domain_id))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_X509_LIB); + goto err; + } + if (!EVP_PKEY_add1_attr_by_NID(pkey, NID_commonName, + MBSTRING_UTF8, (const unsigned char *)id, strlen(id))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_X509_LIB); + goto err; + } + */ + return pkey; + +err: + if (pkey) EVP_PKEY_free(pkey); + return NULL; +} + +int CPK_MASTER_SECRET_digest(CPK_MASTER_SECRET *master, const EVP_MD *md, + unsigned char *dgst, unsigned int *dgstlen) +{ + if (!EVP_Digest(M_ASN1_STRING_data(master->secret_factors), + M_ASN1_STRING_length(master->secret_factors), + dgst, dgstlen, md, NULL)) { + return 0; + } + return 1; +} + +int CPK_PUBLIC_PARAMS_digest(CPK_PUBLIC_PARAMS *params, const EVP_MD *md, + unsigned char *dgst, unsigned int *dgstlen) +{ + if (!EVP_Digest(M_ASN1_STRING_data(params->public_factors), + M_ASN1_STRING_length(params->public_factors), + dgst, dgstlen, md, NULL)) { + return 0; + } + return 1; +} + +char *CPK_MASTER_SECRET_get_name(CPK_MASTER_SECRET *master, char *buf, int size) +{ + return X509_NAME_oneline(master->id, buf, size); +} + +char *CPK_PUBLIC_PARAMS_name(CPK_PUBLIC_PARAMS *params, char *buf, int size) +{ + return X509_NAME_oneline(params->id, buf, size); +} + +int CPK_MASTER_SECRET_validate_public_params(CPK_MASTER_SECRET *master, + CPK_PUBLIC_PARAMS *params) +{ + int ret = 0; + CPK_PUBLIC_PARAMS *tmp = NULL; + + if (!(tmp = CPK_MASTER_SECRET_extract_public_params(master))) { + fprintf(stderr, "shit1\n"); + goto err; + } + if (tmp->version != params->version) { + fprintf(stderr, "shit2\n"); + goto err; + } + if (X509_NAME_cmp(tmp->id, params->id)) { + fprintf(stderr, "shit3\n"); + goto err; + } + + /* + * two ASN_OBJECT * with different address may have same NID + * thus we can not check with: + * tmp->pkey_algor->algorithm != params->pkey_algor->algorithm + */ + if (OBJ_obj2nid(tmp->pkey_algor->algorithm) != + OBJ_obj2nid(params->pkey_algor->algorithm)) { + fprintf(stderr, "shit4\n"); + goto err; + } + // FIXME: pkey_algor->parameters + if (OBJ_obj2nid(tmp->map_algor->algorithm) != + OBJ_obj2nid(params->map_algor->algorithm)) { + fprintf(stderr, "shit5\n"); + goto err; + } + if (ASN1_STRING_cmp(tmp->public_factors, params->public_factors)) { + fprintf(stderr, "shit6\n"); + goto err; + } + + ret = 1; +err: + if (tmp) CPK_PUBLIC_PARAMS_free(tmp); + return ret; +} + +int CPK_PUBLIC_PARAMS_validate_private_key(CPK_PUBLIC_PARAMS *params, + const char *id, const EVP_PKEY *priv_key) +{ + int ret = -3; + EVP_PKEY *pub_key = NULL; + + if (!(pub_key = CPK_PUBLIC_PARAMS_extract_public_key(params, id))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_VALIDATE_PRIVATE_KEY, + ERR_R_EVP_LIB); + goto err; + } + ret = EVP_PKEY_cmp(pub_key, priv_key); +err: + if (pub_key) EVP_PKEY_free(pub_key); + return ret; +} + +/* + * static functions + */ +#if 0 +// FIXME: check DSA and EC_KEY +static int X509_ALGOR_cmp(X509_ALGOR *a, X509_ALGOR *b) +{ + int pkey_type = OBJ_obj2nid(a->algorithm); + if (pkey_type != EVP_PKEY_DSA || pkey_type != EVP_PKEY_EC) + return 1; + if (a->algorithm != b->algorithm) + return -1; + return 0; +} +#endif + +static DSA *X509_ALGOR_get1_DSA(X509_ALGOR *algor) +{ + DSA *dsa = NULL; + int ptype; + void *pval; + ASN1_OCTET_STRING *pstr; + const unsigned char *p; + + X509_ALGOR_get0(NULL, &ptype, &pval, algor); + if (ptype != V_ASN1_SEQUENCE) { + CPKerr(CPK_F_X509_ALGOR_GET1_DSA, CPK_R_BAD_DATA); + return NULL; + } + pstr = (ASN1_OCTET_STRING *)pval; + p = pstr->data; + if (!(dsa = d2i_DSAparams(NULL, &p, pstr->length))) { + CPKerr(CPK_F_X509_ALGOR_GET1_DSA, ERR_R_DSA_LIB); + return NULL; + } + return dsa; +} + +static int extract_dsa_params(CPK_MASTER_SECRET *master, CPK_PUBLIC_PARAMS *param) +{ + int ret = 0; + DSA *dsa = NULL; + BIGNUM *pri = BN_new(); + BIGNUM *pub = BN_new(); + BN_CTX *ctx = BN_CTX_new(); + int i, pri_size, pub_size, num_factors; + const unsigned char *pri_ptr; + unsigned char *pub_ptr; + + if (!pri || !pub || !ctx) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!(dsa = (DSA *)X509_ALGOR_get1_DSA(master->pkey_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + CPK_R_BAD_DATA); + goto err; + } + pri_size = BN_num_bytes(dsa->q); + pub_size = BN_num_bytes(dsa->p); + + if ((num_factors = CPK_MAP_num_factors(master->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (M_ASN1_STRING_length(master->secret_factors) != pri_size * num_factors) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + CPK_R_BAD_DATA); + goto err; + } + + ASN1_STRING_free(param->public_factors); + if (!ASN1_STRING_set(param->public_factors, NULL, pub_size * num_factors)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + pri_ptr = M_ASN1_STRING_data(master->secret_factors); + pub_ptr = M_ASN1_STRING_data(param->public_factors); + memset(pub_ptr, 0, M_ASN1_STRING_length(param->public_factors)); + + for (i = 0; i < num_factors; i++) { + + if (!BN_bin2bn(pri_ptr, pri_size, pri)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_BN_LIB); + goto err; + } + if (BN_is_zero(pri) || BN_cmp(pri, dsa->q) >= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + CPK_R_BAD_DATA); + goto err; + } + + if (!BN_mod_exp(pub, dsa->g, pri, dsa->p, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_BN_LIB); + goto err; + } + if (!BN_bn2bin(pub, pub_ptr + pub_size - BN_num_bytes(pub))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_BN_LIB); + goto err; + } + + pri_ptr += pri_size; + pub_ptr += pub_size; + } + + ret = 1; +err: + if (dsa) DSA_free(dsa); + if (pri) BN_free(pri); + if (pub) BN_free(pub); + if (ctx) BN_CTX_free(ctx); + return ret; +} + +static DSA *extract_dsa_priv_key(CPK_MASTER_SECRET *master, const char *id) +{ + int e = 1; + DSA *dsa = NULL; + BIGNUM *bn = BN_new(); + BN_CTX *ctx = BN_CTX_new(); + const unsigned char *p; + int *index = NULL; + int i, num_indexes, bn_size; + + + if (!bn || !ctx) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + if (!(dsa = X509_ALGOR_get1_DSA(master->pkey_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_BAD_DATA); + goto err; + } + + if ((num_indexes = CPK_MAP_num_indexes(master->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!(index = OPENSSL_malloc(sizeof(int) * num_indexes))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!CPK_MAP_str2index(master->map_algor, id, index)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!dsa->priv_key) { + if (!(dsa->priv_key = BN_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + } + BN_zero(dsa->priv_key); + bn_size = BN_num_bytes(dsa->q); + + for (i = 0; i < num_indexes; i++) { + p = M_ASN1_STRING_data(master->secret_factors) + bn_size * index[i]; + if (!BN_bin2bn(p, bn_size, bn)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_BN_LIB); + goto err; + } + if (BN_is_zero(bn) || BN_cmp(bn, dsa->q) >= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_BAD_DATA); + goto err; + } + if (!BN_mod_add(dsa->priv_key, dsa->priv_key, bn, dsa->q, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_X509_LIB); + goto err; + } + } + + if (!(dsa->pub_key)) + if (!(dsa->pub_key = BN_new())) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, ERR_R_BN_LIB); + goto err; + } + e = 0; + +err: + if (e && dsa) { + DSA_free(dsa); + dsa = NULL; + } + if (bn) BN_free(bn); + if (ctx) BN_CTX_free(ctx); + if (index) OPENSSL_free(index); + return dsa; +} + +static DSA *extract_dsa_pub_key(CPK_PUBLIC_PARAMS *param, const char *id) +{ + int e = 1; + DSA *dsa = NULL; + BIGNUM *bn = BN_new(); + BN_CTX *ctx = BN_CTX_new(); + const unsigned char *p; + int *index = NULL; + int i, num_indexes, bn_size; + + + if (!bn || !ctx) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + if (!(dsa = X509_ALGOR_get1_DSA(param->pkey_algor))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_BAD_DATA); + goto err; + } + + if ((num_indexes = CPK_MAP_num_indexes(param->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!(index = OPENSSL_malloc(sizeof(int) * num_indexes))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!CPK_MAP_str2index(param->map_algor, id, index)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!dsa->pub_key) { + if (!(dsa->pub_key = BN_new())) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + } + BN_zero(dsa->pub_key); + bn_size = BN_num_bytes(dsa->p); + + for (i = 0; i < num_indexes; i++) { + p = M_ASN1_STRING_data(param->public_factors) + bn_size * index[i]; + if (!BN_bin2bn(p, bn_size, bn)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_BN_LIB); + goto err; + } + if (BN_is_zero(bn) || BN_cmp(bn, dsa->p) >= 0) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_BAD_DATA); + goto err; + } + if (!BN_mod_add(dsa->pub_key, dsa->pub_key, bn, dsa->p, ctx)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_X509_LIB); + goto err; + } + } + e = 0; + +err: + if (e && dsa) { + DSA_free(dsa); + dsa = NULL; + } + if (bn) BN_free(bn); + if (ctx) BN_CTX_free(ctx); + if (index) OPENSSL_free(index); + return dsa; +} + +static EC_KEY *X509_ALGOR_get1_EC_KEY(X509_ALGOR *algor) +{ + EC_KEY *ec_key = NULL; + int ptype; + void *pval; + const unsigned char *p; + + X509_ALGOR_get0(NULL, &ptype, &pval, algor); + + if (ptype == V_ASN1_SEQUENCE) { + ASN1_OCTET_STRING *pstr = (ASN1_OCTET_STRING *)pval; + p = pstr->data; + if (!(ec_key = d2i_ECParameters(NULL, &p, pstr->length))) { + CPKerr(CPK_F_X509_ALGOR_GET1_EC_KEY, ERR_R_EC_LIB); + return NULL; + } + + } else if (ptype == V_ASN1_OBJECT) { + ASN1_OBJECT *poid = (ASN1_OBJECT *)pval; + EC_GROUP *group; + if (!(ec_key = EC_KEY_new())) { + CPKerr(CPK_F_X509_ALGOR_GET1_EC_KEY, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!(group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(poid)))) { + EC_KEY_free(ec_key); + CPKerr(CPK_F_X509_ALGOR_GET1_EC_KEY, ERR_R_EC_LIB); + return NULL; + } + EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); + if (!EC_KEY_set_group(ec_key, group)) { + EC_GROUP_free(group); + EC_KEY_free(ec_key); + CPKerr(CPK_F_X509_ALGOR_GET1_EC_KEY, ERR_R_EC_LIB); + return NULL; + } + EC_GROUP_free(group); + + } else { + CPKerr(CPK_F_X509_ALGOR_GET1_EC_KEY, CPK_R_BAD_DATA); + return NULL; + } + return ec_key; +} + +static int extract_ec_params(CPK_MASTER_SECRET *master, CPK_PUBLIC_PARAMS *param) +{ + int ret = 0; + EC_KEY *ec_key = NULL; + const EC_GROUP *ec_group; + BIGNUM *bn = BN_new(); + BIGNUM *order = BN_new(); + BN_CTX *ctx = BN_CTX_new(); + EC_POINT *pt = NULL; + int i, bn_size, pt_size, num_factors; + const unsigned char *bn_ptr; + unsigned char *pt_ptr; + + if (!bn || !order || !ctx) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!(ec_key = X509_ALGOR_get1_EC_KEY(master->pkey_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, CPK_R_BAD_DATA); + goto err; + } + ec_group = EC_KEY_get0_group(ec_key); + if (!(EC_GROUP_get_order(ec_group, order, ctx))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, ERR_R_EC_LIB); + goto err; + } + bn_size = BN_num_bytes(order); + pt_size = bn_size + 1; + + if ((num_factors = CPK_MAP_num_factors(master->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (M_ASN1_STRING_length(master->secret_factors) != bn_size * num_factors) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, CPK_R_BAD_DATA); + goto err; + } + if (!ASN1_STRING_set(param->public_factors, NULL, pt_size * num_factors)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_MALLOC_FAILURE); + goto err; + } + + bn_ptr = M_ASN1_STRING_data(master->secret_factors); + pt_ptr = M_ASN1_STRING_data(param->public_factors); + memset(pt_ptr, 0, M_ASN1_STRING_length(param->public_factors)); + + if (!(pt = EC_POINT_new(ec_group))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, ERR_R_X509_LIB); + goto err; + } + for (i = 0; i < num_factors; i++) { + if (!BN_bin2bn(bn_ptr, bn_size, bn)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_BN_LIB); + goto err; + } + if (BN_is_zero(bn) || BN_cmp(bn, order) >= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + CPK_R_BAD_DATA); + goto err; + } + if (!EC_POINT_mul(ec_group, pt, bn, NULL, NULL, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_EC_LIB); + goto err; + } + + if (!EC_POINT_point2oct(ec_group, pt, + POINT_CONVERSION_COMPRESSED, pt_ptr, pt_size, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PUBLIC_PARAMS, + ERR_R_EC_LIB); + goto err; + } + bn_ptr += bn_size; + pt_ptr += pt_size; + } + + ret = 1; +err: + if (ec_key) EC_KEY_free(ec_key); + if (bn) BN_free(bn); + if (order) BN_free(order); + if (ctx) BN_CTX_free(ctx); + if (pt) EC_POINT_free(pt); + return ret; +} + + + +static EC_KEY *extract_ec_priv_key(CPK_MASTER_SECRET *master, const char *id) +{ + int e = 1; + EC_KEY *ec_key = NULL; + const EC_GROUP *ec_group; + EC_POINT *pub_key = NULL; + BIGNUM *priv_key = BN_new(); + BIGNUM *order = BN_new(); + BIGNUM *bn = BN_new(); + BN_CTX *ctx = BN_CTX_new(); + int *index = NULL; + int i, num_indexes, bn_size; + + + if (!priv_key || !bn || !order || !ctx) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!(ec_key = X509_ALGOR_get1_EC_KEY(master->pkey_algor))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, ERR_R_CPK_LIB); + goto err; + } + ec_group = EC_KEY_get0_group(ec_key); + if (!(pub_key = EC_POINT_new(ec_group))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + if ((num_indexes = CPK_MAP_num_indexes(master->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!(index = OPENSSL_malloc(sizeof(int) * num_indexes))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!CPK_MAP_str2index(master->map_algor, id, index)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + + BN_zero(priv_key); + if (!(EC_GROUP_get_order(EC_KEY_get0_group(ec_key), order, ctx))) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, ERR_R_EC_LIB); + goto err; + } + bn_size = BN_num_bytes(order); + + for (i = 0; i < num_indexes; i++) { + const unsigned char *p = + M_ASN1_STRING_data(master->secret_factors) + + bn_size * index[i]; + + if (!BN_bin2bn(p, bn_size, bn)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, ERR_R_BN_LIB); + goto err; + } + if (BN_is_zero(bn) || BN_cmp(bn, order) >= 0) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + CPK_R_BAD_DATA); + goto err; + } + if (!BN_mod_add(priv_key, priv_key, bn, order, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, ERR_R_BN_LIB); + goto err; + } + } + if (!EC_KEY_set_private_key(ec_key, priv_key)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_EC_LIB); + goto err; + } + + if (!EC_POINT_mul(ec_group, pub_key, priv_key, NULL, NULL, ctx)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_EC_LIB); + goto err; + } + if (!EC_KEY_set_public_key(ec_key, pub_key)) { + CPKerr(CPK_F_CPK_MASTER_SECRET_EXTRACT_PRIVATE_KEY, + ERR_R_EC_LIB); + goto err; + } + e = 0; + +err: + if (e && ec_key) { + EC_KEY_free(ec_key); + ec_key = NULL; + } + if (priv_key) BN_free(priv_key); + if (pub_key) EC_POINT_free(pub_key); + if (order) BN_free(order); + if (bn) BN_free(bn); + if (ctx) BN_CTX_free(ctx); + if (index) OPENSSL_free(index); + return ec_key; +} + +static EC_KEY *extract_ec_pub_key(CPK_PUBLIC_PARAMS *param, const char *id) +{ + int e = 1; + EC_KEY *ec_key = NULL; + const EC_GROUP *ec_group; + EC_POINT *pub_key = NULL; + EC_POINT *pt = NULL; + BIGNUM *order = BN_new(); + BIGNUM *bn = BN_new(); + BN_CTX *ctx = BN_CTX_new(); + int *index = NULL; + int i, bn_size, pt_size, num_indexes, num_factors; + + if (!(ec_key = X509_ALGOR_get1_EC_KEY(param->pkey_algor))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_CPK_LIB); + goto err; + } + ec_group = EC_KEY_get0_group(ec_key); + + if (!(pub_key = EC_POINT_new(ec_group))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, ERR_R_EC_LIB); + goto err; + } + if (!(pt = EC_POINT_new(ec_group))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, ERR_R_EC_LIB); + goto err; + } + if (!EC_GROUP_get_order(ec_group, order, ctx)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, ERR_R_EC_LIB); + goto err; + } + bn_size = BN_num_bytes(order); + pt_size = bn_size + 1; + if ((num_factors = CPK_MAP_num_factors(param->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_CPK_LIB); + goto err; + } + if (M_ASN1_STRING_length(param->public_factors) != pt_size * num_factors) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_BAD_DATA); + goto err; + } + + if ((num_indexes = CPK_MAP_num_indexes(param->map_algor)) <= 0) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!(index = OPENSSL_malloc(sizeof(int) * num_indexes))) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + if (!CPK_MAP_str2index(param->map_algor, id, index)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_INVALID_MAP_ALGOR); + goto err; + } + + if (!EC_POINT_set_to_infinity(ec_group, pub_key)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, ERR_R_EC_LIB); + goto err; + } + for (i = 0; i < num_indexes; i++) { + const unsigned char *p = + M_ASN1_STRING_data(param->public_factors) + + pt_size * index[i]; + + if (!EC_POINT_oct2point(ec_group, pt, p, pt_size, ctx)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + CPK_R_BAD_DATA); + goto err; + } + if (!EC_POINT_add(ec_group, pub_key, pub_key, pt, ctx)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_EC_LIB); + goto err; + } + } + + if (!EC_KEY_set_public_key(ec_key, pub_key)) { + CPKerr(CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY, + ERR_R_EC_LIB); + goto err; + } + e = 0; +err: + if (e && ec_key) { + EC_KEY_free(ec_key); + ec_key = NULL; + } + if (pub_key) EC_POINT_free(pub_key); + if (order) BN_free(order); + if (bn) BN_free(bn); + if (ctx) BN_CTX_free(ctx); + if (index) OPENSSL_free(index); + return ec_key; +} + + diff --git a/crypto/cpk/cpk_map.c b/crypto/cpk/cpk_map.c new file mode 100644 index 00000000..5e306724 --- /dev/null +++ b/crypto/cpk/cpk_map.c @@ -0,0 +1,128 @@ +#include +#include +#include +#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; +} + diff --git a/crypto/cpk/cpk_prn.c b/crypto/cpk/cpk_prn.c new file mode 100644 index 00000000..f384f3e8 --- /dev/null +++ b/crypto/cpk/cpk_prn.c @@ -0,0 +1,20 @@ +#include +#include +#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; +} + diff --git a/crypto/ecies/ecies.h b/crypto/ecies/ecies.h index 27e97590..96f6ca72 100644 --- a/crypto/ecies/ecies.h +++ b/crypto/ecies/ecies.h @@ -12,10 +12,22 @@ extern "C" { #endif +/* + KDFSet ALGORITHM ::= { + { OID x9-63-kdf PARMS HashAlgorithm } | + { OID nist-concatenation-kdf PARMS HashAlgorithm } | + { OID tls-kdf PARMS HashAlgorithm } | + { OID ikev2-kdf PARMS HashAlgorithm } + } +*/ + typedef struct ecies_params_st { + int kdf_nid; const EVP_MD *kdf_md; const EVP_CIPHER *sym_cipher; + int mac_nid; const EVP_MD *mac_md; + const EVP_CIPHER *mac_cipher; } ECIES_PARAMS; typedef struct ecies_ciphertext_value_st { @@ -36,14 +48,6 @@ int ECIES_do_decrypt(const ECIES_CIPHERTEXT_VALUE *cv, EC_KEY *pri_key); - -/* ERR function (should in openssl/err.h) begin */ -/* -#define ERR_LIB_ECIES 129 -#define ERR_R_ECIES_LIB ERR_LIB_ECIES -#define ECIESerr(f,r) ERR_PUT_error(ERR_LIB_ECIES,(f),(r),__FILE__,__LINE__) -*/ - void ERR_load_ECIES_strings(void); /* Error codes for the ECIES functions. */ diff --git a/crypto/ecies/ecies_asn1.c b/crypto/ecies/ecies_asn1.c index b416872f..1b1c4812 100644 --- a/crypto/ecies/ecies_asn1.c +++ b/crypto/ecies/ecies_asn1.c @@ -95,6 +95,9 @@ secg-scheme 22 : hmac-full-ecies secg-scheme 23 : hmac-half-ecies secg-scheme 24 0 : cmac-aes128-ecies secg-scheme 24 1 : cmac-aes192-ecies + +FIXME: we can not get an EVP_algor object from these new NIDs + */ typedef struct ecies_parameters_st { diff --git a/crypto/ecies/ecies_lib.c b/crypto/ecies/ecies_lib.c index 300df420..e94aeed0 100644 --- a/crypto/ecies/ecies_lib.c +++ b/crypto/ecies/ecies_lib.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -16,7 +17,7 @@ ECIES_CIPHERTEXT_VALUE *ECIES_do_encrypt(const ECIES_PARAMS *param, EC_KEY *ephem_key = NULL; unsigned char *share = NULL; unsigned char *enckey, *mackey, *p; - int sharelen, enckeylen, mackeylen, len; + int sharelen, enckeylen, mackeylen, maclen, len; EVP_CIPHER_CTX cipher_ctx; EVP_CIPHER_CTX_init(&cipher_ctx); @@ -67,7 +68,29 @@ ECIES_CIPHERTEXT_VALUE *ECIES_do_encrypt(const ECIES_PARAMS *param, if (param->sym_cipher) enckeylen = EVP_CIPHER_key_length(param->sym_cipher); else enckeylen = inlen; - mackeylen = EVP_MD_size(param->mac_md); //TODO: is this true for hmac-half-ecies? + + switch (param->mac_nid) { + case NID_hmac_full_ecies: + maclen = EVP_MD_size(param->mac_md); + mackeylen = EVP_MD_size(param->mac_md); + break; + case NID_hmac_half_ecies: + maclen = EVP_MD_size(param->mac_md)/2; + mackeylen = EVP_MD_size(param->mac_md); + break; + case NID_cmac_aes128_ecies: + maclen = AES_BLOCK_SIZE; + mackeylen = 128/8; + break; + case NID_cmac_aes192_ecies: + maclen = AES_BLOCK_SIZE; + mackeylen = 192/8; + break; + default: + ECIESerr(ECIES_F_ECIES_DO_ENCRYPT, ERR_R_EC_LIB); + goto err; + } + sharelen = enckeylen + mackeylen; if (!(share = OPENSSL_malloc(sharelen))) @@ -138,12 +161,12 @@ ECIES_CIPHERTEXT_VALUE *ECIES_do_encrypt(const ECIES_PARAMS *param, /* * calculate mactag of ciphertext and encode */ - cv->mactag->length = EVP_MD_size(param->mac_md); + cv->mactag->length = maclen; - if (!M_ASN1_OCTET_STRING_set(cv->mactag, NULL, EVP_MD_size(param->mac_md))) + if (!M_ASN1_OCTET_STRING_set(cv->mactag, NULL, cv->mactag->length)) { ECIESerr(ECIES_F_ECIES_DO_ENCRYPT, ERR_R_MALLOC_FAILURE); - goto err; + goto err; } if (!HMAC(param->mac_md, mackey, mackeylen, cv->ciphertext->data, (size_t)cv->ciphertext->length, diff --git a/crypto/ecies/kdf_x9_63.c b/crypto/ecies/kdf_x9_63.c index 715cb228..0b9b1ad5 100644 --- a/crypto/ecies/kdf_x9_63.c +++ b/crypto/ecies/kdf_x9_63.c @@ -14,7 +14,7 @@ static void *x963_kdf(const EVP_MD *md, const void *share, size_t sharelen, void *key, size_t keylen) { EVP_MD_CTX ctx; - unsigned int counter = 1; + unsigned int counter = 1; //FIXME: uint32_t unsigned int counter_be; unsigned char dgst[EVP_MAX_MD_SIZE]; unsigned int dgstlen; diff --git a/crypto/err/err.h b/crypto/err/err.h index 7e74703a..913b33b1 100644 --- a/crypto/err/err.h +++ b/crypto/err/err.h @@ -291,7 +291,7 @@ typedef struct err_state_st { # define ERR_R_ECDH_LIB ERR_LIB_ECDH/* 43 */ # define ERR_R_STORE_LIB ERR_LIB_STORE/* 44 */ # define ERR_R_TS_LIB ERR_LIB_TS/* 45 */ -# define ERR_R_EICES_LIB ERR_LIB_ECIES/* 50 */ +# define ERR_R_ECIES_LIB ERR_LIB_ECIES/* 50 */ # define ERR_R_NESTED_ASN1_ERROR 58 # define ERR_R_BAD_ASN1_OBJECT_HEADER 59 diff --git a/crypto/evp/Makefile b/crypto/evp/Makefile index 31a3d215..f06345db 100644 --- a/crypto/evp/Makefile +++ b/crypto/evp/Makefile @@ -30,7 +30,7 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c evp_cnf.c \ evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \ e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c \ e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c \ - m_sm3.c e_sms4.c + m_sm3.c e_sms4.c e_zuc.c LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o evp_cnf.o \ e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\ @@ -44,7 +44,7 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o evp_cnf.o \ evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o \ e_old.o pmeth_lib.o pmeth_fn.o pmeth_gn.o m_sigver.o \ e_aes_cbc_hmac_sha1.o e_aes_cbc_hmac_sha256.o e_rc4_hmac_md5.o \ - m_sm3.o e_sms4.o + m_sm3.o e_sms4.o e_zuc.o SRC= $(LIBSRC) @@ -354,6 +354,16 @@ e_sms4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h e_sms4.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h e_sms4.o: ../../include/openssl/symhacks.h ../cryptlib.h e_sms4.c evp_locl.h +e_zuc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h +e_zuc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h +e_zuc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +#e_zuc.o: ../../include/openssl/evp.h ../../include/openssl/zuc.h +e_zuc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h +e_zuc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +e_zuc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +e_zuc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +e_zuc.o: ../../include/openssl/symhacks.h ../cryptlib.h e_zuc.c evp_locl.h + e_seed.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h e_seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h e_seed.o: ../../include/openssl/err.h ../../include/openssl/evp.h diff --git a/crypto/evp/c_allc.c b/crypto/evp/c_allc.c index 2de35085..a53e463c 100644 --- a/crypto/evp/c_allc.c +++ b/crypto/evp/c_allc.c @@ -172,6 +172,10 @@ void OpenSSL_add_all_ciphers(void) EVP_add_cipher_alias(SN_sms4_cbc,"sms4"); #endif +#ifndef OPENSSL_NO_ZUC + EVP_add_cipher(EVP_zuc()); +#endif + #ifndef OPENSSL_NO_AES EVP_add_cipher(EVP_aes_128_ecb()); EVP_add_cipher(EVP_aes_128_cbc()); diff --git a/crypto/evp/e_zuc.c b/crypto/evp/e_zuc.c new file mode 100644 index 00000000..0a7388bf --- /dev/null +++ b/crypto/evp/e_zuc.c @@ -0,0 +1,48 @@ +#include +#include "cryptlib.h" + +#ifndef OPENSSL_NO_ZUC + +#include +#include "evp_locl.h" +#include +#include + + +static int zuc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc) +{ + //ZUC_set_key((ZUC_KEY *)&ctx->cipher_data, EVP_CIPHER_CTX_key_length(ctx), key); + return 1; +} + +static int zuc_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, size_t inlen) +{ + //ZUC_encrypt((ZUC_KEY *)&ctx->cipher_data, inlen, in, out); + return 1; +} + +static const EVP_CIPHER zuc_cipher = { + NID_zuc, /* nid */ + 4, /* block_size */ + 16, /* key_len */ + 16, /* iv_len */ + 0, /* flags */ + zuc_init, /* init() */ + zuc_do_cipher, /* do_cipher() */ + NULL, /* cleanup() */ + sizeof(ZUC_KEY), /* ctx_size */ + NULL, /* set_asn1_parameters() */ + NULL, /* get_asn1_parameters() */ + NULL, /* ctrl() */ + NULL /* app_data */ +}; + +const EVP_CIPHER *EVP_zuc(void) +{ + return &zuc_cipher; +} + +#endif + diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h index c60eea34..9d425575 100644 --- a/crypto/evp/evp.h +++ b/crypto/evp/evp.h @@ -838,6 +838,9 @@ const EVP_CIPHER *EVP_sms4_ofb128(void); #define EVP_sm4_cfb128 EVP_sms4_cfb128 #define EVP_sm4_ofb128 EVP_sms4_ofb128 #endif +#ifndef OPENSSL_NO_ZUC +const EVP_CIPHER *EVP_zuc(void); +#endif # ifndef OPENSSL_NO_AES const EVP_CIPHER *EVP_aes_128_ecb(void); const EVP_CIPHER *EVP_aes_128_cbc(void); diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 28b0d483..d000d2af 100644 --- a/crypto/objects/obj_dat.h +++ b/crypto/objects/obj_dat.h @@ -62,12 +62,12 @@ * [including the GNU Public Licence.] */ -#define NUM_NID 1000 -#define NUM_SN 985 -#define NUM_LN 985 -#define NUM_OBJ 924 +#define NUM_NID 1001 +#define NUM_SN 986 +#define NUM_LN 986 +#define NUM_OBJ 925 -static const unsigned char lvalues[6483]={ +static const unsigned char lvalues[6491]={ 0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */ @@ -986,6 +986,7 @@ static const unsigned char lvalues[6483]={ 0x2B,0x81,0x04,0x01,0x17, /* [6465] OBJ_hmac_half_ecies */ 0x2B,0x81,0x04,0x01,0x18,0x00, /* [6470] OBJ_cmac_aes128_ecies */ 0x2B,0x81,0x04,0x01,0x18,0x01, /* [6476] OBJ_cmac_aes192_ecies */ +0x2A,0x81,0x1C,0xCF,0x55,0x01,0x81,0x48, /* [6482] OBJ_zuc */ }; static const ASN1_OBJECT nid_objs[NUM_NID]={ @@ -2607,6 +2608,7 @@ static const ASN1_OBJECT nid_objs[NUM_NID]={ &(lvalues[6470]),0}, {"cmac-aes192-ecies","cmac-aes192-ecies",NID_cmac_aes192_ecies,6, &(lvalues[6476]),0}, +{"ZUC","zuc",NID_zuc,8,&(lvalues[6482]),0}, }; static const unsigned int sn_objs[NUM_SN]={ @@ -2813,6 +2815,7 @@ static const unsigned int sn_objs[NUM_SN]={ 184, /* "X9-57" */ 185, /* "X9cm" */ 125, /* "ZLIB" */ +1000, /* "ZUC" */ 478, /* "aRecord" */ 289, /* "aaControls" */ 287, /* "ac-auditEntity" */ @@ -4583,6 +4586,7 @@ static const unsigned int ln_objs[NUM_LN]={ 985, /* "x9-63-kdf" */ 989, /* "xor-in-ecies" */ 125, /* "zlib compression" */ +1000, /* "zuc" */ }; static const unsigned int obj_objs[NUM_OBJ]={ @@ -5021,6 +5025,7 @@ static const unsigned int obj_objs[NUM_OBJ]={ 978, /* OBJ_sms4_cbc 1 2 156 10197 1 104 2 */ 982, /* OBJ_sms4_cfb128 1 2 156 10197 1 104 3 */ 981, /* OBJ_sms4_ofb128 1 2 156 10197 1 104 4 */ +1000, /* OBJ_zuc 1 2 156 10197 1 200 */ 969, /* OBJ_sm2 1 2 156 10197 1 301 */ 962, /* OBJ_sm3 1 2 156 10197 1 401 */ 973, /* OBJ_sm2sign_with_sm3 1 2 156 10197 1 501 */ diff --git a/crypto/objects/obj_mac.h b/crypto/objects/obj_mac.h index 9e205f8f..05ee4dbe 100644 --- a/crypto/objects/obj_mac.h +++ b/crypto/objects/obj_mac.h @@ -4340,3 +4340,8 @@ #define LN_sms4_ofb128 "sms4-ofb" #define NID_sms4_ofb128 981 #define OBJ_sms4_ofb128 OBJ_sm,104L,4L + +#define SN_zuc "ZUC" +#define LN_zuc "zuc" +#define NID_zuc 1000 +#define OBJ_zuc OBJ_sm,200L diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index f993f93e..e806edfe 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -997,3 +997,4 @@ hmac_full_ecies 996 hmac_half_ecies 997 cmac_aes128_ecies 998 cmac_aes192_ecies 999 +zuc 1000 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index 5b44ef57..1cb8144b 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -1393,3 +1393,6 @@ sm 104 2 : SMS4-CBC : sms4-cbc sm 104 3 : SMS4-CFB : sms4-cfb !Cname sms4-ofb128 sm 104 4 : SMS4-OFB : sms4-ofb + +sm 200 : ZUC : zuc + diff --git a/crypto/sm2/Makefile b/crypto/sm2/Makefile new file mode 100644 index 00000000..e23002a7 --- /dev/null +++ b/crypto/sm2/Makefile @@ -0,0 +1,79 @@ +# +# crypto/ecies/Makefile +# + +DIR= sm2 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I$(TOP) -I../../include +CFLAG=-g -Wall +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=sm2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= sm2_dgst.c sm2_enc.c + +LIBOBJ= sm2_dgst.o sm2_enc.o + +SRC= $(LIBSRC) + +EXHEADER= sm2_enc.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. + diff --git a/crypto/sm2/sm2_dgst.c b/crypto/sm2/sm2_dgst.c new file mode 100644 index 00000000..a114bcc0 --- /dev/null +++ b/crypto/sm2/sm2_dgst.c @@ -0,0 +1,170 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#define EC_MAX_NBYTES ((OPENSSL_ECC_MAX_FIELD_BITS + 7)/8) + +/* + * pkdata = a || b || G.x || G.y || P.x || P.y + */ +static int sm2_get_public_key_data(unsigned char *buf, EC_KEY *ec_key) +{ + int ret = -1; + int nbytes = (EC_GROUP_get_degree(ec_group) + 7) / 8; + const EC_GROUP *ec_group = EC_KEY_get0_group(ec_key); + const EC_POINT *point; + unsigned char oct[EC_MAX_NBYTES * 2 + 1]; + BN_CTX *ctx = NULL; + BIGNUM *p = NULL; + BIGNUM *x = NULL; + BIGNUM *y = NULL; + + OPENSSL_assert(ec_key); + OPENSSL_assert(nbytes == 256/8); + + if (!buf) { + return (nbytes * 6); + } + bzero(buf, nbytes * 6); + + ctx = BN_CTX_new(); + p = BN_new(); + x = BN_new(); + y = BN_new(); + if (!ctx || !p || !x || !y) { + goto err; + } + + /* get curve coefficients a, b */ + if (!EC_GROUP_get_curve_GFp(ec_group, p, x, y, ctx)) { + goto err; + } + buf += nbytes; + if (!BN_bn2bin(x, buf - BN_num_bytes(x))) { + goto err; + } + buf += nbytes; + if (!BN_bn2bin(y, buf - BN_num_bytes(y))) { + goto err; + } + + /* get curve generator coordinates */ + if (!(point = EC_GROUP_get0_generator(ec_group))) { + goto err; + } + if (!(len = EC_POINT_point2oct(ec_group, point, + POINT_CONVERSION_UNCOMPRESSED, oct, sizeof(oct), bn_ctx))) { + goto err; + } + OPENSSL_assert(len == 32 * 2 + 1); + memcpy(buf, oct + 1, len - 1); + buf += len - 1; + + /* get pub_key coorindates */ + if (!(point = EC_KEY_get0_public_key(ec_key))) { + goto err; + } + if (!(len = EC_POINT_point2oct(ec_group, point, + POINT_CONVERSION_UNCOMPRESSED, oct, sizeof(oct), bn_ctx))) { + goto err; + } + OPENSSL_assert(len == 32 * 2 + 1); + memcpy(buf, oct + 1, len - 1); + buf += len - 1; + + ret = (nbytes * 6); +err: + if (ctx) BN_CTX_free(ctx); + if (p) BN_free(p); + if (x) BN_free(x); + if (y) BN_free(y); + + return ret; +} + +int SM2_compute_za(unsigned char *za, const EVP_MD *md, + const void *id, size_t idlen, EC_KEY *ec_key) +{ + int ret = 0; + EVP_MD_CTX *ctx = NULL; + unsigned char pkdata[EC_MAX_NBYTES * 6]; + uint16_t idbits; + int len; + idbits = cpu_to_be16(idlen * 8); + + if ((pkdatalen = sm2_get_public_key_data(pkdata, ec_key)) < 0) { + goto err; + } + + if (!(ctx = EVP_MD_CTX_create())) { + goto err; + } + if (!EVP_DigestInit_ex(ctx, md, NULL)) { + goto end; + } + if (!EVP_DigestUpdate(ctx, &idbits, sizeof(idbits))) { + goto end; + } + if (!EVP_DigestUpdate(ctx, id, idlen)) { + goto end; + } + if (!EVP_DigestUpdate(ctx, pkdata, pkdatalen)) { + goto end; + } + if (!EVP_DigestFinal(ctx, za, &zalen)) { + } + + ret = SM3_DIGEST_LENGTH; + +err: + if (ctx) EVP_MD_CTX_destroy(ctx); + return ret; +} + +int SM2_compute_digest(unsigned char *dgst, unsigned int *dgstlen, + const EVP_MD *za_md, const void *id, size_t idlen, EC_KEY *ec_key, + const EVP_MD *msg_md, const void *msg, size_t msglen) +{ + int ret = 0; + unsigned char za[EVP_MAX_MD_SIZE]; + int zalen; + EVP_MD_CTX *ctx = NULL; + + /* compute Za */ + if (idlen > SM2_MAX_ID_LENGTH) { + goto err; + } + if ((zalen = SM2_compute_za(za, za_md, id, idlen, ec_key)) < 0) { + goto err; + } + + /* compute digest */ + if (!(ctx = EVP_MD_CTX_create())) { + goto err; + } + if (!EVP_DigestInit_ex(ctx, msg_md, NULL)) { + goto err; + } + if (!EVP_DigestUpdate(ctx, za, zalen)) { + goto err; + } + if (!EVP_DigestUpdate(ctx, msg, msglen)) { + goto err; + } + if (!EVP_DigestFinal_ex(ctx, dgst, dgstlen)) { + goto err; + } + + ret = 1; + +err: + if (ctx) EVP_MD_CTX_destroy(ctx); + return ret; +} + diff --git a/crypto/sm2/sm2_enc.c b/crypto/sm2/sm2_enc.c new file mode 100644 index 00000000..13952068 --- /dev/null +++ b/crypto/sm2/sm2_enc.c @@ -0,0 +1,284 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sm2_enc.h" + +void SM2_CIPEHRTEXT_VALUE_free(SM2_CIPHERTEXT_VALUE *cv) +{ + if (cv->ephem_point) EC_POINT_free(cv->ephem_point); + if (cv->ciphertext) OPENSSL_free(cv->ciphertext); + bzero(cv, sizeof(SM2_CIPHERTEXT_VALUE)); + OPENSSL_free(cv); +} + +SM2_CIPHERTEXT_VALUE *SM2_do_encrypt( + const EVP_MD *kdf_md, const EVP_MD *mac_md, + const void *in, size_t inlen, const EC_KEY *ec_key); +{ + int ok = 0; + SM2_CIPHERTEXT_VALUE *cv = NULL; + const EC_GROUP *ec_group = EC_KEY_get0_group(ec_key); + const EC_POINT *pub_key = EC_KEY_get0_public_key(ec_key); + KDF_FUNC kdf = KDF_get_x9_63(kdf_md); + EC_POINT *point = NULL; + BIGNUM *n = NULL; + BIGNUM *h = NULL; + BIGNUM *k = NULL; + BN_CTX *bn_ctx = NULL; + EVP_MD_CTX *md_ctx = NULL; + unsigned char buf[(OPENSSL_ECC_MAX_FIELD_BITS + 7)/4 + 1]; + int nbytes; + int i; + + if (!ec_group || !pub_key) { + goto err; + } + if (!kdf) { + goto err; + } + + /* init ciphertext_value */ + if (!(cv = OPENSSL_malloc(sizeof(SM2_CIPHERTEXT_VALUE)))) { + goto err; + } + bzero(cv, sizeof(SM2_CIPHERTEXT_VALUE)); + cv->ephem_point = EC_POINT_new(ec_group); + cv->ciphertext = OPENSSL_malloc(inlen); + cv->ciphertext_size = inlen; + if (!cv->ephem_point || !cv->ciphertext) { + goto err; + } + + point = EC_POINT_new(ec_group); + n = BN_new(); + h = BN_new(); + k = BN_new(); + bn_ctx = BN_CTX_new(); + md_ctx = EVP_MD_CTX_create(); + if (!point || !n || !h || !k || !bn_ctx || !md_ctx) { + goto err; + } + + /* init ec domain parameters */ + if (!EC_GROUP_get_order(ec_group, n, bn_ctx)) { + goto err; + } + if (!EC_GROUP_get_cofactor(ec_group, h, bn_ctx)) { + goto err; + } + nbytes = (EC_GROPU_get_degree(ec_group) + 7) / 8; + OPENSSL_assert(nbytes == BN_num_bytes(n)); + + /* check sm2 curve and md is 256 bits */ + OPENSSL_assert(nbytes == 32); + OPENSSL_assert(EVP_MD_size(kdf_md) == 32); + OPENSSL_assert(EVP_MD_size(mac_md) == 32); + + do + { + /* A1: rand k in [1, n-1] */ + do { + BN_rand_range(k, n); + } while (BN_is_zero(k)); + + /* A2: C1 = [k]G = (x1, y1) */ + if (!EC_POINT_mul(ec_group, cv->ephem_point, k, NULL, NULL, bn_ctx)) { + goto err; + } + + /* A3: check [h]P_B != O */ + if (!EC_POINT_mul(ec_group, point, NULL, pub_key, h, bn_ctx)) { + goto err; + } + if (EC_POINT_is_at_infinity(ec_group, point)) { + goto err; + } + + /* A4: compute ECDH [k]P_B = (x2, y2) */ + if (!EC_POINT_mul(ec_group, point, NULL, pub_key, k, bn_ctx)) { + goto err; + } + if (!(len = EC_POINT_point2oct(ec_group, point, + POINT_CONVERSION_UNCOMPRESSED, buf, sizeof(buf), bn_ctx))) { + goto err; + } + OPENSSL_assert(len == nbytes * 2 + 1); + + /* A5: t = KDF(x2 || y2, klen) */ + kdf(buf - 1, len - 1, cv->ciphertext, &cv->ciphertext_size); + + for (i = 0; i < cv->ciphertext_size; i++) { + if (cv->ciphertext[i]) { + break; + } + } + if (i == cv->ciphertext_size) { + continue; + } + + break; + + } while (1); + + + /* A6: C2 = M xor t */ + for (i = 0; i < inlen; i++) { + cv->ciphertext[i] ^= in[i]; + } + + /* A7: C3 = Hash(x2 || M || y2) */ + if (!EVP_DigestInit_ex(md_ctx, mac_md, NULL)) { + goto err; + } + if (!EVP_DigestUpdate(md_ctx, buf + 1, nbytes)) { + goto err; + } + if (!EVP_DigestUpdate(md_ctx, in, inlen)) { + goto err; + } + if (!EVP_DigestUpdate(md_ctx, buf + 1 + nbytes, nbytes)) { + goto err; + } + if (!EVP_DigestFinal_ex(md_ctx, cv->mactag, &cv->mactag_size)) { + goto err; + } + + ok = 1; + +err: + if (!ok && cv) { + SM2_CIPHERTEXT_VALUE_free(cv); + cv = NULL; + } + + if (n) BN_free(n); + if (h) BN_free(h); + if (k) BN_free(k); + if (bn_ctx) BN_CTX_free(bn_ctx); + if (md_ctx) EVP_MD_CTX_destroy(md_ctx); + + return cv; +} + + +int SM2_do_decrypt(const SM2_CIPHERTEXT_VALUE *cv, + const EVP_MD *kdf_md, const EVP_MD *mac_md, + unsigned char *out, size_t *outlen, EC_KEY *ec_key) +{ + int ret = 0 + const EC_GROUP *ec_group = EC_KEY_get0_group(ec_key); + const BIGNUM *pri_key = EC_KEY_get0_private_key(ec_key); + KDF_FUNC kdf = KDF_get_x9_63(kdf_md); + EC_POINT *point = NULL; + BIGNUM *n = NULL; + BIGNUM *h = NULL; + BN_CTX *bn_ctx = NULL; + EVP_MD_CTX *md_ctx = NULL; + unsigned char buf[(OPENSSL_ECC_MAX_FIELD_BITS + 7)/4 + 1]; + unsigned char mac[EVP_MAX_MD_SIZE]; + int nbytes; + int i; + + if (!ec_group || !pub_key) { + goto err; + } + if (!kdf) { + goto err; + } + + if (!out) { + *outlen = cv->ciphertext_size; + return 1; + } + if (*outlen < cv->ciphertext_size) { + goto err; + } + + /* init vars */ + point = EC_POINT_new(ec_group); + n = BN_new(); + h = BN_new(); + bn_ctx = BN_CTX_new(); + md_ctx = EVP_MD_CTX_create(); + if (!point || !n || !h || !bn_ctx || !md_ctx) { + goto err; + } + + /* init ec domain parameters */ + if (!EC_GROUP_get_order(ec_group, n, bn_ctx)) { + goto err; + } + if (!EC_GROUP_get_cofactor(ec_group, h, bn_ctx)) { + goto err; + } + nbytes = (EC_GROPU_get_degree(ec_group) + 7) / 8; + OPENSSL_assert(nbytes == BN_num_bytes(n)); + + /* check sm2 curve and md is 256 bits */ + OPENSSL_assert(nbytes == 32); + OPENSSL_assert(EVP_MD_size(kdf_md) == 32); + OPENSSL_assert(EVP_MD_size(mac_md) == 32); + + /* B2: check [h]C1 != O */ + if (!EC_POINT_mul(ec_group, point, NULL, cv->ephem_point, h, bn_ctx)) { + goto err; + } + if (EC_POINT_is_at_infinity(ec_group, point)) { + goto err; + } + + /* B3: compute ECDH [d]C1 = (x2, y2) */ + if (!EC_POINT_mul(ec_group, point, NULL, cv->ephem_point, pri_key, bn_ctx)) { + goto err; + } + if (!(len = EC_POINT_point2oct(ec_group, point, + POINT_CONVERSION_UNCOMPRESSED, buf, sizeof(buf), bn_ctx))) { + goto err; + } + + /* B4: compute t = KDF(x2 || y2, clen) */ + kdf(buf - 1, len - 1, out, outlen); + + + /* B5: compute M = C2 xor t */ + for (i = 0; i < cv->ciphertext_size; i++) { + out[i] ^= cv->ciphertext[i]; + } + + /* B6: check Hash(x2 || M || y2) == C3 */ + if (!EVP_DigestInit_ex(md_ctx, mac_md, NULL)) { + goto err; + } + if (!EVP_DigestUpdate(md_ctx, buf + 1, nbytes)) { + goto err; + } + if (!EVP_DigestUpdate(md_ctx, out, *outlen)) { + goto err; + } + if (!EVP_DigestUpdate(md_ctx, buf + 1 + nbytes, nbytes)) { + goto err; + } + if (!EVP_DigestFinal_ex(md_ctx, mac, &maclen)) { + goto err; + } + if (cv->mactag_size != maclen || memcmp(cv->mactag, mac, maclen)) { + goto err; + } + + ret = 1; +err: + if (point) EC_POINT_free(point); + if (n) BN_free(n); + if (h) BN_free(h); + if (bn_ctx) BN_CTX_free(bn_ctx); + if (md_ctx) EVP_MD_CTX_destroy(md_ctx); + + return ret; +} + diff --git a/crypto/sm2/sm2_enc.h b/crypto/sm2/sm2_enc.h new file mode 100644 index 00000000..6cd0a220 --- /dev/null +++ b/crypto/sm2/sm2_enc.h @@ -0,0 +1,59 @@ +#ifndef HEADER_SM2_ENC_H +#define HEADER_SM2_ENC_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct sm2_ciphertext_value_st { + EC_POINT *ephem_point; + unsigned char *ciphertext; + size_t ciphertext_size; + unsigned char mactag[EVP_MAX_MD_SIZE]; + size_t mactag_size; +} SM2_CIPHERTEXT_VALUE; + + +SM2_CIPHERTEXT_VALUE *SM2_do_encrypt( + const EVP_MD *kdf_md, const EVP_MD *mac_md, + const void *in, size_t inlen, const EC_KEY *pub_key); + +int SM2_do_decrypt(const SM2_CIPHERTEXT_VALUE *cv, + const EVP_MD *kdf_md, const EVP_MD *mac_md, + unsigned char *out, size_t *outlen, EC_KEY *pri_key); + +void SM2_CIPHERTEXT_VALUE_free(SM2_CIPHERTEXT_VALUE *cv); + + +void ERR_load_SM2_strings(void); + +/* Error codes for the ECIES functions. */ + +/* Function codes. */ +#define SM2_F_SM2_DO_ENCRYPT 100 +#define SM2_F_SM2_DO_DECRYPT 101 +#define SM2_F_SM2_CIPHERTEXT_VALUE_FREE 102 + +/* Reason codes. */ +#define SM2_R_BAD_DATA 100 +#define SM2_R_UNKNOWN_CIPHER_TYPE 101 +#define SM2_R_ENCRYPT_FAILED 102 +#define SM2_R_DECRYPT_FAILED 103 +#define SM2_R_UNKNOWN_MAC_TYPE 104 +#define SM2_R_GEN_MAC_FAILED 105 +#define SM2_R_VERIFY_MAC_FAILED 106 +#define SM2_R_ECDH_FAILED 107 +#define SM2_R_BUFFER_TOO_SMALL 108 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/crypto/sm2/sm2test.c b/crypto/sm2/sm2test.c new file mode 100644 index 00000000..c5f14ea4 --- /dev/null +++ b/crypto/sm2/sm2test.c @@ -0,0 +1,114 @@ +#include +#include +#include +#include +#include +#include +#include "sm2.h" +#include "sm3.h" + +void SM2PKE_test3() +{ + /* test3 params */ + const char *p = "8542D69E4C044F18E8B92435BF6FF7DE457283915C45517D722EDB8B08F1DFC3"; + const char *a = "787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E498"; + const char *b = "63E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A"; + const char *xG = "421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D"; + const char *yG = "0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2"; + const char *n = "8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7"; + const char *dB = "1649AB77A00637BD5E2EFE283FBF353534AA7F7CB89463F208DDBC2920BB0DA0"; + const char *xB = "435B39CCA8F3B508C1488AFC67BE491A0F7BA07E581A0E4849A5CF70628A7E0A"; + const char *yB = "75DDBA78F15FEECB4C7895E2C1CDF5FE01DEBB2CDBADF45399CCF77BBA076A42"; + + BIGNUM *bn_p = BN_new(); + BN_hex2bn(&bn_p, p); + BIGNUM *bn_a = BN_new(); + BN_hex2bn(&bn_a, a); + BIGNUM *bn_b = BN_new(); + BN_hex2bn(&bn_b, b); + BIGNUM *bn_xG = BN_new(); + BN_hex2bn(&bn_xG, xG); + BIGNUM *bn_yG = BN_new(); + BN_hex2bn(&bn_yG, yG); + BIGNUM *bn_n = BN_new(); + BN_hex2bn(&bn_n, n); + BIGNUM *bn_dB = BN_new(); + BN_hex2bn(&bn_dB, dB); + BIGNUM *bn_xB = BN_new(); + BN_hex2bn(&bn_xB, xB); + BIGNUM *bn_yB = BN_new(); + BN_hex2bn(&bn_yB, yB); + + BN_CTX *bn_ctx = BN_CTX_new(); + EC_GROUP *ec_group = EC_GROUP_new(EC_GFp_mont_method()); + EC_GROUP_set_curve_GFp(ec_group, bn_p, bn_a, bn_b, bn_ctx); + + EC_POINT *G = EC_POINT_new(ec_group); + EC_POINT_set_affine_coordinates_GFp(ec_group, G, bn_xG, bn_yG, bn_ctx); + BIGNUM *bn_h = BN_new(); /* cofactor h = #E(Fp) / n */ + BN_div(bn_h, NULL, bn_p, bn_n, bn_ctx); + EC_GROUP_set_generator(ec_group, G, bn_n, bn_h); + + EC_POINT *PB = EC_POINT_new(ec_group); + EC_POINT_set_affine_coordinates_GFp(ec_group, PB, bn_xB, bn_yB, bn_ctx); + EC_KEY *ec_key_B = EC_KEY_new(); + EC_KEY_set_group(ec_key_B, ec_group); + EC_KEY_set_private_key(ec_key_B, bn_dB); + EC_KEY_set_public_key(ec_key_B, PB); + + BN_free(bn_p); + BN_free(bn_a); + BN_free(bn_b); + BN_free(bn_n); + BN_free(bn_xG); + BN_free(bn_yG); + BN_free(bn_dB); + BN_free(bn_xB); + BN_free(bn_yB); + BN_free(bn_h); + BN_CTX_free(bn_ctx); + EC_POINT_free(G); + EC_POINT_free(PB); + EC_GROUP_free(ec_group); + + char *M = "encryption standard"; + char *ctest = "04245C26FB68B1DDDDB12C4B6BF9F2B6D5FE60A383B0D18D1C4144ABF17F6252" + "E776CB9264C2A7E88E52B19903FDC47378F605E36811F5C07423A24B84400F01" + "B8650053A89B41C418B0C3AAD00D886C002864679C3D7360C30156FAB7C80A02" + "76712DA9D8094A634B766D3A285E07480653426D"; + BIGNUM *ct = BN_new(); + BN_hex2bn(&ct, ctest); + unsigned char ct2bin[116]; + BN_bn2bin(ct, ct2bin); + BN_free(ct); + + int mlen = strlen(M); + int c1len = PRIME_SIZE / 8 * 2 + 1; + int clen = c1len + mlen + HASH_V / 8; + + unsigned char *C = malloc(sizeof(unsigned char) * clen); + sm2_pke_encrypt(C, M, mlen, ec_key_B); + if (memcmp(C, ct2bin, clen) == 0) + printf("sm2_pke_encrypt passed.\n"); + else + printf("sm2_pke_encrypt failed.\n"); + free(C); + + int m1len = clen - c1len - HASH_V / 8; + unsigned char *M1bin = malloc(sizeof(unsigned char) * m1len); + sm2_pke_decrypt((char *)ct2bin, M1bin, m1len, ec_key_B); + if (memcmp(M1bin, M, m1len) == 0) + printf("sm2_pke_decrypt passed.\n"); + else + printf("sm2_pke_decrypt failed.\n"); + free(M1bin); + + EC_KEY_free(ec_key_B); +} + +int main() +{ + SM2PKE_test3(); + return 0; +} + diff --git a/crypto/sms4/sms4.h b/crypto/sms4/sms4.h index 56539860..40e9dd49 100644 --- a/crypto/sms4/sms4.h +++ b/crypto/sms4/sms4.h @@ -1,5 +1,5 @@ -#ifndef LIBSM_SMS4_H -#define LIBSM_SMS4_H +#ifndef HEADER_SMS4_H +#define HEADER_SMS4_H #define SMS4_KEY_LENGTH 16 #define SMS4_BLOCK_SIZE 16 @@ -9,6 +9,8 @@ #include #include #include "openssl/modes.h" + + #ifdef __cplusplus extern "C" { #endif @@ -20,18 +22,21 @@ typedef struct { void sms4_set_encrypt_key(sms4_key_t *key, const unsigned char *user_key); void sms4_set_decrypt_key(sms4_key_t *key, const unsigned char *user_key); void sms4_encrypt(const unsigned char *in, unsigned char *out, sms4_key_t *key); -void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const sms4_key_t *key, - unsigned char *ivec, int encrypt); +void sms4_ecb_encrypt(const unsigned char *in, unsigned char *out, const sms4_key_t *key, int encrypt); + + +void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, + const sms4_key_t *key, unsigned char *ivec, int encrypt); void sms4_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const sms4_key_t *key, + size_t length, const sms4_key_t *key, unsigned char *ivec, int *num, int encrypt); void sms4_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const sms4_key_t *key, unsigned char ivec[SMS4_BLOCK_SIZE], unsigned int *num); -void sms4_ecb_encrypt(const unsigned char *in, unsigned char *out, const sms4_key_t *key, int encrypt); + #define sms4_decrypt(in,out,key) sms4_encrypt(in,out,key) + #ifdef __cplusplus } #endif diff --git a/crypto/sms4/sms4_cbc.c b/crypto/sms4/sms4_cbc.c index 054b8684..646015b9 100644 --- a/crypto/sms4/sms4_cbc.c +++ b/crypto/sms4/sms4_cbc.c @@ -5,7 +5,8 @@ void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, const sms4_key_t *key, - unsigned char *ivec, int encrypt) { + unsigned char *ivec, int encrypt) +{ if(encrypt) CRYPTO_cbc128_encrypt(in,out,len,key,ivec,(block128_f)sms4_encrypt); else diff --git a/crypto/sms4/sms4_ecb.c b/crypto/sms4/sms4_ecb.c index e53806d7..8a29fc0e 100644 --- a/crypto/sms4/sms4_ecb.c +++ b/crypto/sms4/sms4_ecb.c @@ -12,4 +12,4 @@ void sms4_ecb_encrypt(const unsigned char *in, unsigned char *out, const sms4_ke sms4_decrypt(in, out, key); } -//sms4_decrypt = sms4_encrypt, but the key is in reverse order \ No newline at end of file +//sms4_decrypt = sms4_encrypt, but the key is in reverse order diff --git a/crypto/zuc/Makefile b/crypto/zuc/Makefile new file mode 100644 index 00000000..bd3efd0c --- /dev/null +++ b/crypto/zuc/Makefile @@ -0,0 +1,94 @@ +# +# OpenSSL/crypto/zuc/Makefile +# + +DIR=zuc +TOP=../.. +CC=cc +CPP=$(CC) -E +INCLUDES= +CFLAG=-g +AR=ar r + + +ZUC_ENC=zuc.o + +CFLAGS= $(INCLUDES) $(CFLAG) +ASFLAGS= $(INCLUDES) $(ASFLAG) +AFLAGS= $(ASFLAGS) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=zuc.c +LIBOBJ=$(ZUC_ENC) + +SRC= $(LIBSRC) + +EXHEADER=zuc.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 "RC4_ENC=$(RC4_ENC)" 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 *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +# DO NOT DELETE THIS LINE -- make depend depends on it. + + + + +zuc.o: ../../e_os.h ../../include/openssl/bio.h +zuc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h +zuc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +zuc.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h +zuc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +zuc.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h +zuc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +zuc.o: ../cryptlib.h zuc.c zuc.h diff --git a/crypto/zuc/zuc.c b/crypto/zuc/zuc.c new file mode 100755 index 00000000..a97e320e --- /dev/null +++ b/crypto/zuc/zuc.c @@ -0,0 +1,221 @@ +#include "zuc.h" + + + +static uint8_t S0[256] = { + 0x3e,0x72,0x5b,0x47,0xca,0xe0,0x00,0x33,0x04,0xd1,0x54,0x98,0x09,0xb9,0x6d,0xcb, + 0x7b,0x1b,0xf9,0x32,0xaf,0x9d,0x6a,0xa5,0xb8,0x2d,0xfc,0x1d,0x08,0x53,0x03,0x90, + 0x4d,0x4e,0x84,0x99,0xe4,0xce,0xd9,0x91,0xdd,0xb6,0x85,0x48,0x8b,0x29,0x6e,0xac, + 0xcd,0xc1,0xf8,0x1e,0x73,0x43,0x69,0xc6,0xb5,0xbd,0xfd,0x39,0x63,0x20,0xd4,0x38, + 0x76,0x7d,0xb2,0xa7,0xcf,0xed,0x57,0xc5,0xf3,0x2c,0xbb,0x14,0x21,0x06,0x55,0x9b, + 0xe3,0xef,0x5e,0x31,0x4f,0x7f,0x5a,0xa4,0x0d,0x82,0x51,0x49,0x5f,0xba,0x58,0x1c, + 0x4a,0x16,0xd5,0x17,0xa8,0x92,0x24,0x1f,0x8c,0xff,0xd8,0xae,0x2e,0x01,0xd3,0xad, + 0x3b,0x4b,0xda,0x46,0xeb,0xc9,0xde,0x9a,0x8f,0x87,0xd7,0x3a,0x80,0x6f,0x2f,0xc8, + 0xb1,0xb4,0x37,0xf7,0x0a,0x22,0x13,0x28,0x7c,0xcc,0x3c,0x89,0xc7,0xc3,0x96,0x56, + 0x07,0xbf,0x7e,0xf0,0x0b,0x2b,0x97,0x52,0x35,0x41,0x79,0x61,0xa6,0x4c,0x10,0xfe, + 0xbc,0x26,0x95,0x88,0x8a,0xb0,0xa3,0xfb,0xc0,0x18,0x94,0xf2,0xe1,0xe5,0xe9,0x5d, + 0xd0,0xdc,0x11,0x66,0x64,0x5c,0xec,0x59,0x42,0x75,0x12,0xf5,0x74,0x9c,0xaa,0x23, + 0x0e,0x86,0xab,0xbe,0x2a,0x02,0xe7,0x67,0xe6,0x44,0xa2,0x6c,0xc2,0x93,0x9f,0xf1, + 0xf6,0xfa,0x36,0xd2,0x50,0x68,0x9e,0x62,0x71,0x15,0x3d,0xd6,0x40,0xc4,0xe2,0x0f, + 0x8e,0x83,0x77,0x6b,0x25,0x05,0x3f,0x0c,0x30,0xea,0x70,0xb7,0xa1,0xe8,0xa9,0x65, + 0x8d,0x27,0x1a,0xdb,0x81,0xb3,0xa0,0xf4,0x45,0x7a,0x19,0xdf,0xee,0x78,0x34,0x60 +}; + +static uint8_t S1[256] = { + 0x55,0xc2,0x63,0x71,0x3b,0xc8,0x47,0x86,0x9f,0x3c,0xda,0x5b,0x29,0xaa,0xfd,0x77, + 0x8c,0xc5,0x94,0x0c,0xa6,0x1a,0x13,0x00,0xe3,0xa8,0x16,0x72,0x40,0xf9,0xf8,0x42, + 0x44,0x26,0x68,0x96,0x81,0xd9,0x45,0x3e,0x10,0x76,0xc6,0xa7,0x8b,0x39,0x43,0xe1, + 0x3a,0xb5,0x56,0x2a,0xc0,0x6d,0xb3,0x05,0x22,0x66,0xbf,0xdc,0x0b,0xfa,0x62,0x48, + 0xdd,0x20,0x11,0x06,0x36,0xc9,0xc1,0xcf,0xf6,0x27,0x52,0xbb,0x69,0xf5,0xd4,0x87, + 0x7f,0x84,0x4c,0xd2,0x9c,0x57,0xa4,0xbc,0x4f,0x9a,0xdf,0xfe,0xd6,0x8d,0x7a,0xeb, + 0x2b,0x53,0xd8,0x5c,0xa1,0x14,0x17,0xfb,0x23,0xd5,0x7d,0x30,0x67,0x73,0x08,0x09, + 0xee,0xb7,0x70,0x3f,0x61,0xb2,0x19,0x8e,0x4e,0xe5,0x4b,0x93,0x8f,0x5d,0xdb,0xa9, + 0xad,0xf1,0xae,0x2e,0xcb,0x0d,0xfc,0xf4,0x2d,0x46,0x6e,0x1d,0x97,0xe8,0xd1,0xe9, + 0x4d,0x37,0xa5,0x75,0x5e,0x83,0x9e,0xab,0x82,0x9d,0xb9,0x1c,0xe0,0xcd,0x49,0x89, + 0x01,0xb6,0xbd,0x58,0x24,0xa2,0x5f,0x38,0x78,0x99,0x15,0x90,0x50,0xb8,0x95,0xe4, + 0xd0,0x91,0xc7,0xce,0xed,0x0f,0xb4,0x6f,0xa0,0xcc,0xf0,0x02,0x4a,0x79,0xc3,0xde, + 0xa3,0xef,0xea,0x51,0xe6,0x6b,0x18,0xec,0x1b,0x2c,0x80,0xf7,0x74,0xe7,0xff,0x21, + 0x5a,0x6a,0x54,0x1e,0x41,0x31,0x92,0x35,0xc4,0x33,0x07,0x0a,0xba,0x7e,0x0e,0x34, + 0x88,0xb1,0x98,0x7c,0xf3,0x3d,0x60,0x6c,0x7b,0xca,0xd3,0x1f,0x32,0x65,0x04,0x28, + 0x64,0xbe,0x85,0x9b,0x2f,0x59,0x8a,0xd7,0xb0,0x25,0xac,0xaf,0x12,0x03,0xe2,0xf2 +}; + +static uint32_t EK_d[16] = { + 0x44D7, 0x26BC, 0x626B, 0x135E, 0x5789, 0x35E2, 0x7135, 0x09AF, + 0x4D78, 0x2F13, 0x6BC4, 0x1AF1, 0x5E26, 0x3C4D, 0x789A, 0x47AC +}; + +static inline uint32_t AddM(uint32_t a, uint32_t b) +{ + uint32_t c = a + b; + return (c & 0x7FFFFFFF) + (c >> 31); +} + +#define MulByPow2(x, k) ((((x) << k) | ((x) >> (31 - k))) & 0x7FFFFFFF) +static void LFSRWithInitialisationMode(ZUC_KEY *key, uint32_t u) +{ + uint32_t f, v; + f = key->LFSR_S0; + + v = MulByPow2(key->LFSR_S0, 8); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S4, 20); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S10, 21); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S13, 17); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S15, 15); + f = AddM(f, v); + + f = AddM(f, u); + + /* update the state */ + key->LFSR_S0 = key->LFSR_S1; + key->LFSR_S1 = key->LFSR_S2; + key->LFSR_S2 = key->LFSR_S3; + key->LFSR_S3 = key->LFSR_S4; + key->LFSR_S4 = key->LFSR_S5; + key->LFSR_S5 = key->LFSR_S6; + key->LFSR_S6 = key->LFSR_S7; + key->LFSR_S7 = key->LFSR_S8; + key->LFSR_S8 = key->LFSR_S9; + key->LFSR_S9 = key->LFSR_S10; + key->LFSR_S10 = key->LFSR_S11; + key->LFSR_S11 = key->LFSR_S12; + key->LFSR_S12 = key->LFSR_S13; + key->LFSR_S13 = key->LFSR_S14; + key->LFSR_S14 = key->LFSR_S15; + key->LFSR_S15 = f; +} + +/* LFSR with work mode */ +static void LFSRWithWorkMode(ZUC_KEY *key) +{ + uint32_t f, v; + f = key->LFSR_S0; + + v = MulByPow2(key->LFSR_S0, 8); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S4, 20); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S10, 21); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S13, 17); + f = AddM(f, v); + v = MulByPow2(key->LFSR_S15, 15); + f = AddM(f, v); + + /* update the state */ + key->LFSR_S0 = key->LFSR_S1; + key->LFSR_S1 = key->LFSR_S2; + key->LFSR_S2 = key->LFSR_S3; + key->LFSR_S3 = key->LFSR_S4; + key->LFSR_S4 = key->LFSR_S5; + key->LFSR_S5 = key->LFSR_S6; + key->LFSR_S6 = key->LFSR_S7; + key->LFSR_S7 = key->LFSR_S8; + key->LFSR_S8 = key->LFSR_S9; + key->LFSR_S9 = key->LFSR_S10; + key->LFSR_S10 = key->LFSR_S11; + key->LFSR_S11 = key->LFSR_S12; + key->LFSR_S12 = key->LFSR_S13; + key->LFSR_S13 = key->LFSR_S14; + key->LFSR_S14 = key->LFSR_S15; + key->LFSR_S15 = f; +} + +/* BitReorganization */ +static inline void BitReorganization(ZUC_KEY *key) +{ + key->BRC_X0 = ((key->LFSR_S15 & 0x7FFF8000) << 1) | (key->LFSR_S14 & 0xFFFF); + key->BRC_X1 = ((key->LFSR_S11 & 0xFFFF) << 16) | (key->LFSR_S9 >> 15); + key->BRC_X2 = ((key->LFSR_S7 & 0xFFFF) << 16) | (key->LFSR_S5 >> 15); + key->BRC_X3 = ((key->LFSR_S2 & 0xFFFF) << 16) | (key->LFSR_S0 >> 15); +} + +#define ROT(a, k) (((a) << k) | ((a) >> (32 - k))) + +static inline uint32_t L1(uint32_t X) +{ + return (X ^ ROT(X, 2) ^ ROT(X, 10) ^ ROT(X, 18) ^ ROT(X, 24)); +} + +static inline uint32_t L2(uint32_t X) +{ + return (X ^ ROT(X, 8) ^ ROT(X, 14) ^ ROT(X, 22) ^ ROT(X, 30)); +} + +#define MAKEuint32_t(a, b, c, d) (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | ((uint32_t)(d))) + +static uint32_t F(ZUC_KEY *key) +{ + uint32_t W, W1, W2, u, v; + + W = (key->BRC_X0 ^ key->F_R1) + key->F_R2; + W1 = key->F_R1 + key->BRC_X1; + W2 = key->F_R2 ^ key->BRC_X2; + + u = L1((W1 << 16) | (W2 >> 16)); + v = L2((W2 << 16) | (W1 >> 16)); + + key->F_R1 = MAKEuint32_t(S0[u >> 24], S1[(u >> 16) & 0xFF], S0[(u >> 8) & 0xFF], S1[u & 0xFF]); + key->F_R2 = MAKEuint32_t(S0[v >> 24], S1[(v >> 16) & 0xFF], S0[(v >> 8) & 0xFF], S1[v & 0xFF]); + + return W; +} + +#define MAKEU31(a, b, c) (((uint32_t)(a) << 23) | ((uint32_t)(b) << 8) | (uint32_t)(c)) + +void ZUC_set_key(ZUC_KEY *key, const unsigned char *k, const unsigned char *iv) +{ + uint32_t w, nCount; + + /* expand key */ + key->LFSR_S0 = MAKEU31(k[0], EK_d[0], iv[0]); + key->LFSR_S1 = MAKEU31(k[1], EK_d[1], iv[1]); + key->LFSR_S2 = MAKEU31(k[2], EK_d[2], iv[2]); + key->LFSR_S3 = MAKEU31(k[3], EK_d[3], iv[3]); + key->LFSR_S4 = MAKEU31(k[4], EK_d[4], iv[4]); + key->LFSR_S5 = MAKEU31(k[5], EK_d[5], iv[5]); + key->LFSR_S6 = MAKEU31(k[6], EK_d[6], iv[6]); + key->LFSR_S7 = MAKEU31(k[7], EK_d[7], iv[7]); + key->LFSR_S8 = MAKEU31(k[8], EK_d[8], iv[8]); + key->LFSR_S9 = MAKEU31(k[9], EK_d[9], iv[9]); + key->LFSR_S10 = MAKEU31(k[10], EK_d[10], iv[10]); + key->LFSR_S11 = MAKEU31(k[11], EK_d[11], iv[11]); + key->LFSR_S12 = MAKEU31(k[12], EK_d[12], iv[12]); + key->LFSR_S13 = MAKEU31(k[13], EK_d[13], iv[13]); + key->LFSR_S14 = MAKEU31(k[14], EK_d[14], iv[14]); + key->LFSR_S15 = MAKEU31(k[15], EK_d[15], iv[15]); + + /* set F_R1 and F_R2 to zero */ + key->F_R1 = 0; + key->F_R2 = 0; + nCount = 32; + while (nCount > 0) + { + BitReorganization(key); + w = F(key); + LFSRWithInitialisationMode(key, w >> 1); + nCount--; + } +} + +void ZUC_encrypt(ZUC_KEY *key, size_t inlen, const unsigned char *in, unsigned char *out) +{ +#if 0 + int i; + BitReorganization(key); + F(key); /* discard the output of F */ + LFSRWithWorkMode(key); + + for (i = 0; i < KeystreamLen; i ++) + { + BitReorganization(key); + pKeystream[i] = F(key) ^ key->BRC_X3; + LFSRWithWorkMode(key); + } +#endif +} + diff --git a/crypto/zuc/zuc.h b/crypto/zuc/zuc.h new file mode 100755 index 00000000..b0984c2c --- /dev/null +++ b/crypto/zuc/zuc.h @@ -0,0 +1,51 @@ +#ifndef HEADER_ZUC_H +#define HEADER_ZUC_H + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct { + uint32_t LFSR_S0; + uint32_t LFSR_S1; + uint32_t LFSR_S2; + uint32_t LFSR_S3; + uint32_t LFSR_S4; + uint32_t LFSR_S5; + uint32_t LFSR_S6; + uint32_t LFSR_S7; + uint32_t LFSR_S8; + uint32_t LFSR_S9; + uint32_t LFSR_S10; + uint32_t LFSR_S11; + uint32_t LFSR_S12; + uint32_t LFSR_S13; + uint32_t LFSR_S14; + uint32_t LFSR_S15; + + /* the registers of F */ + uint32_t F_R1; + uint32_t F_R2; + + /* the outputs of BitReorganization */ + uint32_t BRC_X0; + uint32_t BRC_X1; + uint32_t BRC_X2; + uint32_t BRC_X3; +} ZUC_KEY; + + +void ZUC_set_key(ZUC_KEY *key, const unsigned char *k, const unsigned char *iv); +void ZUC_encrypt(ZUC_KEY *key, size_t inlen, const unsigned char *in, unsigned char *out); + + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/demos/sm2/sm2-pkcs7.pem b/demos/sm2/sm2-pkcs7.pem new file mode 100644 index 00000000..426a4c5e --- /dev/null +++ b/demos/sm2/sm2-pkcs7.pem @@ -0,0 +1,26 @@ +-----BEGIN PKCS7----- +MIIEbgYJKoZIhvcNAQcCoIIEXzCCBFsCAQExADALBgkqhkiG9w0BBwGgggRDMIIB +szCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQGEwJD +TjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQwMzEx +NTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVOUkNB +QzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEMPCc +a6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRTV7Q9 +v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5YtiW/CX +dlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZMxvE +pgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b53W+ +CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xIpDoi +VhsLwjCCAogwggIsoAMCAQICEC2hpr0M52xiTmNLfWop0CowDAYIKoEcz1UBg3UF +ADAuMQswCQYDVQQGEwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RD +QTAeFw0xMzA5MTMwODEwMjVaFw0zMzA5MDgwODEwMjVaMDQxCzAJBgNVBAYTAkNO +MREwDwYDVQQKDAhVbmlUcnVzdDESMBAGA1UEAwwJU0hFQ0EgU00yMFkwEwYHKoZI +zj0CAQYIKoEcz1UBgi0DQgAEfdEfkS0GSlQQ8ISEVSUdvKL7tcd3bsNssWlmmOhN +5VCg1iLJgMDDqhO9TFt4EDsZuvECXz8uiU+BL4pddBcMgKOCASIwggEeMB8GA1Ud +IwQYMBaAFEwysZfZMxvEpgXBxuWLYlvwl3ZYMA8GA1UdEwEB/wQFMAMBAf8wgboG +A1UdHwSBsjCBrzBBoD+gPaQ7MDkxCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVOUkNB +QzEMMAoGA1UECwwDQVJMMQwwCgYDVQQDDANhcmwwKqAooCaGJGh0dHA6Ly93d3cu +cm9vdGNhLmdvdi5jbi9hcmwvYXJsLmNybDA+oDygOoY4bGRhcDovL2xkYXAucm9v +dGNhLmdvdi5jbjozODkvQ049YXJsLE9VPUFSTCxPPU5SQ0FDLEM9Q04wDgYDVR0P +AQH/BAQDAgEGMB0GA1UdDgQWBBSJMQSRe0Oqqpq/hB2bhu7wuHCZoDAMBggqgRzP +VQGDdQUAA0gAMEUCIQCKe/9772vmcRXjynapM3RqFchrHxh4Yiy0HiqwmUNkOQIg +JjDnX9H9G/Aopa1VnYvKX2cjukamH56XCet/Jeyh3zQxAA== +-----END PKCS7----- diff --git a/demos/sm2/sm2-x509.pem b/demos/sm2/sm2-x509.pem new file mode 100644 index 00000000..675cb5da --- /dev/null +++ b/demos/sm2/sm2-x509.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICiDCCAiygAwIBAgIQLaGmvQznbGJOY0t9ainQKjAMBggqgRzPVQGDdQUAMC4x +CzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVOUkNBQzEPMA0GA1UEAwwGUk9PVENBMB4X +DTEzMDkxMzA4MTAyNVoXDTMzMDkwODA4MTAyNVowNDELMAkGA1UEBhMCQ04xETAP +BgNVBAoMCFVuaVRydXN0MRIwEAYDVQQDDAlTSEVDQSBTTTIwWTATBgcqhkjOPQIB +BggqgRzPVQGCLQNCAAR90R+RLQZKVBDwhIRVJR28ovu1x3duw2yxaWaY6E3lUKDW +IsmAwMOqE71MW3gQOxm68QJfPy6JT4Evil10FwyAo4IBIjCCAR4wHwYDVR0jBBgw +FoAUTDKxl9kzG8SmBcHG5YtiW/CXdlgwDwYDVR0TAQH/BAUwAwEB/zCBugYDVR0f +BIGyMIGvMEGgP6A9pDswOTELMAkGA1UEBhMCQ04xDjAMBgNVBAoMBU5SQ0FDMQww +CgYDVQQLDANBUkwxDDAKBgNVBAMMA2FybDAqoCigJoYkaHR0cDovL3d3dy5yb290 +Y2EuZ292LmNuL2FybC9hcmwuY3JsMD6gPKA6hjhsZGFwOi8vbGRhcC5yb290Y2Eu +Z292LmNuOjM4OS9DTj1hcmwsT1U9QVJMLE89TlJDQUMsQz1DTjAOBgNVHQ8BAf8E +BAMCAQYwHQYDVR0OBBYEFIkxBJF7Q6qqmr+EHZuG7vC4cJmgMAwGCCqBHM9VAYN1 +BQADSAAwRQIhAIp7/3vva+ZxFePKdqkzdGoVyGsfGHhiLLQeKrCZQ2Q5AiAmMOdf +0f0b8CilrVWdi8pfZyO6RqYfnpcJ638l7KHfNA== +-----END CERTIFICATE----- diff --git a/include/openssl/zuc.h b/include/openssl/zuc.h new file mode 120000 index 00000000..f42f6253 --- /dev/null +++ b/include/openssl/zuc.h @@ -0,0 +1 @@ +../../crypto/zuc/zuc.h \ No newline at end of file diff --git a/sm2test.c b/sm2test.c new file mode 100644 index 00000000..c6324c47 --- /dev/null +++ b/sm2test.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int ok; + EC_KEY *ec_key; + ECDSA_SIG *sig; + unsigned char dgst[32]; + + ec_key = EC_KEY_new_by_curve_name(NID_sm2p256v1); + OPENSSL_assert(ec_key); + + ok = EC_KEY_generate_key(ec_key); + OPENSSL_assert(ok); + + sig = ECDSA_do_sign(dgst, 32, ec_key); + ok = ECDSA_do_verify(dgst, 32, sig, ec_key); + + printf("ok = %d\n", ok); + + return 0; +} + diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 58f6f329..bee44449 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -111,7 +111,7 @@ and [options] can be one of no-ripemd no-sm3 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher no-bf no-cast no-aes no-camellia no-seed - no-sms4 + no-sms4 no-zuc no-rsa no-dsa no-dh - Skip this public key cipher no-ssl2 no-ssl3 - Skip this version of SSL just-ssl - remove all non-ssl keys/digest @@ -295,6 +295,7 @@ $cflags.= " -DZLIB" if $zlib_opt; $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; $cflags.=" -DOPENSSL_NO_SM3" if $no_sm3; $cflags.=" -DOPENSSL_NO_SMS4" if $no_sms4; +$cflags.=" -DOPENSSL_NO_ZUC" if $no_zuc; if ($no_static_engine) { @@ -919,6 +920,7 @@ sub var_add @a=grep(!/(^sm3)|(_sm3$)/,@a) if $no_sm3; @a=grep(!/(^sms4)|(_sms4$)/,@a) if $no_sms4; + @a=grep(!/(^zuc)|(_zuc$)/,@a) if $no_zuc; grep($_="$dir/$_",@a); @a=grep(!/(^|\/)s_/,@a) if $no_sock; @@ -1248,7 +1250,8 @@ sub read_options "no-multiblock" => 0, "fips" => \$fips, "no-sm3" => \$no_sm3, - "no-sms4" => \$no_sms4 + "no-sms4" => \$no_sms4, + "no-zuc" => \$no_zuc ); if (exists $valid_options{$_}) diff --git a/util/mkdef.pl b/util/mkdef.pl index 55e8d427..c782f8c0 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -146,7 +146,7 @@ my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng; my $no_jpake; my $no_srp; my $no_ssl2; my $no_ec2m; my $no_nistp_gcc; my $no_nextprotoneg; my $no_sctp; my $no_srtp; my $no_ssl_trace; my $no_unit_test; my $no_ssl3_method; -my $no_sm3; my $no_sms4; +my $no_sm3; my $no_sms4; my $no_zuc; my $fips; @@ -251,6 +251,7 @@ foreach (@ARGV, split(/ /, $options)) elsif (/^no-unit-test$/){ $no_unit_test=1; } elsif (/^no-sm3$/) { $no_sm3=1; } elsif (/^no-sms4$/) { $no_sms4=1; } + elsif (/^no-zuc$/) { $no_zuc=1; } } @@ -361,6 +362,7 @@ $crypto.=" crypto/srp/srp.h"; $crypto.=" crypto/sm3/sm3.h" ; # unless $no_sm3; $crypto.=" crypto/sms4/sms4.h" ; # unless $no_sms4; +$crypto.=" crypto/zuc/zuc.h" ; # unless $no_zuc; my $symhacks="crypto/symhacks.h"; @@ -983,6 +985,7 @@ sub do_defs $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/); $a .= ",SM3" if($s =~ /EVP_sm3/); $a .= ",SMS4" if($s =~ /EVP_sms4/); + $a .= ",ZUC" if($s =~ /EVP_zuc/); $platform{$s} = &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p); @@ -1236,6 +1239,7 @@ sub is_valid if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; } if ($keyword eq "SM3" && $no_sm3) { return 0; } if ($keyword eq "SMS4" && $no_sms4) { return 0; } + if ($keyword eq "ZUC" && $no_zuc) { return 0; } # Nothing recognise as true return 1; diff --git a/util/mkfiles.pl b/util/mkfiles.pl index c94da577..8fa37f45 100755 --- a/util/mkfiles.pl +++ b/util/mkfiles.pl @@ -23,6 +23,7 @@ my @dirs = ( "crypto/rc4", "crypto/rc5", "crypto/sms4", +"crypto/zuc", "crypto/idea", "crypto/bf", "crypto/cast", diff --git a/util/sp-diff.pl b/util/sp-diff.pl index 5572b818..d0df2599 100755 --- a/util/sp-diff.pl +++ b/util/sp-diff.pl @@ -13,7 +13,7 @@ $line=0; foreach $a ("md2","md4","md5","sha","sha1","rc4","des cfb","des cbc","des ede3", "idea cfb","idea cbc","rc2 cfb","rc2 cbc","blowfish cbc","cast cbc", - "sm3","sms4 cfb","sms4 cbc") + "sm3","sms4 cfb","sms4 cbc","zuc") { if (defined($one{$a,8}) && defined($two{$a,8})) {