]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
merge upstream
authorMax <maxamar@mail.ru>
Thu, 8 Sep 2016 08:49:08 +0000 (11:49 +0300)
committerMax <maxamar@mail.ru>
Thu, 8 Sep 2016 08:49:08 +0000 (11:49 +0300)
15 files changed:
CMakeLists.txt
Makefile [deleted file]
e_gost_err.h
gost_ameth.c
gost_asn1.c
gost_crypt.c
gost_ec_keyx.c
gost_ec_sign.c
gost_grasshopper_cipher.c
gost_grasshopper_core.c
gost_grasshopper_math.h
gost_lcl.h
gost_md.c
gost_md2012.c
gost_pmeth.c

index a95986d875a896abf30d6ff1b3857a6abae87f41..6d51a055465add04d93d95f0a25b8622447bf7e8 100644 (file)
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.4)
+cmake_minimum_required(VERSION 2.8)
 project(ccgost)
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c98 -O3")
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 95014cb..0000000
--- a/Makefile
+++ /dev/null
@@ -1,277 +0,0 @@
-DIR=ccgost
-TOP=../..
-CC=cc
-INCLUDES= -I../../include
-CFLAG=-g
-MAKEFILE= Makefile
-AR= ar r
-CFLAGS= $(INCLUDES) $(CFLAG)
-LIB=$(TOP)/libcrypto.a
-
-LIBSRC= gost_md2012.c gosthash2012.c gost_ec_sign.c gost_ec_keyx.c gost89.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
-
-LIBOBJ= gost_md2012.o gosthash2012.o e_gost_err.o gost_ec_keyx.o gost_ec_sign.o gost89.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
-
-SRC=$(LIBSRC)
-
-LIBNAME=gost
-
-top: 
-       (cd $(TOP); $(MAKE) DIRS=engines sub_all)
-
-all: lib
-
-tags:
-       ctags $(SRC)
-
-errors:
-       $(PERL) ../../util/mkerr.pl -conf gost.ec -nostatic -write $(SRC)
-
-lib: $(LIBOBJ)
-       if [ -n "$(SHARED_LIBS)" ]; then \
-               $(MAKE) -f $(TOP)/Makefile.shared -e \
-                       LIBNAME=$(LIBNAME) \
-                       LIBEXTRAS='$(LIBOBJ)' \
-                       LIBDEPS='-L$(TOP) -lcrypto' \
-                       link_o.$(SHLIB_TARGET); \
-       else \
-               $(AR) $(LIB) $(LIBOBJ); \
-       fi
-       @touch lib
-
-install:
-       [ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
-       if [ -n "$(SHARED_LIBS)" ]; then \
-               set -e; \
-               echo installing $(LIBNAME); \
-               pfx=lib; \
-               if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
-                       sfx=".so"; \
-                       cp cyg$(LIBNAME).dll $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$${pfx}$(LIBNAME)$$sfx.new; \
-               else \
-                       case "$(CFLAGS)" in \
-                       *DSO_DLFCN*) sfx=`expr "$(SHLIB_EXT)" : '.*\(\.[a-z][a-z]*\)' \| ".so"`;; \
-                       *DSO_DL*) sfx=".sl";; \
-                       *DSO_WIN32*) sfx="eay32.dll"; pfx=;; \
-                       *) sfx=".bad";; \
-                       esac; \
-                       cp $${pfx}$(LIBNAME)$$sfx $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$${pfx}$(LIBNAME)$$sfx.new; \
-               fi; \
-               chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$${pfx}$(LIBNAME)$$sfx.new; \
-               mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$${pfx}$(LIBNAME)$$sfx.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$${pfx}$(LIBNAME)$$sfx; \
-       fi
-
-tests:
-
-links:
-
-update: local_depend
-       @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
-
-depend: local_depend
-       @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
-local_depend:
-       @[ -z "$(THIS)" ] || $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
-
-files:
-       $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
-
-lint:
-       lint -DLINT $(INCLUDES) $(SRC)>fluff
-
-dclean:
-       $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
-       mv -f Makefile.new $(MAKEFILE)
-
-clean:
-       rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff *.so *.sl *.dll *.dylib
-
-gostsum$(EXE_EXT): gostsum.o gosthash.o gost89.o
-
-gost12sum$(EXE_EXT): gost12sum.o gosthash2012.o
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-gost89.o: gost89.c gost89.h
-gost_ameth.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_ameth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_ameth.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
-gost_ameth.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
-gost_ameth.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_ameth.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_ameth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_ameth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_ameth.o: ../../include/openssl/opensslconf.h
-gost_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-gost_ameth.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
-gost_ameth.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-gost_ameth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-gost_ameth.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-gost_ameth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
-gost_ameth.o: ../../include/openssl/x509v3.h e_gost_err.h gost89.h gost_ameth.c
-gost_ameth.o: gost_lcl.h gosthash.h
-gost_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_asn1.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_asn1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_asn1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_asn1.o: ../../include/openssl/opensslconf.h
-gost_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-gost_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
-gost_asn1.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-gost_asn1.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-gost_asn1.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-gost_asn1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
-gost_asn1.o: gost89.h gost_asn1.c gost_lcl.h gosthash.h
-gost_crypt.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_crypt.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_crypt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_crypt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_crypt.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_crypt.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_crypt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_crypt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_crypt.o: ../../include/openssl/opensslconf.h
-gost_crypt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-gost_crypt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
-gost_crypt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-gost_crypt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-gost_crypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-gost_crypt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
-gost_crypt.o: e_gost_err.h gost89.h gost_crypt.c gost_lcl.h gosthash.h
-gost_ctl.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_ctl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_ctl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_ctl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_ctl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_ctl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_ctl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_ctl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_ctl.o: ../../include/openssl/opensslconf.h
-gost_ctl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-gost_ctl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
-gost_ctl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-gost_ctl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-gost_ctl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-gost_ctl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
-gost_ctl.o: gost89.h gost_ctl.c gost_lcl.h gosthash.h
-gost_ec_keyx.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_ec_keyx.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_ec_keyx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_ec_keyx.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_ec_keyx.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_ec_keyx.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_ec_keyx.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_ec_keyx.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_ec_keyx.o: ../../include/openssl/opensslconf.h
-gost_ec_keyx.o: ../../include/openssl/opensslv.h
-gost_ec_keyx.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
-gost_ec_keyx.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
-gost_ec_keyx.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-gost_ec_keyx.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-gost_ec_keyx.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
-gost_ec_keyx.o: ../../include/openssl/x509_vfy.h e_gost_err.h gost89.h
-gost_ec_keyx.o: gost_ec_keyx.c gost_keywrap.h gost_lcl.h gosthash.h
-gost_ec_sign.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_ec_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_ec_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_ec_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_ec_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_ec_sign.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
-gost_ec_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
-gost_ec_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
-gost_ec_sign.o: ../../include/openssl/objects.h
-gost_ec_sign.o: ../../include/openssl/opensslconf.h
-gost_ec_sign.o: ../../include/openssl/opensslv.h
-gost_ec_sign.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
-gost_ec_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
-gost_ec_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-gost_ec_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-gost_ec_sign.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
-gost_ec_sign.o: ../../include/openssl/x509_vfy.h e_gost_err.h gost89.h
-gost_ec_sign.o: gost_ec_sign.c gost_lcl.h gosthash.h
-gost_eng.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_eng.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_eng.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_eng.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_eng.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_eng.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_eng.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_eng.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_eng.o: ../../include/openssl/opensslconf.h
-gost_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-gost_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
-gost_eng.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-gost_eng.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-gost_eng.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-gost_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
-gost_eng.o: e_gost_err.h gost89.h gost_eng.c gost_lcl.h gosthash.h
-gost_keywrap.o: gost89.h gost_keywrap.c gost_keywrap.h
-gost_md.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_md.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_md.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_md.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_md.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_md.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_md.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_md.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_md.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-gost_md.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
-gost_md.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
-gost_md.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-gost_md.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-gost_md.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
-gost_md.o: ../../include/openssl/x509_vfy.h e_gost_err.h gost89.h gost_lcl.h
-gost_md.o: gost_md.c gosthash.h
-gost_md2012.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-gost_md2012.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
-gost_md2012.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
-gost_md2012.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_md2012.o: ../../include/openssl/opensslconf.h
-gost_md2012.o: ../../include/openssl/opensslv.h
-gost_md2012.o: ../../include/openssl/ossl_typ.h
-gost_md2012.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-gost_md2012.o: ../../include/openssl/symhacks.h gost_md2012.c gosthash2012.h
-gost_md2012.o: gosthash2012_const.h gosthash2012_precalc.h gosthash2012_sse2.h
-gost_params.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_params.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_params.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-gost_params.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
-gost_params.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-gost_params.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-gost_params.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
-gost_params.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-gost_params.o: ../../include/openssl/opensslconf.h
-gost_params.o: ../../include/openssl/opensslv.h
-gost_params.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
-gost_params.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
-gost_params.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-gost_params.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-gost_params.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
-gost_params.o: ../../include/openssl/x509_vfy.h gost89.h gost_lcl.h
-gost_params.o: gost_params.c gosthash.h
-gost_pmeth.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
-gost_pmeth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
-gost_pmeth.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
-gost_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
-gost_pmeth.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
-gost_pmeth.o: ../../include/openssl/ec.h ../../include/openssl/engine.h
-gost_pmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
-gost_pmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
-gost_pmeth.o: ../../include/openssl/objects.h
-gost_pmeth.o: ../../include/openssl/opensslconf.h
-gost_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-gost_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
-gost_pmeth.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-gost_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-gost_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-gost_pmeth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
-gost_pmeth.o: ../../include/openssl/x509v3.h e_gost_err.h gost89.h gost_lcl.h
-gost_pmeth.o: gost_pmeth.c gosthash.h
-gosthash.o: gost89.h gosthash.c gosthash.h
-gosthash2012.o: gosthash2012.c gosthash2012.h gosthash2012_const.h
-gosthash2012.o: gosthash2012_precalc.h gosthash2012_sse2.h
index e8a5f2877ba63740014a0ae5f8f09037ad3adeae..d0f7d8943a07c6e86760b5b585e896384e716b28 100644 (file)
@@ -64,9 +64,9 @@ extern "C" {
  * The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
  */
-void ERR_load_GOST_strings(void);
-void ERR_unload_GOST_strings(void);
-void ERR_GOST_error(int function, int reason, char *file, int line);
+    void ERR_load_GOST_strings(void);
+    void ERR_unload_GOST_strings(void);
+    void ERR_GOST_error(int function, int reason, char *file, int line);
 # define GOSTerr(f,r) ERR_GOST_error((f),(r),__FILE__,__LINE__)
 
 /* Error codes for the GOST functions. */
@@ -139,7 +139,7 @@ void ERR_GOST_error(int function, int reason, char *file, int line);
 # define GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND            126
 # define GOST_R_UNSUPPORTED_PARAMETER_SET                 127
 
-#ifdef  __cplusplus
+# ifdef  __cplusplus
 }
-#endif
+# endif
 #endif
index 3d1382e8d517f6721ee019820d8346f8acc289de..27217a827c533ac048fac63355efc5f215cb9078 100644 (file)
@@ -255,7 +255,7 @@ static int pkey_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
                 return -1;
             }
             PKCS7_RECIP_INFO_get0_alg((PKCS7_RECIP_INFO *)arg2, &alg1);
-            X509_ALGOR_set0(alg1, OBJ_nid2obj(pkey->type),
+            X509_ALGOR_set0(alg1, OBJ_nid2obj(EVP_PKEY_id(pkey)),
                             V_ASN1_SEQUENCE, params);
         }
         return 1;
@@ -268,8 +268,8 @@ static int pkey_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
             }
             CMS_RecipientInfo_ktri_get0_algs((CMS_RecipientInfo *)arg2, NULL,
                                              NULL, &alg1);
-            X509_ALGOR_set0(alg1, OBJ_nid2obj(pkey->type), V_ASN1_SEQUENCE,
-                            params);
+            X509_ALGOR_set0(alg1, OBJ_nid2obj(EVP_PKEY_id(pkey)),
+                            V_ASN1_SEQUENCE, params);
         }
         return 1;
 #endif
@@ -284,7 +284,7 @@ static int pkey_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
 /* --------------------- free functions * ------------------------------*/
 static void pkey_free_gost_ec(EVP_PKEY *key)
 {
-    EC_KEY_free(key->pkey.ec);
+    EC_KEY_free(EVP_PKEY_get0_EC_KEY(key));
 }
 
 /* ------------------ private key functions  -----------------------------*/
@@ -706,7 +706,7 @@ static int pub_encode_gost_ec(X509_PUBKEY *pub, const EVP_PKEY *pk)
     int ptype = V_ASN1_UNDEF;
 
     algobj = OBJ_nid2obj(EVP_PKEY_base_id(pk));
-    if (pk->save_parameters) {
+    if (EVP_PKEY_save_parameters((EVP_PKEY *)pk, -1)) {
         ASN1_STRING *params = encode_gost_algor_params(pk);
         pval = params;
         ptype = V_ASN1_SEQUENCE;
@@ -806,7 +806,7 @@ static int pkey_size_gost(const EVP_PKEY *pk)
 /* ---------------------- ASN1 METHOD for GOST MAC  -------------------*/
 static void mackey_free_gost(EVP_PKEY *pk)
 {
-    OPENSSL_free(pk->pkey.ptr);
+    OPENSSL_free(EVP_PKEY_get0(pk));
 }
 
 static int mac_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
index fb9792a7fbe5c9aad1eb028843b8269ae5c4eefb..3a106c2fc675409e7d5939a34ca30d956e4b2a24 100644 (file)
@@ -26,29 +26,29 @@ ASN1_NDEF_SEQUENCE_END(GOST_KEY_TRANSPORT)
     ASN1_SIMPLE(GOST_KEY_INFO, encrypted_key, ASN1_OCTET_STRING),
         ASN1_SIMPLE(GOST_KEY_INFO, imit, ASN1_OCTET_STRING)
 } ASN1_NDEF_SEQUENCE_END(GOST_KEY_INFO)
- IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_INFO)
- ASN1_NDEF_SEQUENCE(GOST_KEY_AGREEMENT_INFO) =
+IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_INFO)
+ASN1_NDEF_SEQUENCE(GOST_KEY_AGREEMENT_INFO) =
 {
     ASN1_SIMPLE(GOST_KEY_AGREEMENT_INFO, cipher, ASN1_OBJECT),
         ASN1_IMP_OPT(GOST_KEY_AGREEMENT_INFO, ephem_key, X509_PUBKEY, 0),
         ASN1_SIMPLE(GOST_KEY_AGREEMENT_INFO, eph_iv, ASN1_OCTET_STRING)
 } ASN1_NDEF_SEQUENCE_END(GOST_KEY_AGREEMENT_INFO)
- IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_AGREEMENT_INFO)
- ASN1_NDEF_SEQUENCE(GOST_KEY_PARAMS) =
+IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_AGREEMENT_INFO)
+ASN1_NDEF_SEQUENCE(GOST_KEY_PARAMS) =
 {
 ASN1_SIMPLE(GOST_KEY_PARAMS, key_params, ASN1_OBJECT),
         ASN1_SIMPLE(GOST_KEY_PARAMS, hash_params, ASN1_OBJECT),
         ASN1_OPT(GOST_KEY_PARAMS, cipher_params,
                      ASN1_OBJECT),} ASN1_NDEF_SEQUENCE_END(GOST_KEY_PARAMS)
- IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_PARAMS)
- ASN1_NDEF_SEQUENCE(GOST_CIPHER_PARAMS) =
+IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_PARAMS)
+ASN1_NDEF_SEQUENCE(GOST_CIPHER_PARAMS) =
 {
 ASN1_SIMPLE(GOST_CIPHER_PARAMS, iv, ASN1_OCTET_STRING),
         ASN1_SIMPLE(GOST_CIPHER_PARAMS, enc_param_set,
                         ASN1_OBJECT),}
 ASN1_NDEF_SEQUENCE_END(GOST_CIPHER_PARAMS)
- IMPLEMENT_ASN1_FUNCTIONS(GOST_CIPHER_PARAMS)
- ASN1_NDEF_SEQUENCE(GOST_CLIENT_KEY_EXCHANGE_PARAMS) =
+IMPLEMENT_ASN1_FUNCTIONS(GOST_CIPHER_PARAMS)
+ASN1_NDEF_SEQUENCE(GOST_CLIENT_KEY_EXCHANGE_PARAMS) =
 {                               /* FIXME incomplete */
     ASN1_SIMPLE(GOST_CLIENT_KEY_EXCHANGE_PARAMS, gkt, GOST_KEY_TRANSPORT)
 } ASN1_NDEF_SEQUENCE_END(GOST_CLIENT_KEY_EXCHANGE_PARAMS)
@@ -60,4 +60,4 @@ ASN1_NDEF_SEQUENCE_END(GOST_CIPHER_PARAMS)
     ASN1_SIMPLE(MASKED_GOST_KEY, masked_priv_key, ASN1_OCTET_STRING),
         ASN1_SIMPLE(MASKED_GOST_KEY, public_key, ASN1_OCTET_STRING)
 } ASN1_NDEF_SEQUENCE_END(MASKED_GOST_KEY)
- IMPLEMENT_ASN1_FUNCTIONS(MASKED_GOST_KEY)
+IMPLEMENT_ASN1_FUNCTIONS(MASKED_GOST_KEY)
index 4358265b7016e25e4a8b0ac1e52c6d43cee687a0..d375a3dc89dd1b237900acf719f1fd371b72afd7 100644 (file)
@@ -51,9 +51,8 @@ const EVP_CIPHER *cipher_gost(void)
 {
     if (_hidden_Gost28147_89_cipher == NULL
         && ((_hidden_Gost28147_89_cipher =
-             EVP_CIPHER_meth_new(NID_id_Gost28147_89,
-                                 1  /* block_size */,
-                                 32 /* key_size */)) == NULL
+             EVP_CIPHER_meth_new(NID_id_Gost28147_89, 1 /* block_size */ ,
+                                 32 /* key_size */ )) == NULL
             || !EVP_CIPHER_meth_set_iv_length(_hidden_Gost28147_89_cipher, 8)
             || !EVP_CIPHER_meth_set_flags(_hidden_Gost28147_89_cipher,
                                           EVP_CIPH_CFB_MODE |
@@ -68,11 +67,14 @@ const EVP_CIPHER *cipher_gost(void)
             || !EVP_CIPHER_meth_set_cleanup(_hidden_Gost28147_89_cipher,
                                             gost_cipher_cleanup)
             || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_Gost28147_89_cipher,
-                                                  sizeof(struct ossl_gost_cipher_ctx))
-            || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_Gost28147_89_cipher,
-                                                    gost89_set_asn1_parameters)
-            || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_Gost28147_89_cipher,
-                                                    gost89_get_asn1_parameters)
+                                                  sizeof(struct
+                                                         ossl_gost_cipher_ctx))
+            ||
+            !EVP_CIPHER_meth_set_set_asn1_params(_hidden_Gost28147_89_cipher,
+                                                 gost89_set_asn1_parameters)
+            ||
+            !EVP_CIPHER_meth_set_get_asn1_params(_hidden_Gost28147_89_cipher,
+                                                 gost89_get_asn1_parameters)
             || !EVP_CIPHER_meth_set_ctrl(_hidden_Gost28147_89_cipher,
                                          gost_cipher_ctl))) {
         EVP_CIPHER_meth_free(_hidden_Gost28147_89_cipher);
@@ -80,21 +82,20 @@ const EVP_CIPHER *cipher_gost(void)
     }
     return _hidden_Gost28147_89_cipher;
 }
+
 static EVP_CIPHER *_hidden_Gost28147_89_cbc = NULL;
 const EVP_CIPHER *cipher_gost_cbc(void)
 {
     if (_hidden_Gost28147_89_cbc == NULL
         && ((_hidden_Gost28147_89_cbc =
-             EVP_CIPHER_meth_new(NID_gost89_cbc,
-                                 8  /* block_size */,
-                                 32 /* key_size */)) == NULL
+             EVP_CIPHER_meth_new(NID_gost89_cbc, 8 /* block_size */ ,
+                                 32 /* key_size */ )) == NULL
             || !EVP_CIPHER_meth_set_iv_length(_hidden_Gost28147_89_cbc, 8)
             || !EVP_CIPHER_meth_set_flags(_hidden_Gost28147_89_cbc,
-                                       EVP_CIPH_CBC_MODE |
-                                       EVP_CIPH_CUSTOM_IV | 
-                                       EVP_CIPH_RAND_KEY | 
-                                       EVP_CIPH_ALWAYS_CALL_INIT)
+                                          EVP_CIPH_CBC_MODE |
+                                          EVP_CIPH_CUSTOM_IV |
+                                          EVP_CIPH_RAND_KEY |
+                                          EVP_CIPH_ALWAYS_CALL_INIT)
             || !EVP_CIPHER_meth_set_init(_hidden_Gost28147_89_cbc,
                                          gost_cipher_init_cbc)
             || !EVP_CIPHER_meth_set_do_cipher(_hidden_Gost28147_89_cbc,
@@ -102,7 +103,8 @@ const EVP_CIPHER *cipher_gost_cbc(void)
             || !EVP_CIPHER_meth_set_cleanup(_hidden_Gost28147_89_cbc,
                                             gost_cipher_cleanup)
             || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_Gost28147_89_cbc,
-                                                  sizeof(struct ossl_gost_cipher_ctx))
+                                                  sizeof(struct
+                                                         ossl_gost_cipher_ctx))
             || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_Gost28147_89_cbc,
                                                     gost89_set_asn1_parameters)
             || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_Gost28147_89_cbc,
@@ -114,14 +116,14 @@ const EVP_CIPHER *cipher_gost_cbc(void)
     }
     return _hidden_Gost28147_89_cbc;
 }
+
 static EVP_CIPHER *_hidden_gost89_cnt = NULL;
 const EVP_CIPHER *cipher_gost_cpacnt(void)
 {
     if (_hidden_gost89_cnt == NULL
         && ((_hidden_gost89_cnt =
-             EVP_CIPHER_meth_new(NID_gost89_cnt,
-                                 1  /* block_size */,
-                                 32 /* key_size */)) == NULL
+             EVP_CIPHER_meth_new(NID_gost89_cnt, 1 /* block_size */ ,
+                                 32 /* key_size */ )) == NULL
             || !EVP_CIPHER_meth_set_iv_length(_hidden_gost89_cnt, 8)
             || !EVP_CIPHER_meth_set_flags(_hidden_gost89_cnt,
                                           EVP_CIPH_OFB_MODE |
@@ -136,7 +138,8 @@ const EVP_CIPHER *cipher_gost_cpacnt(void)
             || !EVP_CIPHER_meth_set_cleanup(_hidden_gost89_cnt,
                                             gost_cipher_cleanup)
             || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_gost89_cnt,
-                                                  sizeof(struct ossl_gost_cipher_ctx))
+                                                  sizeof(struct
+                                                         ossl_gost_cipher_ctx))
             || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_gost89_cnt,
                                                     gost89_set_asn1_parameters)
             || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_gost89_cnt,
@@ -154,9 +157,8 @@ const EVP_CIPHER *cipher_gost_cpcnt_12(void)
 {
     if (_hidden_gost89_cnt_12 == NULL
         && ((_hidden_gost89_cnt_12 =
-             EVP_CIPHER_meth_new(NID_gost89_cnt_12,
-                                 1  /* block_size */,
-                                 32 /* key_size */)) == NULL
+             EVP_CIPHER_meth_new(NID_gost89_cnt_12, 1 /* block_size */ ,
+                                 32 /* key_size */ )) == NULL
             || !EVP_CIPHER_meth_set_iv_length(_hidden_gost89_cnt_12, 8)
             || !EVP_CIPHER_meth_set_flags(_hidden_gost89_cnt_12,
                                           EVP_CIPH_OFB_MODE |
@@ -171,7 +173,8 @@ const EVP_CIPHER *cipher_gost_cpcnt_12(void)
             || !EVP_CIPHER_meth_set_cleanup(_hidden_gost89_cnt_12,
                                             gost_cipher_cleanup)
             || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_gost89_cnt_12,
-                                                  sizeof(struct ossl_gost_cipher_ctx))
+                                                  sizeof(struct
+                                                         ossl_gost_cipher_ctx))
             || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_gost89_cnt_12,
                                                     gost89_set_asn1_parameters)
             || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_gost89_cnt_12,
@@ -196,7 +199,6 @@ void cipher_gost_destroy(void)
     _hidden_gost89_cnt_12 = NULL;
 }
 
-
 /* Implementation of GOST 28147-89 in MAC (imitovstavka) mode */
 /* Init functions which set specific parameters */
 static int gost_imit_init_cpa(EVP_MD_CTX *ctx);
@@ -223,7 +225,8 @@ EVP_MD *imit_gost_cpa(void)
             || !EVP_MD_meth_set_result_size(md, 4)
             || !EVP_MD_meth_set_input_blocksize(md, 8)
             || !EVP_MD_meth_set_app_datasize(md,
-                                             sizeof(struct ossl_gost_imit_ctx))
+                                             sizeof(struct
+                                                    ossl_gost_imit_ctx))
             || !EVP_MD_meth_set_flags(md, 0)
             || !EVP_MD_meth_set_init(md, gost_imit_init_cpa)
             || !EVP_MD_meth_set_update(md, gost_imit_update)
@@ -254,7 +257,8 @@ EVP_MD *imit_gost_cp_12(void)
             || !EVP_MD_meth_set_result_size(md, 4)
             || !EVP_MD_meth_set_input_blocksize(md, 8)
             || !EVP_MD_meth_set_app_datasize(md,
-                                             sizeof(struct ossl_gost_imit_ctx))
+                                             sizeof(struct
+                                                    ossl_gost_imit_ctx))
             || !EVP_MD_meth_set_flags(md, 0)
             || !EVP_MD_meth_set_init(md, gost_imit_init_cp_12)
             || !EVP_MD_meth_set_update(md, gost_imit_update)
@@ -364,11 +368,11 @@ static int gost_cipher_init_param(EVP_CIPHER_CTX *ctx,
                                   const unsigned char *iv, int enc,
                                   int paramNID, int mode)
 {
-    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     if (EVP_CIPHER_CTX_get_app_data(ctx) == NULL) {
         if (!gost_cipher_set_param(c, paramNID))
             return 0;
-        EVP_CIPHER_CTX_set_app_data(ctx, EVP_CIPHER_CTX_cipher_data(ctx));
+        EVP_CIPHER_CTX_set_app_data(ctx, EVP_CIPHER_CTX_get_cipher_data(ctx));
     }
     if (key)
         gost_key(&(c->cctx), key);
@@ -377,8 +381,7 @@ static int gost_cipher_init_param(EVP_CIPHER_CTX *ctx,
                EVP_CIPHER_CTX_iv_length(ctx));
     }
     memcpy(EVP_CIPHER_CTX_iv_noconst(ctx),
-           EVP_CIPHER_CTX_original_iv(ctx),
-           EVP_CIPHER_CTX_iv_length(ctx));
+           EVP_CIPHER_CTX_original_iv(ctx), EVP_CIPHER_CTX_iv_length(ctx));
     return 1;
 }
 
@@ -387,7 +390,7 @@ static int gost_cipher_init_cnt(EVP_CIPHER_CTX *ctx,
                                 const unsigned char *iv,
                                 gost_subst_block * block)
 {
-    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     gost_init(&(c->cctx), block);
     c->key_meshing = 1;
     c->count = 0;
@@ -398,8 +401,7 @@ static int gost_cipher_init_cnt(EVP_CIPHER_CTX *ctx,
                EVP_CIPHER_CTX_iv_length(ctx));
     }
     memcpy(EVP_CIPHER_CTX_iv_noconst(ctx),
-           EVP_CIPHER_CTX_original_iv(ctx),
-           EVP_CIPHER_CTX_iv_length(ctx));
+           EVP_CIPHER_CTX_original_iv(ctx), EVP_CIPHER_CTX_iv_length(ctx));
     return 1;
 }
 
@@ -489,12 +491,12 @@ int gost_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
     const unsigned char *in_ptr = in;
     unsigned char *out_ptr = out;
     int i;
-    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx);
     OPENSSL_assert(inl % 8 == 0);
     if (EVP_CIPHER_CTX_encrypting(ctx)) {
         while (inl > 0) {
-            
+
             for (i = 0; i < 8; i++) {
                 b[i] = iv[i] ^ in_ptr[i];
             }
@@ -528,7 +530,7 @@ int gost_cipher_do_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out,
     size_t i = 0;
     size_t j = 0;
     unsigned char *buf = EVP_CIPHER_CTX_buf_noconst(ctx);
-    unsigned char *iv  = EVP_CIPHER_CTX_iv_noconst(ctx);
+    unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx);
 /* process partial block if any */
     if (EVP_CIPHER_CTX_num(ctx)) {
         for (j = EVP_CIPHER_CTX_num(ctx), i = 0; j < 8 && i < inl;
@@ -552,7 +554,7 @@ int gost_cipher_do_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out,
         /*
          * block cipher current iv
          */
-        gost_crypt_mesh(EVP_CIPHER_CTX_cipher_data(ctx), iv, buf);
+        gost_crypt_mesh(EVP_CIPHER_CTX_get_cipher_data(ctx), iv, buf);
         /*
          * xor next block of input text with it and output it
          */
@@ -571,7 +573,7 @@ int gost_cipher_do_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out,
     }
 /* Process rest of buffer */
     if (i < inl) {
-        gost_crypt_mesh(EVP_CIPHER_CTX_cipher_data(ctx), iv, buf);
+        gost_crypt_mesh(EVP_CIPHER_CTX_get_cipher_data(ctx), iv, buf);
         if (!EVP_CIPHER_CTX_encrypting(ctx))
             memcpy(buf + 8, in_ptr, inl - i);
         for (j = 0; i < inl; j++, i++) {
@@ -594,7 +596,7 @@ static int gost_cipher_do_cnt(EVP_CIPHER_CTX *ctx, unsigned char *out,
     size_t i = 0;
     size_t j;
     unsigned char *buf = EVP_CIPHER_CTX_buf_noconst(ctx);
-    unsigned char *iv  = EVP_CIPHER_CTX_iv_noconst(ctx);
+    unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx);
 /* process partial block if any */
     if (EVP_CIPHER_CTX_num(ctx)) {
         for (j = EVP_CIPHER_CTX_num(ctx), i = 0; j < 8 && i < inl;
@@ -614,7 +616,7 @@ static int gost_cipher_do_cnt(EVP_CIPHER_CTX *ctx, unsigned char *out,
          * block cipher current iv
          */
         /* Encrypt */
-        gost_cnt_next(EVP_CIPHER_CTX_cipher_data(ctx), iv, buf);
+        gost_cnt_next(EVP_CIPHER_CTX_get_cipher_data(ctx), iv, buf);
         /*
          * xor next block of input text with it and output it
          */
@@ -627,7 +629,7 @@ static int gost_cipher_do_cnt(EVP_CIPHER_CTX *ctx, unsigned char *out,
     }
 /* Process rest of buffer */
     if (i < inl) {
-        gost_cnt_next(EVP_CIPHER_CTX_cipher_data(ctx), iv, buf);
+        gost_cnt_next(EVP_CIPHER_CTX_get_cipher_data(ctx), iv, buf);
         for (j = 0; i < inl; j++, i++) {
             out_ptr[j] = buf[j] ^ in_ptr[j];
         }
@@ -641,7 +643,9 @@ static int gost_cipher_do_cnt(EVP_CIPHER_CTX *ctx, unsigned char *out,
 /* Cleaning up of EVP_CIPHER_CTX */
 int gost_cipher_cleanup(EVP_CIPHER_CTX *ctx)
 {
-    gost_destroy(&((struct ossl_gost_cipher_ctx *)EVP_CIPHER_CTX_cipher_data(ctx))->cctx);
+    gost_destroy(&
+                 ((struct ossl_gost_cipher_ctx *)
+                  EVP_CIPHER_CTX_get_cipher_data(ctx))->cctx);
     EVP_CIPHER_CTX_set_app_data(ctx, NULL);
     return 1;
 }
@@ -653,7 +657,8 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
 #if 0
     case EVP_CTRL_INIT:
         {
-            struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+            struct ossl_gost_cipher_ctx *c =
+                EVP_CIPHER_CTX_get_cipher_data(ctx);
             if (c == NULL) {
                 return -1;
             }
@@ -662,7 +667,8 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
 #endif
     case EVP_CTRL_RAND_KEY:
         {
-            if (RAND_bytes((unsigned char *)ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) {
+            if (RAND_bytes
+                ((unsigned char *)ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) {
                 GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_RNG_ERROR);
                 return -1;
             }
@@ -689,7 +695,8 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
 
     case EVP_CTRL_SET_SBOX:
         if (ptr) {
-            struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+            struct ossl_gost_cipher_ctx *c =
+                EVP_CIPHER_CTX_get_cipher_data(ctx);
             int nid;
             int cur_meshing;
             int ret;
@@ -712,11 +719,12 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
             c->key_meshing = cur_meshing;
             return ret;
         } else {
-          return 0;
+            return 0;
         }
     case EVP_CTRL_KEY_MESH:
         {
-            struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+            struct ossl_gost_cipher_ctx *c =
+                EVP_CIPHER_CTX_get_cipher_data(ctx);
 
             if (c == NULL) {
                 return -1;
@@ -743,14 +751,15 @@ int gost89_set_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
     int len = 0;
     unsigned char *buf = NULL;
     unsigned char *p = NULL;
-    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     GOST_CIPHER_PARAMS *gcp = GOST_CIPHER_PARAMS_new();
     ASN1_OCTET_STRING *os = NULL;
     if (!gcp) {
         GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE);
         return 0;
     }
-    if (!ASN1_OCTET_STRING_set(gcp->iv, EVP_CIPHER_CTX_iv(ctx), EVP_CIPHER_CTX_iv_length(ctx))) {
+    if (!ASN1_OCTET_STRING_set
+        (gcp->iv, EVP_CIPHER_CTX_iv(ctx), EVP_CIPHER_CTX_iv_length(ctx))) {
         GOST_CIPHER_PARAMS_free(gcp);
         GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE);
         return 0;
@@ -788,7 +797,7 @@ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
     int len;
     GOST_CIPHER_PARAMS *gcp = NULL;
     unsigned char *p;
-    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_cipher_data(ctx);
+    struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     int nid;
 
     if (ASN1_TYPE_get(params) != V_ASN1_SEQUENCE) {
@@ -819,9 +828,9 @@ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
         GOST_CIPHER_PARAMS_free(gcp);
         return -1;
     }
-    /*XXX missing non-const accessor*/
+    /*XXX missing non-const accessor */
     memcpy((unsigned char *)EVP_CIPHER_CTX_original_iv(ctx), gcp->iv->data,
-        EVP_CIPHER_CTX_iv_length(ctx));
+           EVP_CIPHER_CTX_iv_length(ctx));
 
     GOST_CIPHER_PARAMS_free(gcp);
 
@@ -931,9 +940,10 @@ int gost_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr)
         return 1;
     case EVP_MD_CTRL_SET_KEY:
         {
-            struct ossl_gost_imit_ctx *gost_imit_ctx = EVP_MD_CTX_md_data(ctx);
+            struct ossl_gost_imit_ctx *gost_imit_ctx =
+                EVP_MD_CTX_md_data(ctx);
 
-            if (EVP_MD_meth_get_init(EVP_MD_CTX_md(ctx))(ctx) <= 0) {
+            if (EVP_MD_meth_get_init(EVP_MD_CTX_md(ctx)) (ctx) <= 0) {
                 GOSTerr(GOST_F_GOST_IMIT_CTRL, GOST_R_MAC_KEY_NOT_SET);
                 return 0;
             }
index 457b30880913d0611848c2d23e0e765e46cb88a8..8c2af2affef629a0ae5677bd8a505b5a61bd52cd 100644 (file)
@@ -79,8 +79,8 @@ static int VKO_compute_key(unsigned char *shared_key, size_t shared_key_size,
     }
     mdctx = EVP_MD_CTX_new();
     if (!mdctx) {
-      GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
-      goto err;
+        GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
+        goto err;
     }
     EVP_MD_CTX_init(mdctx);
     EVP_DigestInit_ex(mdctx, md, NULL);
index c3e1e016e84bc85ca38b243cea034507fb0fc958..2c04ed756e2600b86fa197dbc97b5afe21e8d207 100644 (file)
@@ -160,6 +160,9 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
     const BIGNUM *priv_key;
     BIGNUM *r = NULL, *s = NULL, *X = NULL, *tmp = NULL, *tmp2 = NULL,
         *k = NULL, *e = NULL;
+
+    BIGNUM *new_r = NULL, *new_s = NULL;
+
     EC_POINT *C = NULL;
     BN_CTX *ctx;
 
@@ -273,9 +276,10 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
     }
     while (BN_is_zero(s));
 
-    newsig->s = BN_dup(s);
-    newsig->r = BN_dup(r);
-    if (!newsig->s || !newsig->r) {
+    DSA_SIG_get0(&new_r, &new_s, newsig);
+    new_s = BN_dup(s);
+    new_r = BN_dup(r);
+    if (!new_s || !new_r) {
         GOSTerr(GOST_F_GOST_EC_SIGN, ERR_R_MALLOC_FAILURE);
         goto err;
     }
@@ -306,6 +310,7 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len,
     BIGNUM *order;
     BIGNUM *md = NULL, *e = NULL, *R = NULL, *v = NULL,
         *z1 = NULL, *z2 = NULL;
+    BIGNUM *sig_s = NULL, *sig_r = NULL;
     BIGNUM *X = NULL, *tmp = NULL;
     EC_POINT *C = NULL;
     const EC_POINT *pub_key = NULL;
@@ -338,8 +343,10 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len,
         goto err;
     }
 
-    if (BN_is_zero(sig->s) || BN_is_zero(sig->r) ||
-        (BN_cmp(sig->s, order) >= 1) || (BN_cmp(sig->r, order) >= 1)) {
+    DSA_SIG_get0(&sig_r, &sig_s, sig);
+
+    if (BN_is_zero(sig_s) || BN_is_zero(sig_r) ||
+        (BN_cmp(sig_s, order) >= 1) || (BN_cmp(sig_r, order) >= 1)) {
         GOSTerr(GOST_F_GOST_EC_VERIFY, GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q);
         goto err;
 
@@ -362,8 +369,8 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len,
         goto err;
     }
     v = BN_mod_inverse(v, e, order, ctx);
-    if (!v || !BN_mod_mul(z1, sig->s, v, order, ctx)
-        || !BN_sub(tmp, order, sig->r)
+    if (!v || !BN_mod_mul(z1, sig_s, v, order, ctx)
+        || !BN_sub(tmp, order, sig_r)
         || !BN_mod_mul(z2, tmp, v, order, ctx)) {
         GOSTerr(GOST_F_GOST_EC_VERIFY, ERR_R_INTERNAL_ERROR);
         goto err;
@@ -400,7 +407,7 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len,
     BN_print_fp(stderr, R);
     fprintf(stderr, "\n");
 #endif
-    if (BN_cmp(R, sig->r) != 0) {
+    if (BN_cmp(R, sig_r) != 0) {
         GOSTerr(GOST_F_GOST_EC_VERIFY, GOST_R_SIGNATURE_MISMATCH);
     } else {
         ok = 1;
index f6c4428c30d3387eefaa45b5dc83edebd87709b5..b3aa4b9aa9009184dae6b9cc20b30f9ba9b4deba 100644 (file)
@@ -104,7 +104,8 @@ static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[5] = {
 
 /* Set 256 bit  key into context */
 static GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k) {
-    for (int i = 0; i < 2; i++) {
+               int i;
+    for (i = 0; i < 2; i++) {
         grasshopper_copy128(&c->key.k.k[i], (const grasshopper_w128_t*) (k + i * 16));
     }
     grasshopper_set_encrypt_key(&c->encrypt_round_keys, &c->key);
@@ -113,13 +114,14 @@ static GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_ciph
 
 /* Cleans up key from context */
 static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c) {
-    for (int i = 0; i < 2; i++) {
+               int i;
+    for (i = 0; i < 2; i++) {
         grasshopper_zero128(&c->key.k.k[i]);
     }
-    for (int i = 0; i < GRASSHOPPER_ROUND_KEYS_COUNT; i++) {
+    for (i = 0; i < GRASSHOPPER_ROUND_KEYS_COUNT; i++) {
         grasshopper_zero128(&c->encrypt_round_keys.k[i]);
     }
-    for (int i = 0; i < GRASSHOPPER_ROUND_KEYS_COUNT; i++) {
+    for (i = 0; i < GRASSHOPPER_ROUND_KEYS_COUNT; i++) {
         grasshopper_zero128(&c->decrypt_round_keys.k[i]);
     }
     grasshopper_zero128(&c->buffer);
@@ -142,10 +144,10 @@ static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ctr(gost_grasshop
 
 static int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key,
                                         const unsigned char* iv, int enc) {
-    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
 
     if (EVP_CIPHER_CTX_get_app_data(ctx) == NULL) {
-        EVP_CIPHER_CTX_set_app_data(ctx, EVP_CIPHER_CTX_cipher_data(ctx));
+        EVP_CIPHER_CTX_set_app_data(ctx, EVP_CIPHER_CTX_get_cipher_data(ctx));
     }
 
     if (key != NULL) {
@@ -169,7 +171,7 @@ static int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char
 static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key,
                                                                const unsigned char* iv,
                                                                int enc) {
-    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     c->type = GRASSHOPPER_CIPHER_ECB;
     return gost_grasshopper_cipher_init(ctx, key, iv, enc);
 }
@@ -177,7 +179,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* c
 static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key,
                                                                const unsigned char* iv,
                                                                int enc) {
-    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     c->type = GRASSHOPPER_CIPHER_CBC;
     return gost_grasshopper_cipher_init(ctx, key, iv, enc);
 }
@@ -185,7 +187,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* c
 static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key,
                                                                const unsigned char* iv,
                                                                int enc) {
-    gost_grasshopper_cipher_ctx_ofb* c = EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx_ofb* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
 
     c->c.type = GRASSHOPPER_CIPHER_OFB;
 
@@ -197,7 +199,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* c
 static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key,
                                                                const unsigned char* iv,
                                                                int enc) {
-    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
     c->type = GRASSHOPPER_CIPHER_CFB;
     return gost_grasshopper_cipher_init(ctx, key, iv, enc);
 }
@@ -205,7 +207,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* c
 static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key,
                                                                const unsigned char* iv,
                                                                int enc) {
-    gost_grasshopper_cipher_ctx_ctr* c = EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx_ctr* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
 
     c->c.type = GRASSHOPPER_CIPHER_CTR;
 
@@ -219,7 +221,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* c
 
 static GRASSHOPPER_INLINE int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                                          const unsigned char* in, size_t inl) {
-    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     struct GRASSHOPPER_CIPHER_PARAMS* params = &gost_cipher_params[c->type];
 
     return params->do_cipher(ctx, out, in, inl);
@@ -227,7 +229,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, un
 
 static int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                           const unsigned char* in, size_t inl) {
-    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     bool encrypting = (bool) EVP_CIPHER_CTX_encrypting(ctx);
     const unsigned char* current_in = in;
     unsigned char* current_out = out;
@@ -251,7 +253,7 @@ static int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* ou
 
 static int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                           const unsigned char* in, size_t inl) {
-    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx);
     bool encrypting = (bool) EVP_CIPHER_CTX_encrypting(ctx);
     const unsigned char* current_in = in;
@@ -283,7 +285,7 @@ static int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* ou
 
 static int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                           const unsigned char* in, size_t inl) {
-    gost_grasshopper_cipher_ctx_ctr* c = (gost_grasshopper_cipher_ctx_ctr*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx_ctr* c = (gost_grasshopper_cipher_ctx_ctr*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx);
     const unsigned char* current_in = in;
     unsigned char* current_out = out;
@@ -372,7 +374,7 @@ static void gost_grasshopper_cnt_next(gost_grasshopper_cipher_ctx_ofb* ctx, gras
 
 static int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                           const unsigned char* in, size_t inl) {
-    gost_grasshopper_cipher_ctx_ofb* c = (gost_grasshopper_cipher_ctx_ofb*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx_ofb* c = (gost_grasshopper_cipher_ctx_ofb*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     const unsigned char* in_ptr = in;
     unsigned char* out_ptr = out;
     unsigned char* buf = EVP_CIPHER_CTX_buf_noconst(ctx);
@@ -430,7 +432,7 @@ static int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* ou
 
 static int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                           const unsigned char* in, size_t inl) {
-    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     const unsigned char* in_ptr = in;
     unsigned char* out_ptr = out;
     unsigned char* buf = EVP_CIPHER_CTX_buf_noconst(ctx);
@@ -508,7 +510,7 @@ static int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* ou
 }
 
 static int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx) {
-    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_cipher_data(ctx);
+    gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
     struct GRASSHOPPER_CIPHER_PARAMS* params = &gost_cipher_params[c->type];
 
     gost_grasshopper_cipher_destroy(c);
index 6eb749021513d49fc3dacb68170db97430602e8c..83bcbc6043fdafffc5ff56deba6fe1b690fa766b 100644 (file)
@@ -14,14 +14,16 @@ extern "C" {
 
 static GRASSHOPPER_INLINE void grasshopper_l(grasshopper_w128_t* w) {
     uint8_t x;
+               unsigned int j;
+               int i;
 
     // 16 rounds
-    for (unsigned int j = 0; j < sizeof(grasshopper_lvec) / sizeof(grasshopper_lvec[0]); j++) {
+    for (j = 0; j < sizeof(grasshopper_lvec) / sizeof(grasshopper_lvec[0]); j++) {
 
         // An LFSR with 16 elements from GF(2^8)
         x = w->b[15];    // since lvec[15] = 1
 
-        for (int i = 14; i >= 0; i--) {
+        for (i = 14; i >= 0; i--) {
             w->b[i + 1] = w->b[i];
             x ^= grasshopper_galois_mul(w->b[i], grasshopper_lvec[i]);
         }
@@ -31,12 +33,14 @@ static GRASSHOPPER_INLINE void grasshopper_l(grasshopper_w128_t* w) {
 
 static GRASSHOPPER_INLINE void grasshopper_l_inv(grasshopper_w128_t* w) {
     uint8_t x;
+               unsigned int j;
+               int i;
 
     // 16 rounds
-    for (unsigned int j = 0; j < sizeof(grasshopper_lvec) / sizeof(grasshopper_lvec[0]); j++) {
+    for (j = 0; j < sizeof(grasshopper_lvec) / sizeof(grasshopper_lvec[0]); j++) {
 
         x = w->b[0];
-        for (int i = 0; i < 15; i++) {
+        for (i = 0; i < 15; i++) {
             w->b[i] = w->b[i + 1];
             x ^= grasshopper_galois_mul(w->b[i], grasshopper_lvec[i]);
         }
@@ -48,8 +52,9 @@ static GRASSHOPPER_INLINE void grasshopper_l_inv(grasshopper_w128_t* w) {
 
 void grasshopper_set_encrypt_key(grasshopper_round_keys_t* subkeys, const grasshopper_key_t* key) {
     grasshopper_w128_t c, x, y, z;
+               int i;
 
-    for (int i = 0; i < 16; i++) {
+    for (i = 0; i < 16; i++) {
         // this will be have to changed for little-endian systems
         x.b[i] = key->k.b[i];
         y.b[i] = key->k.b[i + 16];
@@ -58,7 +63,7 @@ void grasshopper_set_encrypt_key(grasshopper_round_keys_t* subkeys, const grassh
     grasshopper_copy128(&subkeys->k[0], &x);
     grasshopper_copy128(&subkeys->k[1], &y);
 
-    for (int i = 1; i <= 32; i++) {
+    for (i = 1; i <= 32; i++) {
 
         // C Value
         grasshopper_zero128(&c);
@@ -88,18 +93,20 @@ void grasshopper_set_encrypt_key(grasshopper_round_keys_t* subkeys, const grassh
 }
 
 void grasshopper_set_decrypt_key(grasshopper_round_keys_t* subkeys, const grasshopper_key_t* key) {
+               int i;
     grasshopper_set_encrypt_key(subkeys, key);
 
-    for (int i = 1; i < 10; i++) {
+    for (i = 1; i < 10; i++) {
         grasshopper_l_inv(&subkeys->k[i]);
     }
 }
 
 void grasshopper_encrypt_block(grasshopper_round_keys_t* subkeys, grasshopper_w128_t* source,
                                grasshopper_w128_t* target, grasshopper_w128_t* buffer) {
+               int i;
     grasshopper_copy128(target, source);
 
-    for (int i = 0; i < 9; i++) {
+    for (i = 0; i < 9; i++) {
         grasshopper_append128(target, &subkeys->k[i]);
         grasshopper_append128multi(buffer, target, grasshopper_pil_enc128);
     }
@@ -116,11 +123,12 @@ void grasshopper_encrypt_block2(grasshopper_round_keys_t* subkeys, grasshopper_w
 
 void grasshopper_decrypt_block(grasshopper_round_keys_t* subkeys, grasshopper_w128_t* source,
                                grasshopper_w128_t* target, grasshopper_w128_t* buffer) {
+               int i;
     grasshopper_copy128(target, source);
 
     grasshopper_append128multi(buffer, target, grasshopper_l_dec128);
 
-    for (int i = 9; i > 1; i--) {
+    for (i = 9; i > 1; i--) {
         grasshopper_append128(target, &subkeys->k[i]);
         grasshopper_append128multi(buffer, target, grasshopper_pil_dec128);
     }
index fb42606b30aaa8b6021a2786866e2b875be40cca..176d16aeca19ce3cea7a0b8fe45c24d7afbcb571 100644 (file)
@@ -57,7 +57,8 @@ static GRASSHOPPER_INLINE void grasshopper_zero128(grasshopper_w128_t* x) {
 #if(GRASSHOPPER_BITS == 8 || GRASSHOPPER_BITS == 16)
     memset(&x, 0, sizeof(x));
 #else
-    for (int i = 0; i < GRASSHOPPER_BIT_PARTS; i++) {
+               int i;
+    for (i = 0; i < GRASSHOPPER_BIT_PARTS; i++) {
         GRASSHOPPER_ACCESS_128_VALUE(*x, i) = 0;
     }
 #endif
@@ -67,14 +68,16 @@ static GRASSHOPPER_INLINE void grasshopper_copy128(grasshopper_w128_t* to, const
 #if(GRASSHOPPER_BITS == 8 || GRASSHOPPER_BITS == 16)
     __builtin_memcpy(&to, &from, sizeof(w128_t));
 #else
-    for (int i = 0; i < GRASSHOPPER_BIT_PARTS; i++) {
+               int i;
+    for (i = 0; i < GRASSHOPPER_BIT_PARTS; i++) {
         GRASSHOPPER_ACCESS_128_VALUE(*to, i) = GRASSHOPPER_ACCESS_128_VALUE(*from, i);
     }
 #endif
 }
 
 static GRASSHOPPER_INLINE void grasshopper_append128(grasshopper_w128_t* x, const grasshopper_w128_t* y) {
-    for (int i = 0; i < GRASSHOPPER_BIT_PARTS; i++) {
+               int i;
+    for (i = 0; i < GRASSHOPPER_BIT_PARTS; i++) {
         GRASSHOPPER_ACCESS_128_VALUE(*x, i) ^= GRASSHOPPER_ACCESS_128_VALUE(*y, i);
     }
 }
@@ -88,8 +91,9 @@ static GRASSHOPPER_INLINE void grasshopper_plus128(grasshopper_w128_t* result, c
 // result & x must be different
 static GRASSHOPPER_INLINE void grasshopper_plus128multi(grasshopper_w128_t* result, const grasshopper_w128_t* x,
                                                     const grasshopper_w128_t array[][256]) {
+               int i;
     grasshopper_zero128(result);
-    for (int i = 0; i < GRASSHOPPER_MAX_BIT_PARTS; i++) {
+    for (i = 0; i < GRASSHOPPER_MAX_BIT_PARTS; i++) {
         grasshopper_append128(result, &array[i][GRASSHOPPER_ACCESS_128_VALUE_8(*x, i)]);
     }
 }
@@ -101,7 +105,8 @@ static GRASSHOPPER_INLINE void grasshopper_append128multi(grasshopper_w128_t* re
 }
 
 static GRASSHOPPER_INLINE void grasshopper_convert128(grasshopper_w128_t* x, const uint8_t* array) {
-    for (int i = 0; i < GRASSHOPPER_MAX_BIT_PARTS; i++) {
+               int i;
+    for (i = 0; i < GRASSHOPPER_MAX_BIT_PARTS; i++) {
         GRASSHOPPER_ACCESS_128_VALUE_8(*x, i) = array[GRASSHOPPER_ACCESS_128_VALUE_8(*x, i)];
     }
 }
index a82362f47e55f3cf8c382e12ee1c12ebd5e676a5..9dac7d4a486d208e01eef95ee2bc0764dcde652c 100644 (file)
@@ -205,10 +205,10 @@ extern struct gost_cipher_info gost_cipher_list[];
 /* Find encryption params from ASN1_OBJECT */
 const struct gost_cipher_info *get_encryption_params(ASN1_OBJECT *obj);
 /* Implementation of GOST 28147-89 cipher in CFB and CNT modes */
-const EVP_CIPHERcipher_gost();
-const EVP_CIPHERcipher_gost_cbc();
-const EVP_CIPHERcipher_gost_cpacnt();
-const EVP_CIPHERcipher_gost_cpcnt_12();
+const EVP_CIPHER *cipher_gost();
+const EVP_CIPHER *cipher_gost_cbc();
+const EVP_CIPHER *cipher_gost_cpacnt();
+const EVP_CIPHER *cipher_gost_cpcnt_12();
 void cipher_gost_destroy();
 # define EVP_MD_CTRL_KEY_LEN (EVP_MD_CTRL_ALG_CTRL+3)
 # define EVP_MD_CTRL_SET_KEY (EVP_MD_CTRL_ALG_CTRL+4)
index 54a2fe511f4912a12bb0b573c03edb32a76088c0..5d2c537a7acd95ef49f626490d71ce11014ed00d 100644 (file)
--- a/gost_md.c
+++ b/gost_md.c
@@ -30,7 +30,8 @@ EVP_MD *digest_gost(void)
             || !EVP_MD_meth_set_result_size(md, 32)
             || !EVP_MD_meth_set_input_blocksize(md, 32)
             || !EVP_MD_meth_set_app_datasize(md,
-                                             sizeof(struct ossl_gost_digest_ctx))
+                                             sizeof(struct
+                                                    ossl_gost_digest_ctx))
             || !EVP_MD_meth_set_init(md, gost_digest_init)
             || !EVP_MD_meth_set_update(md, gost_digest_update)
             || !EVP_MD_meth_set_final(md, gost_digest_final)
@@ -84,6 +85,7 @@ int gost_digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from)
 int gost_digest_cleanup(EVP_MD_CTX *ctx)
 {
     if (EVP_MD_CTX_md_data(ctx))
-        memset(EVP_MD_CTX_md_data(ctx), 0, sizeof(struct ossl_gost_digest_ctx));
+        memset(EVP_MD_CTX_md_data(ctx), 0,
+               sizeof(struct ossl_gost_digest_ctx));
     return 1;
 }
index 52522ee4a8eff48b0fe4d380e9abd573fb488e72..712e0acd88a8db7e1fe8f7b501717a69450dd520 100644 (file)
@@ -35,7 +35,8 @@ EVP_MD *digest_gost2012_256(void)
     if (_hidden_GostR3411_2012_256_md == NULL) {
         EVP_MD *md;
 
-        if ((md = EVP_MD_meth_new(NID_id_GostR3411_2012_256, NID_undef)) == NULL
+        if ((md =
+             EVP_MD_meth_new(NID_id_GostR3411_2012_256, NID_undef)) == NULL
             || !EVP_MD_meth_set_result_size(md, 32)
             || !EVP_MD_meth_set_input_blocksize(md, 64)
             || !EVP_MD_meth_set_app_datasize(md, sizeof(gost2012_hash_ctx))
@@ -64,7 +65,8 @@ EVP_MD *digest_gost2012_512(void)
     if (_hidden_GostR3411_2012_512_md == NULL) {
         EVP_MD *md;
 
-        if ((md = EVP_MD_meth_new(NID_id_GostR3411_2012_512, NID_undef)) == NULL
+        if ((md =
+             EVP_MD_meth_new(NID_id_GostR3411_2012_512, NID_undef)) == NULL
             || !EVP_MD_meth_set_result_size(md, 64)
             || !EVP_MD_meth_set_input_blocksize(md, 64)
             || !EVP_MD_meth_set_app_datasize(md, sizeof(gost2012_hash_ctx))
@@ -90,19 +92,22 @@ void digest_gost2012_512_destroy(void)
 
 static int gost_digest_init512(EVP_MD_CTX *ctx)
 {
-    init_gost2012_hash_ctx((gost2012_hash_ctx *) EVP_MD_CTX_md_data(ctx), 512);
+    init_gost2012_hash_ctx((gost2012_hash_ctx *) EVP_MD_CTX_md_data(ctx),
+                           512);
     return 1;
 }
 
 static int gost_digest_init256(EVP_MD_CTX *ctx)
 {
-    init_gost2012_hash_ctx((gost2012_hash_ctx *) EVP_MD_CTX_md_data(ctx), 256);
+    init_gost2012_hash_ctx((gost2012_hash_ctx *) EVP_MD_CTX_md_data(ctx),
+                           256);
     return 1;
 }
 
 static int gost_digest_update(EVP_MD_CTX *ctx, const void *data, size_t count)
 {
-    gost2012_hash_block((gost2012_hash_ctx *) EVP_MD_CTX_md_data(ctx), data, count);
+    gost2012_hash_block((gost2012_hash_ctx *) EVP_MD_CTX_md_data(ctx), data,
+                        count);
     return 1;
 }
 
@@ -115,7 +120,8 @@ static int gost_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
 static int gost_digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from)
 {
     if (EVP_MD_CTX_md_data(to) && EVP_MD_CTX_md_data(from))
-        memcpy(EVP_MD_CTX_md_data(to), EVP_MD_CTX_md_data(from), sizeof(gost2012_hash_ctx));
+        memcpy(EVP_MD_CTX_md_data(to), EVP_MD_CTX_md_data(from),
+               sizeof(gost2012_hash_ctx));
 
     return 1;
 }
index 6b38e60518c122a4b55c64afa1b1e7f16c7152e8..d84c7ef933d4cfa246c4c05887cdb2e48d9ee6af 100644 (file)
@@ -369,10 +369,12 @@ static int pkey_gost2012cp_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
  */
 int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen)
 {
+    BIGNUM *sig_r = NULL, *sig_s = NULL;
+    DSA_SIG_get0(&sig_r, &sig_s, s);
     *siglen = 2 * order;
     memset(sig, 0, *siglen);
-    store_bignum(s->s, sig, order);
-    store_bignum(s->r, sig + order, order);
+    store_bignum(sig_s, sig, order);
+    store_bignum(sig_r, sig + order, order);
     DSA_SIG_free(s);
     return 1;
 }
@@ -418,14 +420,16 @@ static int pkey_gost_ec_cp_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
 DSA_SIG *unpack_cp_signature(const unsigned char *sig, size_t siglen)
 {
     DSA_SIG *s;
+    BIGNUM *sig_r = NULL, *sig_s = NULL;
 
     s = DSA_SIG_new();
     if (s == NULL) {
         GOSTerr(GOST_F_UNPACK_CP_SIGNATURE, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
-    s->s = BN_bin2bn(sig, siglen / 2, NULL);
-    s->r = BN_bin2bn(sig + siglen / 2, siglen / 2, NULL);
+    DSA_SIG_get0(&sig_r, &sig_s, s);
+    sig_s = BN_bin2bn(sig, siglen / 2, NULL);
+    sig_r = BN_bin2bn(sig + siglen / 2, siglen / 2, NULL);
     return s;
 }
 
@@ -480,7 +484,7 @@ static int pkey_gost_mac_init(EVP_PKEY_CTX *ctx)
         struct gost_mac_key *key = EVP_PKEY_get0(pkey);
         if (key) {
             data->mac_param_nid = key->mac_param_nid;
-                                               data->mac_size      = key->mac_size;
+            data->mac_size = key->mac_size;
         }
     }
 
@@ -568,11 +572,11 @@ static int pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
                             GOST_R_MAC_KEY_NOT_SET);
                     return 0;
                 }
-            return EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(mctx))
-                (mctx, EVP_MD_CTRL_SET_KEY, 0, key);
+                return EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(mctx))
+                    (mctx, EVP_MD_CTRL_SET_KEY, 0, key);
             } else {
-            return EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(mctx))
-                (mctx, EVP_MD_CTRL_SET_KEY, 32, &(data->key));
+                return EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(mctx))
+                    (mctx, EVP_MD_CTRL_SET_KEY, 32, &(data->key));
             }
         }
     case EVP_PKEY_CTRL_MAC_LEN:
@@ -659,7 +663,7 @@ static int pkey_gost_mac_keygen_base(EVP_PKEY_CTX *ctx,
         return 0;
     memcpy(keydata->key, data->key, 32);
     keydata->mac_param_nid = data->mac_param_nid;
-               keydata->mac_size      = data->mac_size;
+    keydata->mac_size = data->mac_size;
     EVP_PKEY_assign(pkey, mac_nid, keydata);
     return 1;
 }
@@ -678,9 +682,9 @@ static int pkey_gost_mac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
 {
     struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
 
-               if (data == NULL) {
-                       pkey_gost_mac_init(ctx);
-               }
+    if (data == NULL) {
+        pkey_gost_mac_init(ctx);
+    }
 
     data = EVP_PKEY_CTX_get_data(ctx);
     if (!data) {